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.