A modern, full-stack sports betting platform built with FastAPI, React, and Supabase.
WagerBabe follows a clean, modular architecture with clear separation between client and backend:
wagerbabe/
├── client/ # Next.js React application
├── backend/ # FastAPI application
├── docs/ # Documentation and guides
└── README.md # This file
- Backend: FastAPI with Python
- client: Next.js 15 with React 19
- Authentication: Supabase Auth
- Database: PostgreSQL via Supabase
- UI Components: shadcn/ui with Tailwind CSS
- State Management: React Context API
- Styling: Custom theming system with automatic propagation
- Node.js 18+ and npm
- Python 3.8+
- Supabase account (for when you're ready to set up authentication)
git clone <repository-url>
cd wagerbabecd backend
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Copy environment file
cp .env.example .env
# Edit .env with your Supabase credentials when ready
# Run the server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd client
# Install dependencies
npm install
# Copy environment file
cp .env.local.example .env.local
# Edit .env.local with your Supabase credentials when ready
# Run the development server
npm run dev- Create a new Supabase project
- The SQL migrations are available in
docs/supabase-migrations.sqlfor future use - Update your environment files with the Supabase credentials
backend/
├── app/
│ ├── api/v1/ # API routes
│ │ ├── endpoints/ # Individual endpoint files
│ │ └── api.py # Main API router
│ ├── core/ # Core configuration
│ │ ├── config.py # Settings and configuration
│ │ └── supabase.py # Supabase client setup
│ ├── models/ # Pydantic models
│ ├── services/ # Business logic
│ ├── utils/ # Utility functions
│ └── main.py # FastAPI application entry point
├── tests/ # Test files
└── requirements.txt # Python dependencies
client/
├── src/
│ ├── app/ # Next.js app directory
│ ├── components/ # React components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── base/ # Custom base components
│ │ └── theme-provider.tsx
│ ├── contexts/ # React Context providers
│ ├── lib/ # Utility libraries
│ │ ├── utils.ts # General utilities
│ │ ├── theme.ts # Theme configuration
│ │ ├── supabase.ts # Supabase client
│ │ └── supabase-types.ts # TypeScript types
│ └── styles/ # Global styles
├── public/ # Static assets
└── package.json # Node.js dependencies
WagerBabe implements a sophisticated theming system where base component styles automatically propagate to composite components.
- Automatic Style Propagation: Changes to base components automatically apply to all composite components
- Sports Betting Specific Colors: Pre-defined color schemes for betting statuses (win, loss, pending, live)
- Context-Aware Theming: Different themes for sportsbook, casino, and poker sections
- Dark/Light Mode Support: Built-in theme switching with system preference detection
The theming system is configured in client/src/lib/theme.ts:
// Sports betting specific colors
export const sportsTheme = {
win: { light: "oklch(0.7 0.15 142)", DEFAULT: "oklch(0.6 0.18 142)" },
loss: { light: "oklch(0.7 0.15 27)", DEFAULT: "oklch(0.6 0.18 27)" },
pending: { light: "oklch(0.8 0.1 60)", DEFAULT: "oklch(0.7 0.15 60)" },
live: { light: "oklch(0.8 0.15 15)", DEFAULT: "oklch(0.7 0.2 15)" }
}-
Base Components: Located in
client/src/components/base/BettingCard: Themed card component with betting-specific variantsOddsButton: Automatically styled based on odds valuesStatusBadge: Color-coded status indicators
-
CSS Utilities: Pre-defined classes in
globals.css.odds-positive { @apply text-win font-semibold; } .status-live { @apply bg-live text-live-foreground animate-pulse; }
-
Theme Provider: Wrap your app with theme providers
<ThemeProvider defaultTheme="system" defaultBettingContext="sportsbook"> <YourApp /> </ThemeProvider>
WagerBabe uses React Context API for state management with three main contexts:
Manages user authentication state, login/logout, and user profile data.
const { user, signIn, signOut, loading } = useAuth()Handles betting slip, odds selection, and bet placement.
const { state, addSelection, removeSelection, placeBet } = useBetting()Manages theme switching and betting context (sportsbook/casino/poker).
const { theme, setTheme, bettingContext, setBettingContext } = useTheme()Authentication is handled through Supabase Auth with the following features:
- Email/password authentication
- Automatic session management
- Protected routes
- User profile management
- Password reset functionality
import { useAuth } from '@/contexts'
function LoginForm() {
const { signIn, loading } = useAuth()
const handleSubmit = async (email: string, password: string) => {
const { error } = await signIn(email, password)
if (error) {
// Handle error
}
}
}The application uses PostgreSQL through Supabase with the following main tables:
- profiles: User profile information and balance
- bets: Betting history and current bets
- transactions: Financial transaction history
See docs/supabase-migrations.sql for the complete schema.
cd backend
pytestcd client
npm testThe FastAPI backend can be deployed to any platform that supports Python applications:
- Heroku
- Railway
- DigitalOcean App Platform
- AWS Lambda (with Mangum)
The Next.js client can be deployed to:
- Vercel (recommended)
- Netlify
- AWS Amplify
- Any platform supporting Node.js
- Component Development: Always extend base components rather than creating new ones from scratch
- Styling: Use the theme system utilities instead of hardcoded colors
- State Management: Use appropriate context providers for different types of state
- Type Safety: Leverage TypeScript types for Supabase operations
- Testing: Write tests for all new components and API endpoints
- Fork the repository
- Create a feature branch
- Make your changes following the established patterns
- Write tests for new functionality
- Submit a pull request
This project is licensed under the MIT License.