How dub55/learning-platform works
Project type and purpose
• This is a full-stack learning platform (“Learning Platform”) with:
• A backend API (Node.js/TypeScript) under apps/api
• A frontend web app (Next.js + React + Supabase) under apps/web
• A PostgreSQL database hosted on Supabase
• AI-powered endpoints wrapping a Python “coder.py” service
• Google OAuth for authentication
File structure
• Top-level apps/ folder contains two sub-apps:
• apps/api/: REST API with routes (src/routes/*.ts), services (src/services/*.ts), and environment config.
• apps/web/: Next.js frontend with pages (src/pages), lib (supabaseClient.ts), styles, and utils.
• scripts/migrate.sql defines the database schema (leersets, SRS tables).
• docs/ contains Google OAuth setup instructions and an OpenAPI spec.
• Monorepo TS config at the root with per-app tsconfig.json files.
Key architecture insights from README
• Backend exposes endpoints for:
• Importing learning sets (POST /api/leersets/import-text)
• SM-2 spaced repetition review (GET /api/srs/due, POST /api/srs/review)
• AI wrappers (POST /api/ai/summarize, /generate/flashcards)
• Supabase handles Auth (email + Google) and stores data.
• The AI service (“coder.py”) is an external streaming endpoint.
• Deployment uses Vercel/GitHub with environment secrets.
Main components
A. Frontend (Next.js app)
• Pages: Import UI, Study UI
• Supabase Client (lib/ and utils/)
• Auth flows (Supabase Auth + Google OAuth)
B. Backend API (Express/Koa-style or Fastify)
• API Gateway / HTTP server
• Route handlers (leersets, srs, ai)
• Services layer (business logic: SRS calculations, DB calls)
• AI Proxy service
C. Database
• Supabase/PostgreSQL
• Tables: leersets, cards, reviews, users, subjects, chapters
D. External services
• Supabase Auth provider (Google OAuth)
• AI model endpoint (coder.py)
E. Deployment & CI
• GitHub (repo, CI triggers)
• Vercel (hosting frontend + serverless functions for API)
Relationships & interactions
1. User opens Web App → Supabase Auth (sign-in with email/Google)
2. Web App requests data or mutations via REST calls to API
3. API authenticates calls via Supabase service-role key
4. API routes call Services → read/write to Supabase DB
5. For AI endpoints, API forwards requests to coder.py endpoint → streams back response
6. Database triggers or scheduled jobs (future enhancement) for SM-2 queue processing
Architectural patterns & principles
• Layered architecture: Presentation (frontend) → API layer → Services → Data layer
• Separation of concerns:
• Next.js handles UI/SSR
• API handles business logic and secures Supabase service-role key
• Monorepo structure with isolated per-app dependencies
• Stateless RESTful services + serverless deployment model
• Externalize identity & data storage to Supabase