Skip to content

aarohCodes/HackAI2026

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pondr — AI-Powered Adaptive Learning Platform

Built for the Dallas AI Hackathon 2026 (Tracks: Dallas AI + Data Science / ML)

Pondr is an intelligent learning platform that uses a knowledge graph canvas, ML-based knowledge decay prediction, and Google Gemini AI to personalize how you learn — and when you review — so nothing you study ever truly fades.


Table of Contents


Overview

Pondr models your brain as a live knowledge graph. Each concept you're learning is a node. The ML engine continuously predicts when your retention of each concept will drop below a threshold — and recommends targeted micro-reviews before knowledge decays.

Core capabilities:

  • Knowledge graph canvas (React Flow) — drag, explore, and visualize your learning as an interconnected web
  • Decay prediction (XGBoost + Ebbinghaus forgetting curves) — personalized retention scoring per concept
  • Gemini AI tutor — Feynman challenges, Socratic debates, quick snapshots, and adaptive quizzes
  • YouTube snippet pipeline — finds the exact 2–3 minute video clip most relevant to your current gap
  • Voice input — ElevenLabs STT for hands-free learning entry

Architecture

┌─────────────────────────────────────────────────────┐
│                    Frontend                          │
│  React 18 + Vite │ React Flow │ Zustand │ Tailwind  │
│  Port: 5173 — /api proxied to :8000                  │
└────────────────────────┬────────────────────────────┘
                         │ HTTP / Axios
┌────────────────────────▼────────────────────────────┐
│                    Backend                           │
│  FastAPI (Python) │ Uvicorn ASGI │ Port: 8000        │
│  JWT Auth │ Beanie ODM │ Motor (async)               │
└──────┬────────┬────────┬────────┬────────┬──────────┘
       │        │        │        │        │
   MongoDB   Gemini   YouTube  Tavily  ElevenLabs
             2.5-flash  v3 API  Search    TTS/STT
                         │
                   XGBoost Model
                  (decay_model.joblib)

Data Flow:

  1. User registers/logs in → JWT token issued (7-day expiry)
  2. Onboarding: goal + background → Gemini generates initial knowledge graph (nodes + edges)
  3. User interacts with nodes → learning events logged → XP awarded
  4. Decay engine scores each node via XGBoost → updates node state (green/yellow/fading/red)
  5. Gemini recommendations surface targeted YouTube clips and practice scenarios
  6. Study schedule generated by Gemini → synced to Google Calendar

Tech Stack

Frontend

Technology Version Role
React 18.3.0 UI framework
Vite 5.2.10 Build tool & dev server
React Flow 11.11.3 Interactive knowledge graph canvas
Zustand 4.5.2 Global state management
React Router DOM 6.23.0 Client-side routing
Framer Motion 11.1.7 Animations & transitions
Axios 1.6.8 HTTP client with interceptors
Recharts 2.12.4 ML metrics visualizations
Tailwind CSS 3.4.3 Utility-first styling
Lucide React 0.378.0 Icon library

Backend

Technology Version Role
FastAPI 0.115.0+ Async Python web framework
Uvicorn 0.32.0+ ASGI server
MongoDB + Motor 3.6.0+ Async NoSQL database
Beanie ODM 1.27.0+ MongoDB object-document mapper
python-jose 3.3.0+ JWT encoding/decoding
bcrypt 4.2.0+ Password hashing
XGBoost 2.1.0+ Knowledge decay prediction
scikit-learn 1.6.0+ ML utilities & preprocessing
NetworkX 3.4+ Graph analysis & dependency depth
google-genai 1.0.0+ Gemini 2.5-flash API
LangChain + LangGraph 0.3.0+ Agent framework (experimental)
google-api-python-client 2.160.0+ YouTube Data API v3
youtube-transcript-api 0.6.3+ Video transcript extraction
tavily-python 0.5.0+ Web search
firecrawl-py 1.5.0+ Web scraping
httpx 0.27.0+ Async HTTP (ElevenLabs)

Features

Knowledge Graph Canvas

The main learning interface is a React Flow canvas where each concept is a node with a color-coded state:

Color State Meaning
Green green Mastered (retention ≥ 85%)
Yellow yellow In progress (retention ≥ 70%)
Orange fading Decay alert — review in next 3 days
Red red Needs review (retention < 60%)
  • Drag nodes to reorganize your personal knowledge map — positions persist across sessions
  • Click a node to open the learning panel (video, Feynman, Socratic, quick snapshot)
  • Search to add new concepts; Gemini auto-integrates them into your existing graph
  • Timeline scrubber lets you replay your learning history

Learning Modes

