FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
Bpexch
BpexchequitableAmaranthGoat
Public
Like
equitableAmaranthGoat
Home
Code
4
backend
3
frontend
2
shared
1
README.md
Branches
1
Pull requests
Remixes
1
History
Environment variables
Settings
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in miliseconds.
Sign up now
Code
/
Code
/
Search
index.ts
https://Bpexch--3778fa0239dc11f0b02b9e149126039e.web.val.run
README.md

Betting Platform - Multi-Level Management System

A comprehensive betting platform with hierarchical user management system similar to bpexch.com.

🚀 Live Demo

Website URL: [Your Val Town URL]

Default Login Credentials:

  • Username: owner
  • Password: owner123

📋 System Hierarchy

  1. 👑 Owner (Top Level)

    • Can create/manage Company accounts
    • Full system access
    • Revenue monitoring
    • Access to all features
  2. 🏢 Company

    • Can create/manage Super Admin accounts
    • Company-level settings and limits
    • Monitor company performance
  3. ⭐ Super Admin

    • Can create/manage Dealer accounts
    • Monitor dealer performance
    • Handle escalations
  4. 🎯 Dealer

    • Can create/manage End Users
    • Handle user betting activities
    • Manage user balances
  5. 👤 End Users

    • Login with credentials provided by dealer
    • Place bets and manage account
    • View betting history

✨ Key Features

Authentication & Security

  • ✅ Role-based authentication system
  • ✅ No public signup - all accounts created by upper hierarchy
  • ✅ Session-based login with secure cookies
  • ✅ Hierarchical access control

User Management

  • ✅ Create users based on role hierarchy
  • ✅ Update user balances
  • ✅ Monitor user activity
  • ✅ Real-time user statistics

Betting System

  • ✅ Live sports matches (Cricket, Football, Tennis)
  • ✅ Real-time odds display
  • ✅ Bet placement with balance validation
  • ✅ Betting history tracking
  • ✅ Multiple bet types support

Company Management (Owner Only)

  • ✅ Create and manage multiple companies
  • ✅ Set company-specific limits and settings
  • ✅ Monitor company performance
  • ✅ Configure allowed sports

Dashboard & Analytics

  • ✅ Role-specific dashboards
  • ✅ Real-time statistics
  • ✅ User activity monitoring
  • ✅ Revenue tracking

🛠️ Tech Stack

  • Backend: Hono + SQLite + Val Town
  • Frontend: React 18 + TailwindCSS
  • Authentication: Session-based with cookies
  • Database: SQLite with migrations
  • Styling: TailwindCSS + Custom CSS
  • Deployment: Val Town Platform

📁 Project Structure

├── backend/
│   ├── database/
│   │   ├── migrations.ts    # Database schema & default data
│   │   └── queries.ts       # Database query functions
│   └── routes/              # API route modules
│       ├── auth.ts          # Authentication endpoints
│       ├── users.ts         # User management endpoints
│       └── betting.ts       # Betting system endpoints
│   ├── index.ts             # Main HTTP entry point
├── frontend/
│   ├── components/
│   │   ├── UserManagement.js     # User creation & management
│   │   ├── BettingInterface.js   # Betting interface for users
│   │   └── CompanyManagement.js  # Company management (owner)
│   └── index.html           # Main HTML with React app
├── shared/
│   └── types.ts             # Shared TypeScript types
└── README.md

🎮 How to Use

1. Owner Login

  • Use default credentials: owner / owner123
  • Access all features including company creation

2. Create Company (Owner Only)

  • Go to "Companies" tab
  • Click "Create New Company"
  • Enter company name and settings

3. Create Super Admin (Owner/Company)

  • Go to "User Management" tab
  • Click "Create New User"
  • Select "Super Admin" role
  • Set initial balance and limits

4. Create Dealers (Super Admin)

  • Login as Super Admin
  • Create dealer accounts
  • Manage dealer limits and commissions

5. Create End Users (Dealer)

  • Login as Dealer
  • Create user accounts for betting
  • Set user balances and limits

6. Betting (End Users)

  • Login as end user
  • View available matches
  • Place bets on teams/outcomes
  • Monitor betting history

🔧 API Endpoints

Authentication

  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • GET /api/auth/me - Check auth status

User Management

  • GET /api/users - Get subordinate users
  • POST /api/users - Create new user
  • PATCH /api/users/:id/balance - Update user balance
  • GET /api/users/stats - Get dashboard statistics

Company Management

  • GET /api/users/companies - Get companies (owner only)
  • POST /api/users/companies - Create company (owner only)

Betting System

  • GET /api/betting/matches - Get available matches
  • POST /api/betting/bets - Place a bet
  • GET /api/betting/bets - Get user's bets
  • GET /api/betting/balance - Get current balance

🎯 Sample Data

The system comes pre-loaded with:

  • Default owner account
  • Sample cricket and football matches
  • Realistic odds and betting options

🔒 Security Features

  • Role-based Access Control: Each role can only access appropriate features
  • Session Management: Secure session handling with expiration
  • Input Validation: All inputs are validated on both client and server
  • Balance Validation: Prevents betting more than available balance
  • Hierarchical Permissions: Users can only manage their subordinates

🚀 Deployment

This project is designed for Val Town platform:

  1. All code is ready to deploy
  2. Database migrations run automatically
  3. HTTP trigger is configured
  4. No additional setup required

📱 Mobile Responsive

The interface is fully responsive and works on:

  • Desktop computers
  • Tablets
  • Mobile phones
  • All modern browsers

🎨 UI/UX Features

  • Modern Design: Glass morphism effects and gradients
  • Intuitive Navigation: Role-based navigation menus
  • Real-time Updates: Live balance and statistics updates
  • Loading States: Smooth loading animations
  • Error Handling: User-friendly error messages
  • Responsive Layout: Works on all screen sizes

🔄 Future Enhancements

Potential features for future versions:

  • Live match updates and scores
  • Advanced betting types (over/under, handicap)
  • Payment gateway integration
  • Mobile app development
  • Advanced analytics and reporting
  • Multi-language support
  • Push notifications

Note: This is a demo betting platform. For production use, ensure compliance with local gambling laws and regulations.

HTTP
  • index.ts
    Bpexch--37…9e.web.val.run
Code
backendfrontendsharedREADME.md
Go to top
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Product
FeaturesPricing
Developers
DocsStatusAPI ExamplesNPM Package Examples
Explore
ShowcaseTemplatesNewest ValsTrending ValsNewsletter
Company
AboutBlogCareersBrandhi@val.town
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.