An interactive financial education game powered by AI. Make life decisions, manage your finances, and work towards financial independence in a realistic simulation.
- Docker & Docker Compose installed
- Google Gemini API key (Get one here)
-
Configure Backend Environment
cd backend # Create .env file with your Gemini API key echo "GEMINI_API_KEY=your_api_key_here" > .env
-
Start Everything
docker-compose up --build
-
Access the Application
- Frontend: http://localhost:4000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
docker-compose down.
โโโ backend/
โ โโโ main.py # FastAPI application with game endpoints
โ โโโ models.py # SQLModel database models
โ โโโ database.py # Database configuration & sessions
โ โโโ game_engine.py # Core game mechanics & decision effects
โ โโโ ai_narrative.py # Gemini AI narrative generation
โ โโโ utils.py # Helper functions & calculations
โ โโโ chat_utils.py # Chat history & summaries
โ โโโ requirements.txt # Python dependencies
โ โโโ prompts/ # AI prompt templates
โ โ โโโ narrative_prompt.json
โ โ โโโ consequence_prompt.json
โ โ โโโ learning_moment_prompt.json
โ โ โโโ fallback_narratives.json
โ โโโ .env # Environment variables (create this)
โโโ frontend/
โ โโโ src/
โ โ โโโ routes/ # Page components
โ โ โ โโโ OnboardingPage.js
โ โ โ โโโ GamePage.js
โ โ โโโ components/ # UI components
โ โ โ โโโ GameDashboard.js
โ โ โ โโโ SceneView.js
โ โ โ โโโ ChoiceList.js
โ โ โ โโโ MetricsBar.js
โ โ โ โโโ ConsequenceModal.js
โ โ โ โโโ TopBar.js
โ โ โโโ store/ # Zustand state management
โ โ โ โโโ gameStore.js
โ โ โโโ api/ # TanStack Query API hooks
โ โ โ โโโ lifesim.js
โ โ โโโ hooks/ # Custom React hooks
โ โโโ package.json
โโโ docs/
โ โโโ API_DOCUMENTATION.md
โ โโโ DATABASE.md
โ โโโ EXPENSE_CATEGORIES_FRONTEND_GUIDE.md
โ โโโ TANSTACK_ZUSTAND_README.md
โโโ docker-compose.yml # Docker orchestration
- AI-Generated Narratives: Dynamic storytelling powered by Google Gemini 2.0 Flash
- Financial Simulation: Realistic income, expenses, investments, and debt management
- Expense Breakdown: Detailed expense categories (housing, food, transport, utilities, subscriptions, insurance, other)
- Life Metrics: Energy, motivation, social connections, and financial knowledge
- Decision Making: Choices with realistic consequences and trade-offs
- Curveballs: Random life events that test your financial resilience
- Learning Moments: Educational insights about personal finance
- Progress Tracking: Transaction history and FI score tracking
- Auto-reloads on code changes
- API documentation at
/docs - SQLite database with SQLModel ORM
- Google Gemini AI integration for narrative generation
- Background task processing for faster response times
- Hot-reload enabled
- TanStack Query for server state management
- Zustand for client state management
- Responsive design with custom CSS
- POST
/api/auth/register- Create new account - POST
/api/auth/login- Login to existing account - POST
/api/auth/logout- Logout
- POST
/api/onboarding- Start new game (requires authentication) - GET
/api/game/{session_id}- Get current game state - POST
/api/step- Make a decision and advance the game - GET
/api/next-question/{session_id}- Fetch pre-generated next question - GET
/api/transactions/{session_id}- Get transaction history - GET
/api/leaderboard- View top players
- POST
/api/chat- Chat with AI about financial topics - GET
/api/models- List available AI models
See docs/API_DOCUMENTATION.md for complete API documentation.
- Open http://localhost:4000
- Create an account or login
- Complete the onboarding (name, city, education, risk attitude)
- Start playing! Make decisions and see your financial journey unfold
Required:
GEMINI_API_KEY=your_gemini_api_key_hereThe game uses Google Gemini 2.0 Flash (Experimental) by default. Available models:
gemini-2.0-flash-exp(recommended, fastest)gemini-1.5-pro(more capable, slower)gemini-1.5-flash(balanced)
To change the model, update the model parameter in backend/ai_narrative.py.
Add to backend/requirements.txt, then:
docker-compose up --build backendAdd to frontend/package.json, then:
docker-compose up --build frontendMissing Gemini API key:
# Make sure .env file exists in backend/
cat backend/.env
# Should show: GEMINI_API_KEY=your_key_herePort already in use:
# Change ports in docker-compose.yml
ports:
- "4001:4000" # Frontend
- "8001:8000" # BackendFrontend can't reach backend:
- Check
REACT_APP_API_URLin docker-compose.yml - Verify CORS settings in
backend/main.py
Changes not reflecting:
docker-compose down
docker-compose up --buildAI not generating narratives:
- Verify your Gemini API key is valid
- Check backend logs:
docker-compose logs backend - Ensure you have API quota remaining
- API Reference:
docs/API_DOCUMENTATION.md - Database Schema:
docs/DATABASE.md - Expense Categories Guide:
docs/EXPENSE_CATEGORIES_FRONTEND_GUIDE.md - State Management:
docs/TANSTACK_ZUSTAND_README.md
- Player makes a decision โ
POST /api/step - AI generates consequence narrative (immediate response)
- Effects applied to game state (money, metrics, expenses)
- Next question generated in background and cached
- Frontend fetches cached question โ
GET /api/next-question/{session_id}
- narrative_prompt.json: Initial scenario generation
- consequence_prompt.json: Decision outcomes and effects
- learning_moment_prompt.json: Educational financial insights
- fallback_narratives.json: Backup narratives when AI unavailable
Each player's monthly expenses are divided into 7 categories:
- Housing (40-45%): Rent/mortgage
- Food (25%): Groceries, dining
- Transport (8-12%): Public transport, car costs
- Utilities (12%): Bills, internet, phone
- Subscriptions (5%): Entertainment services
- Insurance (5-8%): Health, car, home
- Other (5-7%): Personal care, pets, misc
Players can reduce expenses through decisions (e.g., cancel subscriptions, reduce food budget), but face trade-offs in energy, motivation, or social connections.
Built for Junction 2025 ๐