# sridesiyan/examgen architecture

> Architecture diagram of the GitHub repository sridesiyan/examgen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sridesiyan/examgen
- Repository: https://github.com/sridesiyan/examgen

## Overview

#### Purpose and Entry Points
ExamGen Nexus is a full examination-lifecycle platform: role-based access, exam authoring/delivery, identity/proctoring signals, adaptive assessment, scoring, and outcomes analytics. The browser application starts at `frontend/src/main.tsx` and routes through `frontend/src/App.tsx`; the API process starts at `backend/src/index.ts` and configures Express in `backend/src/app.ts`.

#### Client Application and Role Workflows
The React/Vite frontend separates student, teacher, and administrator workflows. Shared shell/navigation is in `frontend/src/components/layout/DashboardLayout.tsx`; authentication state is centralized in `frontend/src/store/authStore.ts`, with backend calls behind `frontend/src/services/api.ts`.
- Student flow: readiness/identity, lobby, secure exam room, then results: `frontend/src/pages/student/IdentityVerificationPage.tsx`, `frontend/src/pages/student/ExamRoom.tsx`, `frontend/src/pages/student/ResultPage.tsx`.
- Teacher flow: create exams, monitor active candidates, and view reports: `frontend/src/pages/teacher/CreateExamPage.tsx`, `frontend/src/pages/teacher/LiveMonitorPage.tsx`, `frontend/src/pages/teacher/ReportsPage.tsx`.
- Administrative overview: `frontend/src/pages/admin/AdminDashboard.tsx`.

#### API Boundary, Authentication, and Persistence
Express exposes domain-oriented HTTP route modules for auth, exams/questions, sessions/submissions, biometrics, and analytics: `backend/src/routes/auth.ts`, `backend/src/routes/exams.ts`, `backend/src/routes/sessions.ts`. JWT authorization and role enforcement are a middleware boundary in `backend/src/middleware/auth.ts`; centralized failures pass through `backend/src/middleware/errorHandler.ts`.
Prisma defines the persistent domain model and migration history in `backend/prisma/schema.prisma` and `backend/prisma/migrations/20260613093336_init/migration.sql`. The checked-in local datastore is SQLite (`backend/prisma/examgen.db`), while PostgreSQL is the intended production database.

#### Exam Authoring and Question Intelligence
Teachers create and manage exams through the exam and question APIs (`backend/src/routes/exams.ts`, `backend/src/routes/questions.ts`). AI-assisted generation is isolated behind `backend/src/services/aiService.ts`, allowing the provider/integration to be swapped without coupling route handlers or client pages to it. Question selection adapts to current performance through `backend/src/services/adaptiveEngine.ts`.

#### Assessment Session and Proctoring Flow
A candidate enters an exam session via `backend/src/routes/sessions.ts`, answers through the exam-room UI, and submits via `backend/src/routes/submissions.ts`. The browser gathers webcam/WebRTC and browser-behavior signals; identity and biometric interactions cross the API through `backend/src/routes/biometrics.ts`.
Server-side proctoring interpretation is decomposed into `backend/src/services/agentInvigilator.ts`, `backend/src/services/leakageDetection.ts`, and `backend/src/services/riskEngine.ts`. This separates raw integrity events from derived alerts/risk scores used by live monitoring and post-exam review.

#### Evaluation, Analytics, and Recommendations
Submission data drives scoring and outcome analysis through `backend/src/routes/submissions.ts` and `backend/src/routes/analytics.ts`. Topic-level mastery and remediation are calculated in `backend/src/services/skillGap.ts`; placement-oriented readiness is produced by `backend/src/services/placementEngine.ts`. These outputs feed student results and teacher reports rather than being embedded in exam delivery.

#### Runtime and External Dependencies
The system runs a TypeScript React 18 SPA built by Vite (`frontend/package.json`) and a TypeScript Node.js/Express API (`backend/package.json`). Authentication uses JWT and bcryptjs. Planned client-side proctoring depends on browser APIs, WebRTC, and face-api.js; visualization is expected through Recharts. No separate queue, object store, or deployed AI provider is represented in the repository tree, so AI and biometric/provider concerns remain service-layer integration boundaries.

Main entry points: [`frontend/src/App.tsx`](https://github.com/sridesiyan/examgen/blob/main/frontend/src/App.tsx) (App router), [`backend/src/routes/sessions.ts`](https://github.com/sridesiyan/examgen/blob/main/backend/src/routes/sessions.ts) (Domain routes), [`frontend/src/services/api.ts`](https://github.com/sridesiyan/examgen/blob/main/frontend/src/services/api.ts) (API client), [`backend/src/services/skillGap.ts`](https://github.com/sridesiyan/examgen/blob/main/backend/src/services/skillGap.ts) (Outcome analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React browser app"]
  node_frontend_entry(("Vite entry<br/>React entry<br/>[main.tsx]"))
  node_frontend_app["App router<br/>React routes<br/>[App.tsx]"]
  node_dashboard_shell["Dashboard shell<br/>shared layout"]
  node_auth_store["Auth state<br/>client store<br/>[authStore.ts]"]
  node_api_client["API client<br/>HTTP client<br/>[api.ts]"]
  node_student_workflow["Student exam workflow<br/>student pages<br/>[ExamRoom.tsx]"]
  node_teacher_workflow["Teacher workflow<br/>teacher pages<br/>[CreateExamPage.tsx]"]
  node_admin_dashboard["Admin overview<br/>admin page<br/>[AdminDashboard.tsx]"]
  node_browser_signals["Browser proctoring signals<br/>WebRTC/browser APIs"]
end

subgraph group_api["Express API"]
  node_api_entry(("API process<br/>Node entry<br/>[index.ts]"))
  node_express_app["Express application<br/>HTTP server<br/>[app.ts]"]
  node_auth_boundary["JWT role boundary<br/>auth middleware<br/>[auth.ts]"]
  node_route_modules["Domain routes<br/>Express routes<br/>[sessions.ts]"]
  node_error_boundary["Error handling<br/>Express middleware<br/>[errorHandler.ts]"]
end

subgraph group_domain["Assessment services"]
  node_exam_intelligence["Exam intelligence<br/>authoring services<br/>[adaptiveEngine.ts]"]
  node_proctoring_pipeline["Proctoring risk pipeline<br/>integrity services<br/>[riskEngine.ts]"]
  node_outcome_analysis["Outcome analysis<br/>analytics services<br/>[skillGap.ts]"]
  node_ai_provider_boundary["AI provider boundary<br/>service integration<br/>[aiService.ts]"]
end

subgraph group_data["Persistence"]
  node_prisma_model["Prisma domain model<br/>ORM schema<br/>[schema.prisma]"]
  node_sqlite_store[("Local SQLite datastore<br/>SQLite database<br/>[examgen.db]")]
end

node_frontend_entry -->|"mounts"| node_frontend_app
node_frontend_app -->|"renders"| node_dashboard_shell
node_frontend_app -->|"student routes"| node_student_workflow
node_frontend_app -->|"teacher routes"| node_teacher_workflow
node_frontend_app -->|"admin route"| node_admin_dashboard
node_dashboard_shell -->|"uses"| node_auth_store
node_student_workflow -->|"exam/session calls"| node_api_client
node_teacher_workflow -->|"authoring/report calls"| node_api_client
node_admin_dashboard -->|"API calls"| node_api_client
node_student_workflow -->|"collects"| node_browser_signals
node_browser_signals -->|"sends signals"| node_api_client
node_api_client -->|"HTTPS"| node_express_app
node_api_entry -->|"starts"| node_express_app
node_express_app -->|"protects routes"| node_auth_boundary
node_auth_boundary -->|"authorizes"| node_route_modules
node_express_app -->|"failures"| node_error_boundary
node_route_modules -->|"authoring/adaptation"| node_exam_intelligence
node_exam_intelligence -->|"generation"| node_ai_provider_boundary
node_route_modules -->|"biometric events"| node_proctoring_pipeline
node_route_modules -->|"submissions"| node_outcome_analysis
node_route_modules -->|"reads and writes"| node_prisma_model
node_proctoring_pipeline -->|"stores alerts"| node_prisma_model
node_outcome_analysis -->|"stores outcomes"| node_prisma_model
node_prisma_model -->|"local persistence"| node_sqlite_store
node_proctoring_pipeline -.->|"live risk data"| node_teacher_workflow
node_outcome_analysis -.->|"results"| node_student_workflow
node_outcome_analysis -.->|"reports"| node_teacher_workflow

click node_frontend_entry "https://github.com/sridesiyan/examgen/blob/main/frontend/src/main.tsx"
click node_frontend_app "https://github.com/sridesiyan/examgen/blob/main/frontend/src/App.tsx"
click node_dashboard_shell "https://github.com/sridesiyan/examgen/blob/main/frontend/src/components/layout/DashboardLayout.tsx"
click node_auth_store "https://github.com/sridesiyan/examgen/blob/main/frontend/src/store/authStore.ts"
click node_api_client "https://github.com/sridesiyan/examgen/blob/main/frontend/src/services/api.ts"
click node_student_workflow "https://github.com/sridesiyan/examgen/blob/main/frontend/src/pages/student/ExamRoom.tsx"
click node_teacher_workflow "https://github.com/sridesiyan/examgen/blob/main/frontend/src/pages/teacher/CreateExamPage.tsx"
click node_admin_dashboard "https://github.com/sridesiyan/examgen/blob/main/frontend/src/pages/admin/AdminDashboard.tsx"
click node_api_entry "https://github.com/sridesiyan/examgen/blob/main/backend/src/index.ts"
click node_express_app "https://github.com/sridesiyan/examgen/blob/main/backend/src/app.ts"
click node_auth_boundary "https://github.com/sridesiyan/examgen/blob/main/backend/src/middleware/auth.ts"
click node_route_modules "https://github.com/sridesiyan/examgen/blob/main/backend/src/routes/sessions.ts"
click node_error_boundary "https://github.com/sridesiyan/examgen/blob/main/backend/src/middleware/errorHandler.ts"
click node_exam_intelligence "https://github.com/sridesiyan/examgen/blob/main/backend/src/services/adaptiveEngine.ts"
click node_proctoring_pipeline "https://github.com/sridesiyan/examgen/blob/main/backend/src/services/riskEngine.ts"
click node_outcome_analysis "https://github.com/sridesiyan/examgen/blob/main/backend/src/services/skillGap.ts"
click node_prisma_model "https://github.com/sridesiyan/examgen/blob/main/backend/prisma/schema.prisma"
click node_sqlite_store "https://github.com/sridesiyan/examgen/blob/main/backend/prisma/examgen.db"
click node_ai_provider_boundary "https://github.com/sridesiyan/examgen/blob/main/backend/src/services/aiService.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_entry,node_frontend_app,node_dashboard_shell,node_auth_store,node_api_client,node_student_workflow,node_teacher_workflow,node_admin_dashboard,node_browser_signals toneBlue
class node_api_entry,node_express_app,node_auth_boundary,node_route_modules,node_error_boundary toneAmber
class node_exam_intelligence,node_proctoring_pipeline,node_outcome_analysis,node_ai_provider_boundary toneMint
class node_prisma_model,node_sqlite_store toneRose
```

## Components

### React browser app

- [Vite entry](https://github.com/sridesiyan/examgen/blob/main/frontend/src/main.tsx): React entry · `frontend/src/main.tsx`
- [App router](https://github.com/sridesiyan/examgen/blob/main/frontend/src/App.tsx): React routes · `frontend/src/App.tsx`
- [Dashboard shell](https://github.com/sridesiyan/examgen/blob/main/frontend/src/components/layout/DashboardLayout.tsx): shared layout · Role-aware navigation shell. · `frontend/src/components/layout/DashboardLayout.tsx`
- [Auth state](https://github.com/sridesiyan/examgen/blob/main/frontend/src/store/authStore.ts): client store · `frontend/src/store/authStore.ts`
- [API client](https://github.com/sridesiyan/examgen/blob/main/frontend/src/services/api.ts): HTTP client · `frontend/src/services/api.ts`
- [Student exam workflow](https://github.com/sridesiyan/examgen/blob/main/frontend/src/pages/student/ExamRoom.tsx): student pages · Identity verification, exam room, and results. · `frontend/src/pages/student/ExamRoom.tsx`
- [Teacher workflow](https://github.com/sridesiyan/examgen/blob/main/frontend/src/pages/teacher/CreateExamPage.tsx): teacher pages · Exam authoring, live monitoring, and reports. · `frontend/src/pages/teacher/CreateExamPage.tsx`
- [Admin overview](https://github.com/sridesiyan/examgen/blob/main/frontend/src/pages/admin/AdminDashboard.tsx): admin page · `frontend/src/pages/admin/AdminDashboard.tsx`
- **Browser proctoring signals**: WebRTC/browser APIs · Webcam, identity, and behavior signals.

### Express API

- [API process](https://github.com/sridesiyan/examgen/blob/main/backend/src/index.ts): Node entry · `backend/src/index.ts`
- [Express application](https://github.com/sridesiyan/examgen/blob/main/backend/src/app.ts): HTTP server · `backend/src/app.ts`
- [JWT role boundary](https://github.com/sridesiyan/examgen/blob/main/backend/src/middleware/auth.ts): auth middleware · `backend/src/middleware/auth.ts`
- [Domain routes](https://github.com/sridesiyan/examgen/blob/main/backend/src/routes/sessions.ts): Express routes · Auth, exams, sessions, submissions, biometrics, and analytics endpoints. · `backend/src/routes/sessions.ts`
- [Error handling](https://github.com/sridesiyan/examgen/blob/main/backend/src/middleware/errorHandler.ts): Express middleware · `backend/src/middleware/errorHandler.ts`

### Assessment services

- [Exam intelligence](https://github.com/sridesiyan/examgen/blob/main/backend/src/services/adaptiveEngine.ts): authoring services · AI generation and adaptive question selection. · `backend/src/services/adaptiveEngine.ts`
- [Proctoring risk pipeline](https://github.com/sridesiyan/examgen/blob/main/backend/src/services/riskEngine.ts): integrity services · Interprets events into alerts and risk scores. · `backend/src/services/riskEngine.ts`
- [Outcome analysis](https://github.com/sridesiyan/examgen/blob/main/backend/src/services/skillGap.ts): analytics services · Skill gaps, remediation, and placement readiness. · `backend/src/services/skillGap.ts`
- [AI provider boundary](https://github.com/sridesiyan/examgen/blob/main/backend/src/services/aiService.ts): service integration · Swappable generation-provider integration. · `backend/src/services/aiService.ts`

### Persistence

- [Prisma domain model](https://github.com/sridesiyan/examgen/blob/main/backend/prisma/schema.prisma): ORM schema · `backend/prisma/schema.prisma`
- [Local SQLite datastore](https://github.com/sridesiyan/examgen/blob/main/backend/prisma/examgen.db): SQLite database · Development datastore; PostgreSQL is intended for production. · `backend/prisma/examgen.db`

## Connections

- Vite entry → App router: mounts
- App router → Dashboard shell: renders
- App router → Student exam workflow: student routes
- App router → Teacher workflow: teacher routes
- App router → Admin overview: admin route
- Dashboard shell → Auth state: uses
- Student exam workflow → API client: exam/session calls
- Teacher workflow → API client: authoring/report calls
- Admin overview → API client: API calls
- Student exam workflow → Browser proctoring signals: collects
- Browser proctoring signals → API client: sends signals
- API client → Express application: HTTPS
- API process → Express application: starts
- Express application → JWT role boundary: protects routes
- JWT role boundary → Domain routes: authorizes
- Express application → Error handling: failures
- Domain routes → Exam intelligence: authoring/adaptation
- Exam intelligence → AI provider boundary: generation
- Domain routes → Proctoring risk pipeline: biometric events
- Domain routes → Outcome analysis: submissions
- Domain routes → Prisma domain model: reads and writes
- Proctoring risk pipeline → Prisma domain model: stores alerts
- Outcome analysis → Prisma domain model: stores outcomes
- Prisma domain model → Local SQLite datastore: local persistence
- Proctoring risk pipeline → Teacher workflow: live risk data
- Outcome analysis → Student exam workflow: results
- Outcome analysis → Teacher workflow: reports
