african nations league match simulation using AI commentary
# African Nations League – Project Guide
This app simulates an African Nations League with team registration, bracket play, AI commentary, analytics, and automated email notifications.
## What’s inside
- **Backend (Flask)** in `backend/`
- `app.py`: JSON APIs, match simulator, knockout logic, AI hooks
- `config.py`: Firebase + Gemini initialization
- `ai_commentary.py`: AI preview/commentary/analysis with fallbacks
- **Frontend (React)** in `frontend/`
- Pages: `HomePage`, `BracketPage`, `StandingsPage`, `TeamAnalyticsPage`, `RegisterPage`, `DashboardPage`, `MatchPage`, `LoginPage`
- Global styles in `frontend/src/style.css`
- **Static styles** for legacy pages in `static/css/style.css`
## Setup
Prereqs:
- Python 3.10+
- Node 18+
- Firebase project with Firestore (or run without data)
- Optional: Gemini API key for AI features
### 1) Backend
Install:
```
pip install -r requirements.txt
```
Environment (choose one way for Firebase creds):
- Place `serviceAccountKey.json` at project root, or
- Set `FIREBASE_CONFIG_JSON` (entire JSON string), or
- Set individual vars: `FIREBASE_PROJECT_ID`, `FIREBASE_PRIVATE_KEY`, `FIREBASE_CLIENT_EMAIL`
Optional Gemini:
- Set `GEMINI_API_KEY` to enable AI text (fallback used if missing)
Optional Email Notifications:
- Set `EMAIL_USER` (your Gmail address)
- Set `EMAIL_PASSWORD` (app password for Gmail)
- When configured, the system will automatically email the federations of both teams when matches are completed with scoreline and goal scorers
- Federation emails are pulled from the team registration data in Firebase
Run:
```
python backend/app.py
#
localhost
```
### 2) Frontend
From `frontend/`:
```
npm install
npm start
#
localhost
```
## Common flows
- Login (demo): `admin@anl.com` / `admin123`
- Register teams: `/register`
- Create bracket: `/admin` (needs 8 teams)
- View bracket: `/tournament`
- Play/simulate matches: from `/admin` or the match page
- Golden Boot: `/standings`
- Team …