• Townie
    AI
  • Blog
  • Docs
  • Pricing
  • Weโ€™re hiring!
Log inSign up
Bpexch

Bpexch

equitableAmaranthGoat

Public
Like
equitableAmaranthGoat
Home
Code
4
backend
3
frontend
2
shared
1
README.md
Branches
1
Pull requests
Remixes
1
History
Environment variables
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data โ€“ all from the browser, and deployed in milliseconds.
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
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
Weโ€™re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
ยฉ 2025 Val Town, Inc.