Feynman Challenge — Explain a concept in plain terms; Gemini evaluates your explanation and identifies gaps, returning targeted feedback.

Socratic Debate — Gemini takes a position, you defend yours. Multi-turn debate with progressive pushback. Full conversation history passed each turn.

Quick Snapshot — 30-second Gemini summary of a concept tailored to your current knowledge level.

YouTube Snippet — Pipeline searches YouTube, extracts transcripts for top 3 results, uses Gemini to identify the most relevant 2–3 minute timestamp window for your specific gap.

Adaptive Quiz — Gemini generates a personalized quiz based on your mastery score and recent learning events.

Voice Input

ElevenLabs STT powers voice input on:

  • Onboarding (describe your prior knowledge hands-free)
  • Canvas search (speak a concept to add it)

Google Calendar Integration

  • Full OAuth 2.0 flow — read/write access to Google Calendar
  • AI-generated weekly study schedules created by Gemini (based on your hubs, availability, and decay alerts)
  • Sessions auto-created as Google Calendar events with concept context

Web Search & Scraping

  • Tavily — real-time web search for concept enrichment
  • Firecrawl — intelligent web scraping for resource extraction

ML Model

What It Predicts

The XGBoost model predicts retention R(t) for each user-concept pair — the probability you still remember a concept at time t. Range: 0.0 (forgotten) → 1.0 (perfect recall).

It personalizes the Ebbinghaus stability parameter S based on 10 behavioral features.

Features (in order of importance)

Rank Feature Importance Description
1 days_since_review 66.4% Days elapsed since last review
2 spacing_score 11.9% How well-spaced reviews are (0–1)
3 complexity_tier 5.5% 1=basic, 2=intermediate, 3=advanced
4 review_count 4.8% Total number of reviews
5 feynman_score 3.9% Ratio of successful Feynman challenges
6 practice_fail_rate 3.2% Ratio of failed practice attempts
7 time_spent_avg 1.4% Average minutes per session
8 revisit_rate 1.7% Ratio of rewatch events
9 dependency_depth 1.1% Hops from root concept
10 confidence_gap 0.2% avg |confidence_after − confidence_before|

Model Performance

Metric Value
RMSE 0.0524
MAE 0.0410
Baseline RMSE 0.1588
Personalization Lift 67.03%
Precision @ 0.7 threshold 97.2%
Recall @ 0.7 threshold 96.7%

Training Data

1,000 synthetic learner records generated with realistic behavioral distributions (backend/ml/generate_dataset.py). Model trained with backend/ml/train_model.py and serialized to backend/ml/decay_model.joblib.

Edge Cases

  • days_since_review = 0 → return retention 1.0 (skip model)
  • last_reviewed is null → set days_since_review = 99, return retention 0.0
  • review_count = 0 → skip model, return state red
  • All predictions clipped to [0.0, 1.0]
  • Model file missing → log warning, return 0.5 default

API Reference

All endpoints (except Auth and Health) require Authorization: Bearer <token>.

Auth — /api/auth (Public)

Method Endpoint Description
POST /api/auth/register Email/password registration → JWT + user
POST /api/auth/login Email/password login → JWT + user
POST /api/auth/google Google OAuth code exchange → JWT + user
POST /api/auth/guest Anonymous guest session → JWT + user
GET /api/auth/me Rehydrate user from token

Users — /api/users

Method Endpoint Description
POST /api/users/onboard Set goal/background, generate knowledge graph
GET /api/users/me Current user profile + gamification stats

Graph — /api/graph

Method Endpoint Description
GET /api/graph/canvas All nodes + edges for canvas rendering
POST /api/graph/event Log a behavioral learning signal
PATCH /api/graph/node/{id}/position Persist node drag position
GET /api/graph/history Historical snapshots for timeline scrubber

Gemini — /api/gemini

Method Endpoint Description
POST /api/gemini/recommend Context-aware learning recommendation
POST /api/gemini/feynman Evaluate Feynman explanation
POST /api/gemini/socratic Start Socratic challenge
POST /api/gemini/socratic/reply Continue Socratic thread
POST /api/gemini/quick-snapshot Quick concept summary

YouTube — /api/youtube

Method Endpoint Description
POST /api/youtube/snippet Search + transcript + timestamp extraction

Assessment — /api/assess

Method Endpoint Description
POST /api/assess/quiz Generate adaptive quiz for a concept
POST /api/assess/grade Grade an open-ended quiz answer

Search — /api/search

Method Endpoint Description
POST /api/search/web Tavily web search
POST /api/search/scrape Firecrawl URL scraping

Calendar — /api/calendar

Method Endpoint Description
GET /api/calendar/events Fetch Google Calendar events
POST /api/calendar/schedule Generate + save AI study schedule
POST /api/calendar/event Create a single calendar event

Speech — /api/speech

Method Endpoint Description
POST /api/speech/stt ElevenLabs speech-to-text
POST /api/speech/tts ElevenLabs text-to-speech

Database Models

All models use MongoDB + Beanie ODM (async Pydantic documents).

User

Core user record with auth, profile, and gamification fields. has_onboarded gates the onboarding flow. Google OAuth tokens stored for Calendar access.

Hub

A learning topic (e.g., "Machine Learning", "React Development"). Each hub has its own node subgraph.

ConceptNode

A single concept in the knowledge graph. Tracks Ebbinghaus parameters (stability_s, retention_rt), canvas position, mastery score, and decay state.

LearningEvent

Every user interaction logged as an event: view, rewatch, practice, feynman, snapshot, quiz. XP earned per event stored here.

Recommendation

Gemini-generated recommendation for a node, including YouTube video ID and exact timestamp window.

KnowledgeEdge

Directed edge between two ConceptNodes with type: prerequisite or related.

StudyPlan

AI-generated weekly study schedule. Contains embedded StudySession objects with optional Google Calendar event IDs.

Achievement

Defines unlock conditions and XP rewards for the achievement system.


Setup & Installation

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • MongoDB (local or Atlas)
  • API keys: Gemini, YouTube, ElevenLabs, Tavily, Firecrawl
  • (Optional) Google Cloud project with OAuth 2.0 credentials for Calendar

1. Clone & configure

git clone <repo-url>
cd HackAI2026
cp example.env .env
# Edit .env with your API keys

2. Backend setup

cd backend
python -m venv venv
source venv/bin/activate       # Windows: venv\Scripts\activate
pip install -r requirements.txt

3. Train the ML model

# From backend/
python ml/generate_dataset.py  # Generates synthetic dataset (1000 records)
python ml/train_model.py       # Trains XGBoost, saves decay_model.joblib + metrics.json

4. Seed demo data

python database/seed.py
# Demo user: alex@pondr.dev / demo1234

5. Frontend setup

cd ../frontend
npm install

Environment Variables

Copy example.env to .env at the project root:

# Database
MONGO_DB_URI=mongodb://localhost:27017
MONGO_DB_NAME=pondr

# AI APIs
GEMINI_API_KEY=your_gemini_api_key
YOUTUBE_API_KEY=your_youtube_data_api_key
ELEVENLABS_API_KEY=your_elevenlabs_api_key
TAVILY_API_KEY=your_tavily_api_key
FIRECRAWL_API_KEY=your_firecrawl_api_key

# Google OAuth (for Calendar + Sign-In)
GOOGLE_CLIENT_ID=your_google_oauth_client_id
GOOGLE_CLIENT_SECRET=your_google_oauth_client_secret
GOOGLE_REDIRECT_URI=http://localhost:5173

# App Security
SECRET_KEY=change_this_to_a_random_32_char_string

# CORS
CORS_ORIGINS=http://localhost:5173

# ngrok (optional — for exposing local backend publicly)
# NGROK_URL=https://xxxx.ngrok-free.app

# ML Thresholds
DECAY_THRESHOLD=0.70
DECAY_ALERT_WINDOW_DAYS=3

Running the App

# Terminal 1: Backend
cd backend
uvicorn main:app --reload --port 8000

# Terminal 2: Frontend
cd frontend
npm run dev

App: http://localhost:5173 API docs (Swagger): http://localhost:8000/docs

Exposing with ngrok (optional)

If you need to share the backend publicly (e.g., for Google OAuth callbacks or mobile testing), use ngrok:

ngrok http 8000
# Outputs something like: https://abcd1234.ngrok-free.app

Then update your .env:

NGROK_URL=https://abcd1234.ngrok-free.app
CORS_ORIGINS=http://localhost:5173,https://abcd1234.ngrok-free.app
GOOGLE_REDIRECT_URI=https://abcd1234.ngrok-free.app

The backend automatically adds the NGROK_URL to CORS allowed origins and also allows any *.ngrok-free.app subdomain via regex — no backend restart required after setting the env var.


Project Structure

HackAI2026/
├── .env                          # API keys (never commit)
├── example.env                   # Environment template
├── CLAUDE.md                     # Development guide
├── README.md                     # This file
├── backend/
│   ├── main.py                   # FastAPI entry point + router registration
│   ├── requirements.txt
│   ├── database/
│   │   ├── models.py             # All Beanie document models
│   │   ├── connection.py         # Motor client + Beanie initialization
│   │   └── seed.py               # Demo data seeder
│   ├── ml/
│   │   ├── generate_dataset.py   # Synthetic learner data generation
│   │   ├── train_model.py        # XGBoost training + metrics
│   │   ├── predict.py            # Inference + retention scoring
│   │   ├── evaluate.py           # RMSE, MAE, lift computation
│   │   ├── decay_model.joblib    # Serialized trained model
│   │   ├── dataset.csv           # Training data
│   │   └── metrics.json          # Model performance metrics
│   ├── api/
│   │   ├── deps.py               # JWT get_current_user dependency
│   │   ├── auth.py               # Auth endpoints (register/login/google/guest)
│   │   ├── users.py              # Onboarding, user profile
│   │   ├── graph.py              # Canvas state, events, positions, history
│   │   ├── gemini.py             # AI recommendations, Feynman, Socratic
│   │   ├── youtube.py            # Video snippet pipeline
│   │   ├── assess.py             # Quiz generation & grading
│   │   ├── search.py             # Web search + scraping
│   │   ├── calendar.py           # Google Calendar integration
│   │   └── speech.py             # ElevenLabs STT/TTS
│   └── services/
│       ├── auth_service.py       # JWT, bcrypt, authentication logic
│       ├── gemini_service.py     # All Gemini prompts + retry logic
│       ├── youtube_service.py    # YouTube search + transcript pipeline
│       ├── graph_service.py      # NetworkX graph operations
│       ├── google_oauth_service.py # OAuth code exchange + token refresh
│       ├── calendar_service.py   # Google Calendar CRUD
│       ├── search_service.py     # Tavily web search
│       ├── firecrawl_service.py  # Web scraping
│       └── gamification_service.py # XP, levels, streaks, achievements
└── frontend/
    ├── package.json
    ├── vite.config.js            # Vite + /api proxy to :8000
    ├── tailwind.config.js        # Custom dark theme colors
    └── src/
        ├── App.jsx               # Router + RequireAuth HOC
        ├── api/client.js         # Axios instance + 401 auto-guest interceptor
        ├── store/useStore.js     # Zustand: auth, hubs, graph, gamification
        ├── pages/
        │   ├── Landing.jsx       # Public homepage
        │   ├── Login.jsx         # Auth UI (email + Google OAuth)
        │   ├── Onboarding.jsx    # Goal/background + voice input
        │   ├── Canvas.jsx        # Main React Flow canvas
        │   ├── ConceptPage.jsx   # Single concept learning
        │   ├── QuizPage.jsx      # Adaptive quiz UI
        │   ├── Dashboard.jsx     # Hub overview + gamification
        │   ├── Hubs.jsx          # Browse learning topics
        │   └── Planner.jsx       # Google Calendar week view
        └── components/
            ├── canvas/           # ConceptNode, RecommendationCard, TimelineScrubber
            ├── learning/         # FeynmanChallenge, SocraticDebate, QuickSnapshot, VideoSnippet
            ├── gamification/     # XPBar, StreakCounter, LevelBadge, AchievementToast
            ├── auth/             # GoogleSignIn button
            ├── calendar/         # WeekView
            └── ui/               # Sidebar, MetricsPanel

Gamification System

XP Awards

Action XP
Watch video snippet +40
Complete Quick Quiz +80
Feynman Challenge +120
Socratic Debate (per round) +150
Complete full Socratic (3+ rounds) +450
Daily login +25
Streak bonus +10 × streak_days

Level Progression

Level Title XP Required
1–5 Novice 0 – 1,000
6–10 Explorer 1,001 – 3,000
11–20 Pathfinder 3,001 – 8,000
21–30 Scholar 8,001 – 18,000
31–40 Master 18,001 – 35,000
41–50 Sage 35,001+

Achievements

Achievement Condition Rarity
First Steps Complete first learning event Common
Feynman Apprentice 5 Feynman challenges Common
Debate Champion Win 10 Socratic debates Rare
Streak Fire 7-day streak Rare
Decay Slayer Recover 5 fading concepts Epic
Graph Explorer Unlock 20 nodes Epic
Speed Demon 3 Quick Snapshots in < 90s Rare
Knowledge Keeper 90%+ retention for 7 days Legendary

Auth Flow

Register/Login → JWT (7-day, HS256) → localStorage (pondr_token)
     ↓
All API calls: Authorization: Bearer <token>
     ↓
Backend: get_current_user() → decode JWT → fetch User from MongoDB
     ↓
401 response → Axios interceptor → auto guest login → retry

Google OAuth: Exchanges auth code for Google tokens, links by google_id or email, stores refresh token for Calendar access, returns Pondr JWT.

Demo credentials: alex@pondr.dev / demo1234


Built with Google Gemini 2.5 Flash, XGBoost, React Flow, and FastAPI.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages