MedCore Zambia is an interactive web-based learning platform designed for Zambian medical students. It features course materials, video lessons, quiz assessments, and structured content with rich learning tools. The app includes admin management capabilities and tracks student progress with XP-based engagement metrics.
# MedCore Zambia — Supabase Edition
Medical learning platform for UNZA, CBU & Levy Mwanawasa Medical University students.
Built with **Supabase** (auth + database) and deployed on **Vercel**.
---
## Architecture Overview
```
medcore-supabase/
├── public/
│ ├── index.html ← Landing page
│ ├── medcore-v3.html ← Main app (auth, dashboard, quiz, AI tutor, admin)
│ └── supabase-client.js ← Supabase wrapper (auth, progress, content, admin)
├── api/
│ ├── ai.js ← Vercel serverless: Claude AI proxy (key never reaches browser)
│ └── admin.js ← Vercel serverless: admin CRUD (service role only)
├── supabase/
│ ├── config.toml ← Supabase CLI config (local dev)
│ └── migrations/
│ ├── 001_initial_schema.sql ← Users, profiles, progress, RLS, triggers
│ └── 002_content_tables.sql ← Subjects, lessons, quiz questions, flashcards + seed data
├── scripts/
│ ├── inject-env.js ← Build script: injects env vars into HTML at Vercel build time
│ └── dev-server.js ← Local dev server (no Vercel CLI needed)
├── .env.example ← Template — copy to .env.local and fill in values
├── .env.local ← Your local secrets (git-ignored)
├── vercel.json ← Vercel routing + security headers
└── package.json
```
### Data flow
```
Browser ──→ Supabase Auth (Google OAuth) ← session management
──→ Supabase DB (RLS-protected) ← user progress, content, profiles
──→ /api/ai (Vercel fn) ← Claude proxy (ANTHROPIC_API_KEY server-side)
──→ /api/admin (Vercel fn) ← admin ops (SERVICE_ROLE_KEY server-side)
```
**Secrets that NEVER reach the browser:**
- `ANTHROPIC_API_KEY` — only in `api/ai.js`
- `SUPABASE_SERVICE_ROLE_KEY` — only in `api/admin.js` and `api/ai.js`
**Safe to expose (anon key — RLS enforces all access control):**
- `NEXT_PUBLIC_SUPABASE_URL`
- `NEXT_PUBLIC_SUPABASE_ANON_KEY`
---
## Quick Start
### …