How salmonsteakk/cs5224-grp-22 works
1. Overall shape
- LearnBright is split into a browser SPA, an Express API, and a DynamoDB-backed data layer.
- The active codebase is client/ + server/, with local orchestration via docker-compose.yml.
- Production splits static frontend delivery from API delivery: CloudFront fronts S3 for the SPA and an ALB → ECS Fargate service for /api/*.
2. Frontend boundary
- The client is a React 19 + Vite single-page app written in TypeScript.
- client/src/main.tsx boots the app, and App.tsx wires route handling plus top-level providers.
- Routing is page-based: home, learn, practice, dashboard, exams, auth pages, subject/topic drill-down pages, and a 404 fallback.
3. Client-side UI composition
- Reusable presentation pieces live in client/src/components/ such as navigation, subject/topic cards, quiz UI, video player, protected route wrapper, and chatbot sidebar.
- The app uses shadcn/ui primitives for common controls and layouts, with Tailwind for styling.
- VideoPlayer is a simulated lesson experience rather than a separate media service.
4. Client state and session boundaries
- There are three notable client contexts: auth, chatbot, and progress.
- progress-context.tsx owns learner progress behavior and persists guest progress in localStorage.
- Auth state is used to gate protected pages; authenticated users can have progress mirrored to the backend, while anonymous users stay local.
- The chatbot has its own UI/state boundary, suggesting assistant interactions are separate from the core lesson/practice flow.
5. Learning content flow
- The learning path is hierarchical: subject → topic → lesson.
- The client pages LearnPage, SubjectLearnPage, and TopicLessonPage navigate this hierarchy and render content from the API.
- On the server, learn.controller.ts serves subject/topic content from the Subject model, which stores nested topics and lessons in a single item per subject.
6. Practice and assessment flow
- Practice mirrors the learning hierarchy but adds quiz attempts and scoring.
- PracticePage, SubjectPracticePage, and TopicQuizPage drive topic-level quizzes.
- The server’s practice routes/controller return questions for a topic and likely record attempts via the attempt models.
- Separate exam pages and hooks (ExamPaperPage, useExamPaper, useExamAttempts, useExamPaperList) indicate a second assessment track for exam papers, distinct from topic quizzes.
7. Progress, dashboard, and recommendations
- The dashboard is a synthesis layer over learning and quiz history.
- Client-side helpers such as progress-metrics, dashboard-recommendations, and dashboard-coach-payload compute learner KPIs and likely shape data for assistant/coaching features.
- Server-side progress models (UserProgressProfile, UserTopicProgress, TopicQuizAttempt, ExamAttempt) separate raw attempts from aggregate user progress.
- This is the main analytics boundary in the system: content data vs per-user progression data.
8. API surface and server structure
- The Express server is organized by resource: auth, learn, practice, progress, exams, chat, and dashboard-coach routes.
- app.ts assembles middleware and route registration; index.ts handles startup, DB initialization, and seeding.
- Middleware includes auth protection and exam-admin gating, so not all endpoints are public.
- Utilities for JWT and password handling indicate token-based authentication with server-side credential verification.
9. Content and persistence model
- The core content catalog is seeded from server/src/data/subjects.ts into a DynamoDB Subjects table.
- Each subject contains nested topics, lessons, and questions, which keeps learning content compact and easy to fetch by subject or topic.
- User-related entities are modeled separately from content, which is important for diagramming the boundary between static curriculum and mutable learner state.
10. Local development vs production
- Locally, docker-compose.yml runs three containers: client on 5173, server on 3001, and DynamoDB Local on 8000.
- The server retries DB connection on startup, because DynamoDB Local may not be ready immediately.
- In production, Terraform provisions the network, ECR, ECS/Fargate, ALB, S3, CloudFront, and DynamoDB, while scripts/deploy.sh builds/publishes the client and server artifacts.
- The frontend and API share a single CloudFront entry point, which avoids cross-origin complexity.
11. Legacy code boundary
- v0-old/ is a previous Next.js-based implementation and appears to be archived rather than part of the active architecture.
- For an architecture diagram, it should be treated as historical reference, not a live subsystem.
Main entry points: App.tsx Routes · index.ts API routes · models Dynamo models · app.ts App setup
Components 26
Client SPA
React single-page app and its UI/state layers.
- App shell · Bootstraps the SPA and top-level app wiring.
client/src/main.tsx - Routes · Top-level page routing and providers for the client app.
client/src/App.tsx - Core pages · Home, learn, practice, dashboard, exams, auth, and fallback screens.
client/src/pages - Drill pages · Subject and topic pages for lesson and quiz drill-down.
client/src/pages - UI components · Navigation, cards, quiz UI, video player, protected route, and chatbot sidebar.
client/src/components - App contexts · Auth, chatbot, and progress context boundaries.
client/src/context - Progress logic · Learner progress metrics and local guest progress persistence.
client/src/context/progress-context.tsx - Coach data · Dashboard recommendation and coach-payload shaping helpers.
client/src/lib - Exam hooks · Client hooks for exam paper lists, paper detail, and attempts.
client/src/hooks - API client · Shared client-side API access layer.
client/src/services/api.ts
API Server
Express API, domain controllers, and persistence models.
- Server boot · Starts the API, initializes DB access, and runs seeding.
server/src/index.ts - App setup · Assembles middleware and registers routes.
server/src/app.ts - API routes · Central route composition for auth, learn, practice, progress, exams, chat, and coaching.
server/src/routes/index.ts - Learn API · Serves subject/topic/lesson content from the curriculum model.
server/src/controllers/learn.controller.ts - Practice API · Serves topic practice questions and related attempt flow.
server/src/controllers/practice.controller.ts - Exams API · Handles exam paper access and attempt tracking.
server/src/controllers/exam.controller.ts - Progress API · Exposes user progress and dashboard-facing progress data.
server/src/controllers/progress.controller.ts - Auth API · Login/signup and session credential handling.
server/src/controllers/auth.controller.ts - Dynamo models · Subjects, users, progress profiles, topic quiz attempts, and exam attempts.
server/src/models - Curriculum data · Seed data for subjects, nested topics, lessons, questions, and exam papers.
server/src/data - DynamoDB · Persistent store for curriculum and learner state.
server/src/db/index.ts - Middleware · Auth protection and exam-admin gating.
server/src/middleware
Delivery & Infra
Local orchestration and production deployment infrastructure.
- Local compose · Runs client, server, and DynamoDB Local together.
docker-compose.yml - Deploy script · Builds and publishes client and server artifacts.
scripts/deploy.sh - Terraform · Defines network, ECR, ECS/Fargate, ALB, CloudFront, S3, and DynamoDB infrastructure.
terraform
Legacy App
Archived prior implementation kept as historical reference.
- Old app · Archived prior implementation, not part of the active architecture.
v0-old
Connections 33
- App shell → Routes: boots · Entry initializes the app shell and hands off to routing.
- Routes → Core pages: renders · Routing selects the main page-level screens.
- Routes → Drill pages: renders · Routing drives subject/topic drill-down pages.
- Routes → UI components: composes · Pages are built from reusable UI components.
- Routes → App contexts: provides · Top-level providers supply shared auth, chatbot, and progress state.
- App contexts → Progress logic: includes · Progress context owns metrics and guest persistence behavior.
- Core pages → API client: fetches via · Core pages retrieve data from the API client.
- Drill pages → API client: fetches via · Learning drill-down pages load subject/topic/lesson and quiz data.
- Exam hooks → API client: queries · Hooks centralize exam-related API reads and attempt state.
- Coach data → Progress logic: derives from · Recommendations and coach payloads are shaped from progress data.
- Server boot → App setup: starts · Startup delegates to the Express application assembly.
- App setup → API routes: registers · App setup mounts the route tree.
- App setup → Middleware: uses · Middleware applies protection and admin gating.
- API routes → Auth API: maps · Route registry exposes auth endpoints.
- API routes → Learn API: maps · Route registry exposes learn endpoints.
- API routes → Practice API: maps · Route registry exposes practice endpoints.
- API routes → Exams API: maps · Route registry exposes exam endpoints.
- API routes → Progress API: maps · Route registry exposes progress endpoints.
- Learn API → Dynamo models: reads · Learning endpoints use the subject/content model.
- Practice API → Dynamo models: reads/writes · Practice endpoints work with topic quizzes and attempts.
- Exams API → Dynamo models: reads/writes · Exam endpoints access exam papers and attempts.
- Progress API → Dynamo models: aggregates · Progress endpoints aggregate user progress state from attempts and profiles.
- Auth API → Dynamo models: uses · Auth endpoints operate on user records.
- Dynamo models → DynamoDB: persists to · Models map application state into DynamoDB.
- Curriculum data → DynamoDB: seeds · Seed data populates the curriculum store.
- Local compose → App shell: runs · Local compose starts the client container.
- Local compose → Server boot: runs · Local compose starts the API container.
- Local compose → DynamoDB: runs · Local compose provides DynamoDB Local.
- Deploy script → Routes: packages · Deployment builds and publishes the SPA.
- Deploy script → App setup: packages · Deployment builds and publishes the API service.
- Terraform → DynamoDB: provisions · Terraform defines the managed DynamoDB table.
- Terraform → App setup: provisions · Terraform provisions ECS/Fargate delivery for the API.
- Terraform → Routes: provisions · Terraform provisions S3 and CloudFront for SPA delivery.