A stock prediction game where users bet virtual coins on AI-generated stock forecasts. Users sign up, receive a daily AI prediction for a stock (up/down), place a virtual coin bet, and earn or lose coins based on whether the prediction was correct. A leaderboard tracks top performers.
| Layer | Technology |
|---|---|
| Frontend | Next.js 14, React 18, TypeScript, Tailwind CSS |
| Backend | FastAPI (Python), Uvicorn |
| Database | Supabase (PostgreSQL) |
| Auth | Supabase Auth + JWT middleware |
| AI/ML | AWS SageMaker (daily predictions), yfinance |
| Storage | AWS S3 (prediction results) |
| Monitoring | AWS CloudWatch |
| Testing | pytest (backend), Vitest + Playwright (frontend) |
frontend/— Next.js appbackend/— FastAPI backend, serves all API endpointssupabase/migrations/— SQL migration files for database schema
- Python 3.10+
- Node.js 18+
- pip
- A Supabase account and project
- (Optional) AWS account for SageMaker/S3/CloudWatch
Backend
cd backend
pip install -r requirements.txtFrontend
cd frontend
npm installbackend/.env
SUPABASE_URL=your_supabase_url
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key
SUPABASE_JWT_SECRET=your_jwt_secret
AWS_ACCESS_KEY_ID=your_aws_key
AWS_SECRET_ACCESS_KEY=your_aws_secret
AWS_REGION=us-east-1
frontend/.env.local
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
Get Supabase credentials from: Dashboard → Settings → Database / API.
# Backend (from backend/)
uvicorn main:app --reload
# Frontend (from frontend/, separate terminal)
npm run dev- Backend: http://localhost:8000
- Frontend: http://localhost:3000
- API docs: http://localhost:8000/docs
Most endpoints require a Authorization: Bearer <token> header (set by Supabase Auth). Public endpoints are marked.
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| GET | / |
Public | Health check |
| GET | /prediction/today |
Public | Most recent AI prediction for a stock |
| GET | /prediction/history |
Public | Past AI predictions for a stock |
| GET | /stock/price |
Public | Current price for a single ticker |
| GET | /stocks/market-data |
Public | Batch price + sparkline for multiple tickers |
| GET | /leaderboard |
Public | Top users by dubcoin balance |
| GET | /me |
Required | Current user from JWT |
| GET | /auth/me |
Required | Current user id and email from middleware |
| GET | /user/profile |
Required | Authenticated user's full profile |
| POST | /bets/place |
Required | Place a bet on a stock direction |
| GET | /bets/history |
Required | Authenticated user's betting history |
| GET | /bets/resolve |
Required | Resolve all pending bets for the user |
Query parameters:
stock— ticker symbol (default:AAPL) — used by prediction endpointsticker— ticker symbol — used by/stock/pricetickers— comma-separated symbols (default:AAPL,TSLA,MSFT,NVDA,AMZN,META) — used by/stocks/market-datalimit— number of records to return (default varies per endpoint)
| Table | Description |
|---|---|
users |
User profiles — balance, streak, rank, accuracy, xp, level |
bets |
Bet records — ticker, direction, stake, status, entry price |
ai_predictions |
AI prediction history — stock, prediction, confidence, actual, correct, date |
- User registration and login (Supabase Auth)
- Daily AI stock prediction (up/down + confidence score)
- Virtual coin betting on predictions
- Bet resolution with automatic payout and balance updates
- Prediction history and accuracy tracking
- Leaderboard of top coin earners
- AWS CloudWatch monitoring of API latency and errors
- Fork the repo and create a branch from
main - Make your changes in the branch
- Run tests before opening a PR:
# Backend tests cd backend && pytest # Frontend tests cd frontend && npm test
- Open a pull request with
base: mainand describe your changes