How anulsasidharan/dsa_studio works
1. Repo shape
- This is a monorepo with three main code areas: apps/web for the UI, apps/api for the backend, and packages/shared for common types/contracts.
- infra/docker contains the runtime topology for local and containerized deployment.
2. Frontend boundary
- The web app is a React + Vite + Tailwind + shadcn/ui client.
- It is organized by user workflow pages such as dashboard, import, learning, practice, revision, topic detail, track, and assistant.
- Zustand stores (authStore, appStore) hold client state; a thin api-client module is the primary boundary to the backend.
3. Backend boundary
- The API is an Express + TypeScript service.
- Routes are split by domain: auth, chat, import, progress, questions, revision, submit, topics, health, and docs.
- Middleware centralizes auth, validation, rate limiting, not-found handling, and error handling.
4. Core domain services
- Business logic is separated from routing in apps/api/src/services.
- Key services include grading, progress tracking, revision generation, import processing, analytics, daily activity, and chat orchestration.
- This is where cross-cutting learning logic lives, rather than in the route handlers.
5. Data persistence
- PostgreSQL is the primary system of record.
- Prisma is the database layer, with migrations and a seed script for initial question-bank data.
- The schema appears to support users, topics, questions, submissions, progress, and chat-related tables.
6. Shared contracts
- packages/shared defines reusable domain types, enums, entity shapes, API types, and code templates.
- This package is a compile-time contract between web and API, reducing drift in request/response structures and shared learning-domain models.
7. AI/chat subsystem
- The assistant feature is backed by an LLM abstraction layer with provider implementations for OpenAI, Anthropic, and a mock provider.
- Chat-specific services include context building, import classification, learning-path generation, and the main chat service.
- The chat flow likely combines user history, topic theory, and progress data to produce educational responses and recommendations.
8. Sandboxed execution
- The API includes a sandbox subsystem with an executor, and Docker images for Node and Python sandbox runtimes.
- This strongly suggests isolated code execution for programming exercises or answer checking, keeping untrusted execution out of the main API process.
9. Learning workflow
- The main data flow is: imported or seeded content becomes topics/questions, users practice or submit answers, the API grades and records results, and progress/revision views are updated from that state.
- The import route/service is the ingestion entrypoint; submit/grading/progress/revision form the feedback loop that drives the learning experience.
10. Authentication and user state
- Auth is JWT-based with password utilities, and the API exposes an auth route plus auth middleware.
- The web app has an auth dialog and auth store, so login state is managed client-side but enforced server-side.
11. Runtime and infrastructure
- Docker Compose is the default full-stack deployment model: PostgreSQL, Redis, API, and web.
- The web container serves the UI and proxies /api to the backend through Nginx.
- On first startup, the API runs Prisma migrations and seeds data automatically.
12. Operational services
- Redis is present as a separate infrastructure dependency and is wired into the API; the visible middleware usage indicates it supports rate limiting and other transient server-side concerns.
- The API also exposes health and OpenAPI docs endpoints for readiness and integration visibility.
Main entry points: services Services · src/index.ts API app · App.tsx Web app · src/index.ts Shared contracts
Components 18
Apps
Runtime applications for UI and API
- Web app · Vite-based learning UI with workflow pages and client state
apps/web/src/App.tsx - API app · TypeScript backend exposing domain routes and middleware
apps/api/src/index.ts - Pages · Dashboard, import, learning, practice, revision, topic detail, track, and assistant screens
apps/web/src/pages - Client state · Auth and app state used across the UI
apps/web/src/store - API client · Thin client wrapper for backend requests
apps/web/src/lib/api-client.ts - Routes · Auth, chat, import, progress, questions, revision, submit, topics, health, and docs endpoints
apps/api/src/routes - Middleware · Auth, validation, rate limiting, not-found handling, and errors
apps/api/src/middleware - Services · Core learning logic separated from route handlers
apps/api/src/services - Chat services · Context building, import classification, learning-path generation, and chat coordination
apps/api/src/services/chat - Grading · Evaluates submissions and supports answer checking
apps/api/src/services/grading.ts - Progress · Persists and reads user learning progress
apps/api/src/services/progress.ts - Revision · Generates revision content and schedules
apps/api/src/services/revision.ts - Import · Processes imported content into topics and questions
apps/api/src/services/import.ts - Sandbox · Executor for untrusted code and exercise evaluation
apps/api/src/sandbox - Prisma DB · Primary system of record with schema, migrations, and seed data
apps/api/prisma/schema.prisma - LLM layer · Abstraction over OpenAI, Anthropic, and mock providers
apps/api/src/lib/llm
Shared
Cross-app contracts and reusable domain models
- Shared contracts · Reusable API types, entities, enums, and code templates
packages/shared/src/index.ts
Infra
Container and deployment topology
- Docker stack · Compose-based runtime with API, web, PostgreSQL, Redis, and sandbox images
infra/docker/docker-compose.yml
Connections 20
- Web app → Pages: renders · The UI is organized around workflow-specific pages
- Web app → Client state: uses · Client state is managed through local stores
- Web app → API client: calls · UI actions reach the backend through a thin API boundary
- API client → Shared contracts: typed by · Client requests and responses rely on shared contracts
- API app → Routes: hosts · The service mounts domain route modules
- API app → Middleware: wraps · Request handling is centralized through middleware
- Routes → Services: delegates · Routes keep business logic out of handlers
- Routes → Shared contracts: shares types · Route payloads align with shared domain models
- Services → Grading: includes · Submission assessment is a core learning workflow
- Services → Progress: includes · Progress tracking updates learning state
- Services → Revision: includes · Revision generation powers review flows
- Services → Import: includes · Ingestion turns imported content into domain data
- Services → Chat services: includes · Assistant orchestration sits in the service layer
- Chat services → LLM layer: uses · Chat flows are backed by provider abstractions
- Chat services → Shared contracts: shares types · Assistant and learning-path responses use shared models
- Grading → Sandbox: executes in · Untrusted code runs outside the main API process
- API app → Prisma DB: persists to · The backend stores and reads learning data from PostgreSQL via Prisma
- API app → Shared contracts: depends on · Backend and frontend share compile-time contracts
- Web app → Docker stack: deploys with · The UI is shipped as part of the compose-based stack
- API app → Docker stack: deploys with · The API runs within the containerized stack