Skip to content
Arnold Perez
Back to projects
Beta

AI Learning Platform

A monorepo learning engine: FastAPI + Postgres + Redis (ARQ) power a shared REST API for learning items, reusable concepts, knowledge-graph relationships, EMA + SM-2 mastery, goals, and generated study sessions. OpenAI work (process content, summarize, quiz, grade, map goals) runs as async jobs with versioned prompts and strict JSON schemas—never on the request path. Next.js owns Study Today, the library, and longer workflows; Expo handles capture and review on device; an unpacked Chrome/Firefox MV3 extension saves already-rendered page text through the signed-in web app. Auth is Clerk: both clients send Bearer JWTs; this API is the JWKS resource server and auto-provisions users. Local runtime is Docker Compose (API + worker + Postgres + Redis). A public demo is still coming.

AI Learning Platform Study Today, concept graph, and browser capture

Tech stack

  • TypeScript
  • Python
  • FastAPI
  • Next.js
  • React Native
  • Expo
  • PostgreSQL
  • Redis
  • OpenAI API
  • Clerk
  • Docker

Architecture

  1. Learning API + ARQ worker

    FastAPI owns CRUD, concepts, quizzes, goals, and Study Today over Postgres. A separate ARQ worker pulls process_content / summarize / generate_quiz / grade_quiz / goal_map off Redis so OpenAI latency never blocks the request path.

    • Thin routes → services → SQLAlchemy async; Alembic migrations
    • Versioned prompts (content_process:v1, quiz_generate:v3, …) + strict JSON-schema outputs
    • Concept EMA mastery + SM-2 scheduling; GET /api/reviews/due and deterministic Study Today ranking
    • URL/PDF/YouTube/Markdown importers feed the same process_content pipeline
    • Per-job LLM token logging, structlog request IDs, Prometheus /metrics, /health/ready probes
  2. Web, mobile, and browser capture

    Three clients share one REST contract and TanStack Query features. UX and capture surface differ; the API does not.

    • Next.js App Router: Study Today as home, library, concept graph, goals, TanStack Table workflows
    • Expo Router: capture notes/URLs and run review sessions on device
    • MV3 extension + bookmarklet: save rendered page text (Cloudflare/SPA-safe) via the signed-in web app—extension never calls FastAPI
    • Shared design tokens (Tailwind v4 / NativeWind); clients poll /api/jobs/{id} until LLM jobs complete
  3. Clerk + Compose runtime

    Login lives in Clerk; this repo validates JWTs via JWKS and runs API + worker against Compose Postgres/Redis.

    • Web (@clerk/nextjs) and mobile (@clerk/expo) attach Bearer JWTs; backend auto-provisions users from Clerk sub
    • Learning domains partition library, concepts, graph, mastery, and Study Today per subject
    • Local ports: API 8000, web 3000, Postgres 5432, Redis 6379
    • GitHub Actions CI: pytest/ruff, Vitest/Playwright/Biome, Jest/Biome

Engineering highlights

  • LLM work is a job, not a request

    Process, summarize, quiz generation, grading, and goal mapping enqueue to Redis/ARQ and return 202. Clients poll typed job results so the API stays responsive under OpenAI latency, and token usage is logged per user and job.

  • Concepts, not bookmarks

    process_content extracts takeaways, tags, and reusable concepts (slug + trigram dedup, unique per learning domain), then suggests graph relationships. Quizzes attach to concepts; mastery is EMA per idea, not a single article score.

  • Study Today is deterministic

    SM-2 owns next_review_at; ranking for the 5/15/30-minute session is application logic (due + weak + goals + blocked prerequisites)—the model never picks what you should study next.

  • Capture without leaving the page

    A bookmarklet prefills extract-url; the MV3 extension reads already-rendered DOM text and hands it to the web app so Cloudflare and JS-only articles still save. PDF, YouTube transcripts, and Markdown share the same importer contract.