How charanpawarr09-sudo/foxcode works
1. Overall shape
- This is a TypeScript monorepo for the FORGE learning platform.
- Runtime is split into four main apps: web (React/Vite UI), api (Hono REST + WebSocket backend), workers (BullMQ background jobs), and a deprecated Python ADCA service that is no longer part of the live architecture.
2. Frontend boundary: apps/web
- The web app is a client-side React 19 application built with Vite and React Router.
- It owns all learner-facing pages: landing, auth, courses/lessons, workshop, scenario/challenge flows, interview forge, leaderboard, pricing, and legal pages.
- It consumes the API through apps/web/src/lib/api.ts, useApi, useWebSocket, and query hooks, and persists some local UI state in stores like editor-store.ts.
3. Backend boundary: apps/api
- The API is the core application server and exposes the system’s main domain endpoints.
- Routes are organized by capability rather than by UI screen: assess, billing, blueprints, browse, calibration, courses, employer, evidence, gamification, interview-forge, learners, lessons, recommendations, scenarios, search, storage, and WebSocket execution.
- Cross-cutting middleware enforces auth, request IDs, rate limits, body limits, security headers, submission guards, and tier-based permissions.
4. Domain services inside the API
- Business logic is concentrated in apps/api/src/services, including scoring, interview evaluation, evidence processing, graduation, workshop readiness, and workshop profile updates.
- The adaptive calibration system is inline in the API: scoring.ts and adca-client.ts replace the old external Python ADCA service.
- Execution-related logic also lives here, with an e2b-executor integration and a ws-execute route for real-time code execution sessions.
5. Async processing boundary: apps/workers
- Background and scheduled work is separated from request/response traffic in the workers app.
- Worker jobs include leaderboard resets, daily challenge rotation, subscription expiry handling, decay, achievement checks, evidence processing, blueprint evaluation, email delivery, and scenario narrative generation.
- This is the platform’s eventual-consistency layer for anything that should not block user interactions.
6. Data layer: packages/db
- Persistence is centralized in Prisma, with schema, migrations, seeds, and the shared client in packages/db.
- The database is the source of truth for learners, scenarios, lesson progress, assessments, evidence, leaderboard state, subscriptions, and calibration-related records.
- Seeding is content-heavy: blueprints, scenarios, courses, lesson content, and challenge data are loaded from Prisma seed scripts.
7. Shared contracts and logic: packages/shared and packages/validation
- packages/shared holds cross-app enums, constants, utilities, and TypeScript data shapes for API, billing, learner, scenario, execution, websocket, and evidence domains.
- packages/validation contains schema-level validation for common domain objects.
- These packages define the shared boundary between web, API, workers, and the database-backed domain model.
8. UI system: packages/ui
- The shared UI library provides reusable React components and design-system primitives used by the web app.
- It also contains higher-level FORGE-specific widgets such as arena cards, reasoning maps, spark cards, leaderboard rows, XP/streak components, and execution output panels.
- This package is the presentation layer boundary that keeps page implementations thin.
9. Content and curriculum model
- Static content lives in content/ and is mirrored by the richer seed system under packages/db/prisma/seeds.
- The platform’s educational model is organized around blueprints, scenarios, lessons, challenges, and language tracks, which are then surfaced through the API and rendered in the web app.
- The content system is not just documentation; it is operational input for runtime experiences and database seeding.
10. Infrastructure and external services
- Local development depends on PostgreSQL, Redis, and MailHog via Docker Compose.
- Redis is required for queues and worker coordination; PostgreSQL backs Prisma persistence; MailHog supports email testing; Cloudflare R2 is implied by the API storage client.
- CI/CD and quality gates are explicit: GitHub Actions cover CI, security, accessibility, Lighthouse, staging, and preview deployments, with separate deployment configs for Railway and Vercel.
11. Request and event flows
- User traffic starts in the web app, which calls the API for domain data and uses WebSockets for live execution or interactive sessions.
- The API validates, authorizes, scores, and persists state, then emits work to queues when the action should be handled asynchronously.
- Workers consume those jobs, update the database, and trigger side effects such as emails, leaderboard refreshes, or challenge rotations.
12. Important architectural note
- The repository includes a deprecated Python service under apps/adca, but the authoritative production path is now the TypeScript API and workers.
- For an architecture diagram, the critical runtime boxes are: Web App, API Server, Workers, PostgreSQL, Redis, and optional external storage/email/analytics services.
Main entry points: api API Server · web Web App · workers Workers · services Domain services
Components 17
Apps
Runtime applications and services
- Web App · Learner-facing SPA with routes for landing, auth, courses, workshop, scenarios, interview forge, leaderboard, and legal pages.
apps/web - API client · Typed API access, hooks, and websocket integration used by the web app.
apps/web/src/lib/api.ts - UI state · Local editor and interface state persisted in browser stores.
apps/web/src/stores/editor-store.ts - API Server · Core application server exposing domain routes, validation, auth, middleware, and websocket execution.
apps/api - Domain routes · Capability-based endpoints for assess, billing, blueprints, browse, calibration, courses, employer, evidence, gamification, interview-forge, learners, lessons, recommendations, scenarios, search, storage, and ws-execute.
apps/api/src/routes - Middleware · Auth, request IDs, rate limits, body limits, security headers, submission guards, and tier permissions.
apps/api/src/middleware - Domain services · Scoring, interview evaluation, evidence processing, graduation, workshop readiness, and workshop profile updates.
apps/api/src/services - Execution · WebSocket execution and e2b-backed code execution integration for interactive sessions.
apps/api/src/services/e2b-executor.ts - Workers · Async processing for leaderboards, challenge rotation, subscriptions, decay, achievements, evidence, blueprint evaluation, email, and narratives.
apps/workers - ADCA · Legacy adaptive calibration service kept in the repo but no longer part of the live production path.
apps/adca
Shared Packages
Cross-app libraries and domain packages
- Database · Shared persistence layer and source of truth for learners, scenarios, progress, assessments, evidence, subscriptions, and calibration records.
packages/db - Shared Model · Cross-app enums, constants, utilities, and TypeScript data shapes for API, billing, learner, scenario, execution, websocket, and evidence domains.
packages/shared - Validation · Shared validation schemas for common domain objects.
packages/validation - UI Kit · Reusable React components and FORGE-specific presentation widgets used by the web app.
packages/ui
Infra
Deployment and local runtime dependencies
- External services · PostgreSQL, Redis, MailHog, R2-like storage, and deployment targets supporting the platform.
- CI/CD · GitHub Actions and deployment configs for CI, security, accessibility, Lighthouse, staging, preview, Railway, and Vercel.
.github/workflows
Other components
- Content · Blueprints, scenarios, templates, and other operational content consumed by seeding and runtime experiences.
content
Connections 23
- Web App → API client: calls · Web UI fetches domain data and opens realtime sessions.
- Web App → UI state: persists · Client-side UI state and editor state remain local.
- Web App → UI Kit: renders with · Page implementations use shared UI primitives and widgets.
- API Server → Domain routes: exposes · Server mounts capability-based REST and websocket routes.
- API Server → Middleware: protects with · Requests pass through authentication, limits, and security middleware.
- API Server → Domain services: delegates to · Routes hand off core business logic to services.
- API Server → Execution: executes via · Interactive coding sessions use websocket and executor integration.
- API Server → Database: reads/writes · Server persists and queries primary application state.
- API Server → Shared Model: uses · API contracts and domain types are shared across runtimes.
- API Server → Validation: validates with · Domain payloads use shared schema validation.
- Workers → Database: updates · Jobs apply eventual-consistency changes in the database.
- Workers → Shared Model: uses · Jobs share domain enums, limits, and data shapes.
- Workers → External services: uses · Queues, email delivery, and other side effects rely on external services.
- Domain services → Database: reads/writes · Scoring, evidence, and readiness logic operate on persisted records.
- Domain services → Shared Model: uses · Business rules depend on shared constants and utilities.
- Domain services → ADCA: replaces · Inline calibration logic supersedes the deprecated Python service.
- Content → Database: seeds · Static curriculum content is loaded into Prisma seed data.
- Content → Web App: drives · Content shapes user-facing learning experiences.
- CI/CD → Web App: builds · Preview and production pipelines cover the frontend.
- CI/CD → API Server: builds · CI and deployment workflows package the backend.
- CI/CD → Workers: builds · Worker deployment is covered by automation.
- External services → API Server: supports · Storage, email, Redis, and Postgres back the live system.
- External services → Workers: supports · Workers depend on queues, mail, and datastore infrastructure.