Skip to content

Capstone-Project-Financial/Gamified_Financial_Learning_Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MoneyMaster

Master money management through gamified lessons, real-time quiz battles, and simulated stock trading.

Live Demo License: MIT TypeScript React Node.js MongoDB Socket.io Redis

An AI-powered, gamified financial literacy platform β€” built for young learners ages 5–25.


🌟 Overview

Financial literacy is rarely taught in schools, yet it's one of the most critical life skills. MoneyMaster bridges that gap by turning personal finance education into an engaging, game-like experience.

The Problem β€” Young learners lack access to structured, engaging financial education. Traditional resources are dry, disconnected from real-world scenarios, and fail to sustain motivation.

The Solution β€” A full-stack gamified learning platform that combines:

  • Adaptive AI-driven lessons that personalize content based on individual performance
  • Real-time 1v1 quiz battles with ELO-based matchmaking for competitive learning
  • Simulated stock trading to practice investment strategies risk-free
  • XP, achievements, and leaderboards to drive sustained engagement
  • An AI companion mascot (Rupi) that guides learners through their journey

Why It Matters β€” MoneyMaster transforms passive learning into active mastery through gamification psychology, adaptive intelligence, and real-time social interaction.


πŸš€ Live Demo & Screenshots

Landing Page Dashboard Learning
Landing Page Dashboard Adaptive Lessons
Battle Arena Leaderboard Wallet
Real-Time Quiz Battles Leaderboard Virtual Wallet & Stocks

Note: Replace placeholder paths with actual screenshots. Recommended size: 1280Γ—720px.


🎯 Target Audience

Audience Use Case
Students (Ages 5–25) Learn budgeting, saving, investing, and financial planning through gamified modules
Educators & Parents Supplement curriculum with an interactive, self-paced financial literacy tool
EdTech Enthusiasts Explore a production-grade reference architecture for gamified learning platforms
Developers Study a full-stack TypeScript monorepo with real-time systems, adaptive AI, and ELO matchmaking

✨ Key Features

1. Adaptive Learning Engine (V2)

Server-driven, step-based lessons (info cards + MCQs) that dynamically adapt based on user accuracy, response times, and topic-specific performance telemetry. The system recommends the next optimal lesson in real time.

2. Real-Time 1v1 Quiz Battles

WebSocket-powered competitive quiz system with three modes β€” Quick Match, Ranked, and Private Room. Features ELO-based skill matchmaking, adaptive question selection targeting each player's weak areas, and live score updates.

3. ELO Rating & Matchmaking

Standard ELO formula with dynamic K-factors (K=40 new, K=32 standard, K=16 elite). Redis sorted-set queue with composite scoring and skill-window relaxation for fair, fast matchmaking.

4. Anti-Cheat System

Redis-backed rate limiting (1 answer per 500ms), answer replay prevention via SETNX locks, tab-switch event recording, and bot-pattern heuristics through response-time variance analysis.

5. AI-Powered Question Generation

GPT-4o-mini generates financial literacy questions on demand when the question pool drops below threshold. Output is validated with Zod schemas before persisting to the question bank.

6. Simulated Stock Market

Virtual stock trading environment where learners practice buying, selling, and tracking portfolio performance β€” building real-world investment intuition without risk.

7. Gamification Engine

XP leveling system, login streaks, achievement unlocks, virtual wallet with coin rewards, and cross-platform leaderboards to sustain engagement.

8. AI Mascot β€” Rupi

An animated SVG companion with multiple emotional states (waving, celebrating, thinking, sad) that provides contextual guidance, celebrates achievements, and enhances the learning experience with sound effects.

9. Comprehensive Authentication

OTP-based email verification (Brevo HTTP API), Google OAuth 2.0, JWT Bearer tokens, and password reset flows β€” all production-ready.

10. Dark/Light Theme

System-aware theme switching with polished glassmorphism UI, smooth gradients, and micro-animations across all pages.


πŸ—οΈ System Architecture

High-Level System Workflow

graph TD
    A[User Client - React SPA] --> B[REST API - Express 5]
    A <-->|WebSocket| C[Socket.io Server]
    B --> D[Authentication Middleware]
    D --> E[Feature Modules]
    E --> F[(MongoDB Atlas)]
    C --> G[(Redis Cache)]
    E --> H[Adaptive Engine]
    H --> I[OpenAI GPT-4o-mini]
    E --> J[Brevo Email API]
    D --> K[Google OAuth 2.0]
Loading

AI-Powered Adaptive Learning Pipeline

graph TD
    A[User Submits MCQ Answer] --> B[Record Telemetry]
    B --> C{Performance Analysis}
    C -->|Strong| D[Advance Difficulty]
    C -->|Weak| E[Reinforce Topic]
    D --> F[Adaptive Lesson Selection]
    E --> F
    F --> G[Serve Next Lesson]
    H[Question Pool Low] --> I[GPT-4o-mini Generation]
    I --> J[Zod Schema Validation]
    J --> K[Persist to QuestionBank]
Loading

Real-Time Battle System Flow

graph TD
    A[Player Joins Queue] --> B[Redis Sorted Set - ELO Score]
    B --> C{Skill Window Match}
    C -->|Match Found| D[Create Battle Room]
    C -->|No Match| E[Relax Skill Window]
    E --> C
    D --> F[Both Players Ready]
    F --> G[Serve Adaptive Questions]
    G --> H[Anti-Cheat Validation - Redis SETNX]
    H --> I[Score Update via WebSocket]
    I --> J{More Questions?}
    J -->|Yes| G
    J -->|No| K[Calculate ELO Changes]
    K --> L[Battle Results + XP Awards]
Loading

Deployment Architecture

graph TD
    A[GitHub Repository] -->|Auto Deploy| B[Vercel - React SPA]
    A -->|Auto Deploy| C[Render - Node.js API]
    C --> D[(MongoDB Atlas)]
    C --> E[(Redis Cloud)]
    C --> F[Brevo Email API]
    C --> G[OpenAI API]
    B -->|HTTPS| C
Loading

βš™οΈ Technical Stack

Layer Technologies
Frontend React 18, TypeScript, Vite 5, Tailwind CSS 3, shadcn/ui, Radix UI Primitives
State Management React Context (Auth, Wallet, Progress, Battle, Socket, Mascot), TanStack React Query v5
Routing & Forms React Router v6, React Hook Form, Zod v3 validation
Charts & UI Recharts, Lucide Icons, Sonner Toasts, Embla Carousel, next-themes
Backend Node.js, Express 5, TypeScript, Zod v4 validation
Real-Time Socket.io 4 (server + client), Redis Adapter for horizontal scaling
Database MongoDB Atlas, Mongoose 8 ODM
Cache & Pub-Sub Redis (ioredis) β€” matchmaking queue, anti-cheat, Socket.io adapter
AI/ML OpenAI GPT-4o-mini β€” adaptive question generation, Zod-validated output
Authentication JWT (jsonwebtoken), Passport.js (Google OAuth 2.0), OTP via Brevo
Email Brevo HTTP API (not SMTP β€” compatible with Render's port restrictions)
Security Helmet, CORS, bcryptjs, rate limiting, anti-cheat middleware
Logging Pino + pino-pretty (structured JSON logging)
DevOps Vercel (frontend), Render (backend), MongoDB Atlas, Redis Cloud

πŸ“‚ Project Structure

MoneyMaster/
β”œβ”€β”€ client/                          # React SPA (Vite + TypeScript)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ mascot/              # Rupi AI companion (SVG + states)
β”‚   β”‚   β”‚   └── ui/                  # shadcn/ui component library
β”‚   β”‚   β”œβ”€β”€ contexts/                # React Context providers
β”‚   β”‚   β”‚   β”œβ”€β”€ AuthContext.tsx       #   JWT auth state
β”‚   β”‚   β”‚   β”œβ”€β”€ BattleContext.tsx     #   Real-time battle state
β”‚   β”‚   β”‚   β”œβ”€β”€ MascotContext.tsx     #   Rupi companion logic
β”‚   β”‚   β”‚   β”œβ”€β”€ ProgressContext.tsx   #   Learning progress tracking
β”‚   β”‚   β”‚   β”œβ”€β”€ SocketContext.tsx     #   Socket.io connection
β”‚   β”‚   β”‚   └── WalletContext.tsx     #   Virtual wallet state
β”‚   β”‚   β”œβ”€β”€ features/                # Feature-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                #   Auth forms & flows
β”‚   β”‚   β”‚   β”œβ”€β”€ battle/              #   Battle UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ learning/            #   Lesson & quiz components
β”‚   β”‚   β”‚   └── wallet/              #   Wallet & stock components
β”‚   β”‚   β”œβ”€β”€ hooks/                   # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ layouts/                 # Dashboard layout + navigation
β”‚   β”‚   β”œβ”€β”€ lib/                     # Utilities & sound engine
β”‚   β”‚   β”œβ”€β”€ pages/                   # 21 route pages
β”‚   β”‚   β”œβ”€β”€ services/                # API client & socket service
β”‚   β”‚   └── types/                   # TypeScript type definitions
β”‚   β”œβ”€β”€ vercel.json                  # SPA routing config
β”‚   └── package.json
β”‚
β”œβ”€β”€ server/                          # Express REST API + Socket.io
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/                  # App configuration
β”‚   β”‚   β”‚   β”œβ”€β”€ database.ts          #   MongoDB connection
β”‚   β”‚   β”‚   β”œβ”€β”€ env.ts               #   Environment variables
β”‚   β”‚   β”‚   β”œβ”€β”€ passport.ts          #   Google OAuth strategy
β”‚   β”‚   β”‚   β”œβ”€β”€ redis.ts             #   Redis client setup
β”‚   β”‚   β”‚   └── socket.ts            #   Socket.io + Redis adapter
β”‚   β”‚   β”œβ”€β”€ middleware/              # Express middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.ts              #   JWT authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ errorHandler.ts      #   Global error handler
β”‚   β”‚   β”‚   β”œβ”€β”€ socketAuth.ts        #   Socket.io JWT auth
β”‚   β”‚   β”‚   └── validate.ts          #   Zod schema validation
β”‚   β”‚   β”œβ”€β”€ models/                  # Mongoose schemas (14 models)
β”‚   β”‚   β”œβ”€β”€ modules/                 # Feature modules
β”‚   β”‚   β”‚   β”œβ”€β”€ adaptive/            #   AI lesson engine + LLM
β”‚   β”‚   β”‚   β”œβ”€β”€ anticheat/           #   Anti-cheat service
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/                #   Auth + OTP + OAuth
β”‚   β”‚   β”‚   β”œβ”€β”€ battle/              #   Battle engine (27KB)
β”‚   β”‚   β”‚   β”œβ”€β”€ matchmaking/         #   ELO-based matchmaking
β”‚   β”‚   β”‚   β”œβ”€β”€ presence/            #   Online status tracking
β”‚   β”‚   β”‚   β”œβ”€β”€ rating/              #   ELO rating system
β”‚   β”‚   β”‚   β”œβ”€β”€ room/                #   Private battle rooms
β”‚   β”‚   β”‚   β”œβ”€β”€ stocks/              #   Stock market simulation
β”‚   β”‚   β”‚   β”œβ”€β”€ wallet/              #   Virtual wallet
β”‚   β”‚   β”‚   └── ...                  #   + learning, leaderboard, etc.
β”‚   β”‚   β”œβ”€β”€ scripts/                 # Database seed scripts
β”‚   β”‚   └── utils/                   # Logger, email, helpers
β”‚   β”œβ”€β”€ docs/                        # API & frontend contracts
β”‚   └── package.json
β”‚
β”œβ”€β”€ CLAUDE.md                        # Project guide & conventions
β”œβ”€β”€ LICENSE                          # MIT License
└── README.md                        # ← You are here

πŸ› οΈ Getting Started

Prerequisites

  • Node.js β‰₯ 18.x
  • npm β‰₯ 9.x
  • MongoDB β€” Atlas free tier or local instance
  • Redis β€” Required for battle system, matchmaking, and Socket.io

1. Clone the Repository

git clone https://github.com/AneeshaNigam/Gamified_Financial_Learning_Platform.git
cd Gamified_Financial_Learning_Platform

2. Configure Environment Variables

Server (server/.env):

PORT=5000
NODE_ENV=development
MONGODB_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/
JWT_SECRET=<your-jwt-secret>
JWT_EXPIRES_IN=7d
CLIENT_URL=http://localhost:5173
REDIS_URL=redis://localhost:6379
BREVO_API_KEY=<your-brevo-key>
OPENAI_API_KEY=<your-openai-key>          # Optional β€” enables AI question generation
GOOGLE_CLIENT_ID=<your-google-client-id>   # Optional β€” enables Google OAuth
GOOGLE_CLIENT_SECRET=<your-google-secret>
GOOGLE_CALLBACK_URL=http://localhost:5000/api/auth/google/callback

Client (client/.env):

VITE_API_URL=http://localhost:5000/api

3. Install Dependencies & Seed Data

# Server
cd server
npm install
npm run seed:all    # Seeds modules, lessons, quizzes, achievements, testimonials, question bank

# Client
cd ../client
npm install

4. Start Redis

# Docker (recommended)
docker run -d -p 6379:6379 redis:alpine

# Or install locally via your package manager

5. Start Development Servers

# Terminal 1 β€” Backend (port 5000)
cd server && npm run dev

# Terminal 2 β€” Frontend (port 5173)
cd client && npm run dev

Open http://localhost:5173 in your browser.


πŸ“‘ API Reference

Authentication
Method Endpoint Auth Description
POST /api/auth/signup No Start signup (sends OTP)
POST /api/auth/login No Start login (sends OTP)
POST /api/auth/verify-otp No Verify OTP β†’ receive JWT
POST /api/auth/resend-otp No Resend OTP
GET /api/auth/me Yes Current user profile
PATCH /api/auth/me Yes Update profile
POST /api/auth/forgot-password No Send reset email
POST /api/auth/reset-password/:token No Reset password
GET /api/auth/google No Google OAuth initiation
Learning Engine
Method Endpoint Auth Description
GET /api/learning/current Yes Get next adaptive lesson
POST /api/learning/submit Yes Submit MCQ answer
POST /api/learning/complete Yes Complete lesson, get next
GET /api/learning/modules Yes List all modules with progress
GET /api/learning/lessons/:moduleId/:lessonId Yes Get lesson content
Battle System
Method Endpoint Auth Description
GET /api/battle/history Yes Battle history
GET /api/battle/analytics/me Yes Personal battle analytics
GET /api/battle/leaderboard No ELO leaderboard
POST /api/battle/rooms Yes Create private room
POST /api/battle/rooms/join Yes Join room by code
GET /api/battle/rating/history Yes ELO rating history
Wallet & Stocks
Method Endpoint Auth Description
* /api/wallet/* Yes Virtual wallet operations
* /api/stocks/* Yes Stock market simulation

πŸ”Œ WebSocket Events

Client β†’ Server
Event Payload Description
queue_join {mode} Join matchmaking queue
queue_leave β€” Leave queue
battle_ready {roomId} Signal ready
answer_submit {roomId, questionIndex, selectedOption, responseTimeMs} Submit answer
battle_forfeit {roomId} Forfeit battle
visibility_change {battleId, hidden} Anti-cheat tab tracking
heartbeat β€” Presence ping
Server β†’ Client
Event Payload Description
match_found {roomId, battleId, opponent} Match created
battle_start {roomId, question, questionIndex, totalQuestions} Battle begins
score_update {scores, lastAnswer} Live score update
battle_end {winner, scores, xpGained, eloChanges} Battle complete
queue_status {position, estimatedWaitSeconds} Queue position
opponent_disconnected β€” Opponent left

🚒 Deployment

Service Platform Notes
Frontend Vercel Auto-deploys from main. SPA routing via vercel.json.
Backend Render Node.js service. Build: npm run build β†’ Start: npm run start.
Database MongoDB Atlas Free M0 cluster.
Cache Redis Cloud Required for matchmaking, anti-cheat, Socket.io adapter.
Email Brevo HTTP API (Render blocks SMTP ports).

🀝 Contributing

Contributions are welcome. Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Conventions

  • Use Pino logger β€” never console.log
  • Validate all inputs with Zod schemas
  • Follow the module pattern (controller β†’ service β†’ routes β†’ schema)
  • Use asyncHandler wrapper for all async controllers
  • Throw ApiError(statusCode, message) for error responses

πŸ“„ License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Built with ❀️ for financial literacy

Live Demo Β· Report Bug Β· Request Feature

About

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages