Spaces:
Configuration error
Configuration error
|
Download README.md from rockysreenivasa/MathTutor: direct link, hf CLI and curl.
- Browser
- Download file 6.04 kB
-
https://huggingface.co/spaces/rockysreenivasa/MathTutor/resolve/main/README.md
- Command line
-
hf download hf://spaces/rockysreenivasa/MathTutor/README.md
-
curl -L -o README.md https://huggingface.co/spaces/rockysreenivasa/MathTutor/resolve/main/README.md
6.04 kB
| # ๐งฎ MathMind AI โ MVP | |
| AI-powered adaptive math tutor for **Grades 6โ12**. | |
| Built with **Streamlit ยท FastAPI ยท Anthropic Claude ยท Supabase**. | |
| --- | |
| ## Architecture | |
| ``` | |
| Streamlit (localhost:8501) | |
| โโโ httpx calls โ FastAPI (localhost:8000) | |
| โโโ Anthropic Claude API (AI explanations + tests) | |
| โโโ Supabase (Auth + PostgreSQL) | |
| ``` | |
| --- | |
| ## Quick Start | |
| ### 1. Clone & Install | |
| ```bash | |
| git clone <repo-url> | |
| cd mathmind | |
| pip install -r requirements.txt | |
| ``` | |
| ### 2. Configure Environment | |
| ```bash | |
| cp .env.example .env | |
| # Fill in the values in .env (see Environment Variables section below) | |
| ``` | |
| ### 3. Set Up Supabase | |
| 1. Create a free project at [supabase.com](https://supabase.com) | |
| 2. Go to **SQL Editor** and run the scripts **in order**: | |
| - `database/01_schema.sql` | |
| - `database/02_rls.sql` | |
| - `database/03_seed.sql` | |
| 3. Copy your project URL and keys from **Settings โ API** | |
| ### 4. Run the Backend | |
| ```bash | |
| # From the mathmind/ root directory | |
| uvicorn backend.main:app --reload --port 8000 | |
| ``` | |
| Verify: open [http://localhost:8000/api/health](http://localhost:8000/api/health) | |
| You should see: `{"status": "ok"}` | |
| ### 5. Run the Frontend | |
| ```bash | |
| # In a second terminal, from the mathmind/ root directory | |
| streamlit run streamlit_app/app.py | |
| ``` | |
| Open [http://localhost:8501](http://localhost:8501) in your browser. | |
| --- | |
| ## Environment Variables | |
| Create a `.env` file in the `mathmind/` root: | |
| ```bash | |
| # Anthropic โ get your key at console.anthropic.com | |
| ANTHROPIC_API_KEY=sk-ant-... | |
| # Supabase โ from your project: Settings โ API | |
| SUPABASE_URL=https://xxxx.supabase.co | |
| SUPABASE_ANON_KEY=eyJ... # "anon" key (public) | |
| SUPABASE_SERVICE_ROLE_KEY=eyJ... # "service_role" key (secret โ never expose to browser) | |
| # FastAPI | |
| ALLOWED_ORIGINS=http://localhost:8501 | |
| API_BASE_URL=http://localhost:8000 | |
| ``` | |
| --- | |
| ## Project Structure | |
| ``` | |
| mathmind/ | |
| โโโ .env.example | |
| โโโ README.md | |
| โโโ requirements.txt | |
| โ | |
| โโโ streamlit_app/ # Frontend (Streamlit) | |
| โ โโโ app.py # Landing page + router | |
| โ โโโ pages/ | |
| โ โ โโโ 1_Login.py # Auth (login + signup) | |
| โ โ โโโ 2_Tutor.py # Core learning flow | |
| โ โ โโโ 3_Dashboard.py # Badges + streak + history | |
| โ โโโ utils/ | |
| โ โโโ auth.py # Supabase auth helpers | |
| โ โโโ api_client.py # FastAPI HTTP client | |
| โ โโโ state.py # session_state helpers | |
| โ | |
| โโโ backend/ # API (FastAPI) | |
| โ โโโ main.py # App entry + CORS | |
| โ โโโ core/ | |
| โ โ โโโ config.py # Env var loading | |
| โ โ โโโ auth.py # JWT verification | |
| โ โโโ routers/ | |
| โ โ โโโ explain.py # POST /api/explain | |
| โ โ โโโ practice.py # POST /api/practice | |
| โ โ โโโ test.py # POST /api/test/* | |
| โ โ โโโ badges.py # GET/POST /api/badges | |
| โ โโโ services/ | |
| โ โ โโโ claude_service.py # Anthropic SDK wrapper | |
| โ โ โโโ supabase_service.py # Supabase client wrapper | |
| โ โ โโโ prompt_templates.py # Grade-level prompts | |
| โ โโโ models/ # Pydantic request/response models | |
| โ | |
| โโโ database/ | |
| โโโ 01_schema.sql # Table definitions | |
| โโโ 02_rls.sql # Row Level Security | |
| โโโ 03_seed.sql # Badge definitions | |
| โโโ README.md | |
| ``` | |
| --- | |
| ## API Endpoints | |
| | Method | Endpoint | Description | Auth | | |
| |--------|----------|-------------|------| | |
| | GET | `/api/health` | Health check | None | | |
| | POST | `/api/explain` | Stream grade-appropriate explanation | JWT | | |
| | POST | `/api/practice` | Generate 3 practice problems | JWT | | |
| | POST | `/api/test/generate` | Generate 5-question mini-test | JWT | | |
| | POST | `/api/test/evaluate` | Evaluate answers + save result | JWT | | |
| | GET | `/api/badges` | Get student's earned badges | JWT | | |
| | POST | `/api/badges/check` | Check + award new badges | JWT | | |
| Interactive docs: [http://localhost:8000/docs](http://localhost:8000/docs) | |
| --- | |
| ## Student Flow | |
| ``` | |
| Sign Up โ Select Grade โ Ask Question | |
| โ Streamed Explanation | |
| โ Practice Problems (3x) | |
| โ Mini-Test (5 questions) | |
| โโโ PASS (โฅ80%) โ Badge Awarded โ Dashboard | |
| โโโ FAIL (<80%) โ See Feedback โ Retry Test | |
| ``` | |
| --- | |
| ## Badge System | |
| | Badge | Emoji | Condition | | |
| |-------|-------|-----------| | |
| | First Try Champion | ๐ | Pass your first test | | |
| | Getting Started | ๐ | Complete 5 sessions | | |
| | Math Explorer | ๐ | Complete 10 sessions | | |
| | On Fire | ๐ฅ | 5-day streak | | |
| | Perfect Score | ๐ฏ | Score 100% on a test | | |
| --- | |
| ## Tech Stack | |
| | Layer | Technology | | |
| |-------|-----------| | |
| | Frontend | Streamlit 1.35+ | | |
| | Backend | FastAPI + Uvicorn | | |
| | AI | Anthropic Claude `claude-sonnet-4-6` | | |
| | Database | Supabase (PostgreSQL + Auth + RLS) | | |
| | HTTP Client | httpx (async-capable) | | |
| | Validation | Pydantic v2 | | |
| --- | |
| ## Development Notes | |
| - **Backend auto-reloads** on file changes with `--reload` | |
| - **Streamlit auto-reloads** on file saves | |
| - **JWT flow:** Supabase issues JWT on login โ stored in `st.session_state` โ sent as `Authorization: Bearer <token>` to FastAPI โ FastAPI verifies via Supabase auth API | |
| - **Streaming:** `/api/explain` uses FastAPI `StreamingResponse` + Anthropic streaming SDK โ Streamlit renders chunks live | |
| - **Service role key** is used by FastAPI only โ bypasses RLS for server-side writes. Never expose to the browser. | |
| --- | |
| ## Phase 2 Roadmap (not in MVP) | |
| - [ ] Re-engagement email nudges (SendGrid) | |
| - [ ] LMS integration (Google Classroom, Canvas) | |
| - [ ] Parent weekly report emails | |
| - [ ] Adaptive ML difficulty engine | |
| - [ ] Subscription/payment (Stripe) | |
| - [ ] Mobile app | |