How sebastianbo2/testem works
1. Repository shape
- This is a two-part application: a React/Vite frontend and a Node/Express backend.
- The frontend is the main user-facing product; the backend acts as an orchestration layer for AI exam generation, document ingestion, and Supabase-backed data access.
2. Frontend as the main app shell
- frontend/src/main.tsx boots a single-page app built with React + Vite + TypeScript.
- Routing is organized by pages such as Dashboard, DocumentManagement, ActiveExam, Results, History, Login, Signup, and Onboarding.
- AuthContext and ProtectedRoutes indicate that authentication gates most of the app.
3. Domain-oriented UI structure
- Components are grouped by business area: documents, exam, folders, history, onboarding, plus shared ui primitives.
- This suggests a layered UI architecture where reusable shadcn/Radix components sit underneath feature-specific components like QuestionCard, FolderSidebar, and DocumentCard.
4. Primary user flow
- The product flow is: authenticate → organize documents → select source material → configure an exam → take the exam → view results → revisit history.
- The dashboard acts as the workspace hub, while document management and exam pages handle the core learning workflow.
5. Document management boundary
- The DocumentManagement area is centered on folder-based organization and selection of study files.
- The presence of requestFiles.ts, tmpReq.ts, and tmpDocument/addDocToFolder.js suggests a document-upload and folder-assignment workflow with temporary API helpers during development or integration.
- Supported source material is explicitly PDF/TXT from the README.
6. Exam session boundary
- useExamSession and the ActiveExam page imply a client-side session model for question navigation, answer entry, and progress tracking.
- The exam experience uses a sticky navigator/sidebar and supports multiple question types, including math/STEM rendering through LatexRenderer.
7. Results and history are separate read models
- Results focuses on per-question feedback and answer comparison after submission.
- History is a distinct persistence/reporting surface with sortable past attempts and summary statistics.
- This separation suggests the app stores exam attempts and then rehydrates them for review rather than keeping everything in transient UI state.
8. Backend AI orchestration
- The backend src/backboard/* folder is the AI pipeline: assistant.js, thread.js, docUploader.js, and prompts.js.
- This points to a workflow where uploaded documents are sent to Backboard.io, then threaded prompts generate structured exam content.
- The backend likely shapes model output into an application-friendly format before returning it to the frontend.
9. Data and persistence
- src/config/supabaseClient.js on both frontend and backend indicates Supabase is the shared persistence/auth boundary.
- Backend helpers in src/lib/db_requests.js, fetchQuestions.js, and fetchAnswers.js suggest database access is abstracted behind small request utilities rather than being scattered across handlers.
- The frontend also has src/config/supabaseClient.ts, so some auth or user-state integration likely happens directly from the client.
10. Mocking and local simulation
- frontend/src/lib/mockApi.ts and mockData.ts show the UI can run against simulated data or stubbed responses.
- The README’s “CSV-based question parsing” and the presence of temporary request files suggest the app can simulate backend output during development or for deterministic exam rendering.
11. Loading and state transitions
- Dedicated loading pages such as ExamLoadingState, GradingLoading, and LoadingScreen indicate the UI has explicit states for long-running generation and grading phases.
- This is important architecturally because the AI generation step is asynchronous and likely spans document ingestion, prompt execution, and result formatting.
12. Deployment and tooling
- The frontend is built with Tailwind CSS, shadcn/ui, Lucide icons, and likely uses KaTeX/react-latex-next for STEM rendering.
- Root vercel.json suggests the app is deployed with Vercel, while backend/runtime dependencies are managed via npm in backend/package.json.
- Overall, the repo is optimized for a modern SPA frontend plus a lightweight service backend that mediates AI and persistence.
Main entry points: ProtectedRoutes.tsx Protected routes · ActiveExam.tsx Active exam · assistant.js Backboard pipeline · DocumentManagement.tsx Documents
Components 22
Frontend
React/Vite SPA for the learning workflow
- App shell · Bootstraps the SPA and top-level providers
frontend/src/main.tsx - Pages · Maps the app into dashboard, auth, exam, results, and history screens
frontend/src/App.tsx - Auth context · Holds signed-in user state and auth helpers
frontend/src/context/AuthContext.tsx - Protected routes · Blocks protected pages until authentication is available
frontend/src/components/ProtectedRoutes.tsx - Dashboard · Main hub for moving into document and exam workflows
frontend/src/pages/Dashboard.tsx - Documents · Folder-based file selection and source material management
frontend/src/pages/DocumentManagement.tsx - Active exam · Runs question navigation, answer entry, and progress tracking
frontend/src/pages/ActiveExam.tsx - Results · Shows post-submission feedback and answer comparison
frontend/src/pages/Results.tsx - History · Browses prior exams and summary stats
frontend/src/pages/History.tsx - Onboarding · Explains the product cycle for new users
frontend/src/pages/Onboarding.tsx - Exam session hook · Coordinates question state, navigation, and session progress
frontend/src/hooks/useExamSession.ts - UI kit · Reusable shadcn/Radix components used across feature areas
frontend/src/components/ui/button.tsx - Doc components · Cards, action bars, and other document-management widgets
frontend/src/components/documents/DocumentCard.tsx - Exam components · Question cards and exam navigation widgets
frontend/src/components/exam/QuestionCard.tsx - Loading states · Dedicated screens for generation, grading, and loading transitions
frontend/src/pages/loading/LoadingScreen.tsx - Mock API · Simulated backend responses for local or deterministic UI flows
frontend/src/lib/mockApi.ts - Supabase client · Frontend persistence/auth boundary shared with the backend
frontend/src/config/supabaseClient.ts
Backend
Node/Express orchestration and data access layer
- Server entry · Backend process entrypoint and API host
backend/index.js - Backboard pipeline · Uploads documents and drives threaded prompt generation
backend/src/backboard/assistant.js - Prompts · Defines the structured instructions used for exam generation
backend/src/backboard/prompts.js - DB requests · Fetches questions, answers, and related records through small request helpers
backend/src/lib/db_requests.js - Supabase client · Backend persistence/auth boundary shared with the frontend
backend/src/config/supabaseClient.js
Connections 26
- App shell → Pages: renders · Entry point mounts the route tree
- App shell → Auth context: provides · Top-level auth state is available to the app
- Pages → Protected routes: wraps · Protected screens are guarded before render
- Protected routes → Dashboard: unlocks · Authenticated users reach the workspace hub
- Protected routes → Documents: unlocks · Authenticated users manage source documents
- Protected routes → Active exam: unlocks · Authenticated users run an active exam session
- Protected routes → Results: unlocks · Authenticated users review submitted results
- Protected routes → History: unlocks · Authenticated users inspect attempt history
- Protected routes → Onboarding: unlocks · Authenticated users can view onboarding flow
- Active exam → Exam session hook: uses · The exam page delegates session state to the hook
- Pages → Loading states: shows · Long-running generation and grading states are surfaced explicitly
- Documents → Doc components: composes · Document management is built from feature-specific widgets
- Active exam → Exam components: composes · The active exam page is assembled from question UI pieces
- Dashboard → Documents: navigates · Workspace routes into document organization
- Dashboard → Active exam: starts · Workspace routes into exam creation and taking
- Results → History: feeds · Completed attempts are revisited through history
- UI kit → Doc components: supports · Shared primitives underpin document feature widgets
- UI kit → Exam components: supports · Shared primitives underpin exam feature widgets
- Mock API → Active exam: simulates · Stubbed responses can stand in for backend exam data
- Supabase client → Supabase client: shared boundary · Client and server both connect through Supabase
- Server entry → Backboard pipeline: orchestrates · API server delegates AI workflow to the Backboard pipeline
- Backboard pipeline → Prompts: builds from · Prompt templates shape generated exam content
- Server entry → DB requests: queries · Server handlers read and write persistence-backed records
- DB requests → Supabase client: uses · Database helpers access shared Supabase resources
- Backboard pipeline → Supabase client: stores · Generated or ingested data can be persisted through the shared backend boundary
- Backboard pipeline → Documents: serves · Document ingestion supports the frontend document workflow