# nashd31/examapp architecture

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

- Interactive diagram: https://gitdiagram.com/nashd31/examapp
- Repository: https://github.com/nashd31/examapp

## Overview

This is a React/Express exam-management LMS. Students enroll, take timed exams, submit answers, and review released grades and feedback; teachers manage courses and exams, grade open responses, and analyze results. The client can use REST APIs or a local mock fallback; the server supports PostgreSQL or a JSON-backed database and includes Gemini-powered exam generation. The README documents the broad client/server flow; where backend or UI internals were unsampled, edges are limited to documented or indexed relationships.

Main entry points: [`server/server.js`](https://github.com/nashd31/examapp/blob/main/server/server.js) (Express application), [`client/src/App.jsx`](https://github.com/nashd31/examapp/blob/main/client/src/App.jsx) (SPA routing), [`client/src/pages/TeacherDashboard.jsx`](https://github.com/nashd31/examapp/blob/main/client/src/pages/TeacherDashboard.jsx) (Teacher dashboard), [`client/src/api/examService.js`](https://github.com/nashd31/examapp/blob/main/client/src/api/examService.js) (Exam and course API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client application"]
  node_app["SPA routing<br/>[App.jsx]"]
  node_auth["Authentication UI<br/>[Auth.jsx]"]
  node_authstate["Auth state<br/>[AuthContext.jsx]"]
  node_studentportal["Student portal<br/>[StudentPortal.jsx]"]
  node_takeexam["Timed exam<br/>[TakeExam.jsx]"]
  node_teacherdash["Teacher dashboard"]
  node_exameditor["Exam composer<br/>[ExamEditor.jsx]"]
  node_grading["Manual grading"]
  node_analytics["Scores and analytics"]
  node_examservice["Exam and course API<br/>[examService.js]"]
  node_authservice["Auth API<br/>[authService.js]"]
  node_apiclient["HTTP client<br/>[apiClient.js]"]
end

subgraph group_api["API and domain"]
  node_server["Express application<br/>[server.js]"]
  node_authroutes["Auth routes<br/>[authRoutes.js]"]
  node_courseroutes["Course routes<br/>[courseRoutes.js]"]
  node_examroutes["Exam routes<br/>[examRoutes.js]"]
  node_submissionroutes["Submission routes"]
  node_airoutes["AI routes<br/>[aiRoutes.js]"]
  node_authcontroller["Auth operations<br/>[authController.js]"]
  node_coursecontroller["Course operations"]
  node_examcontroller["Exam operations<br/>[examController.js]"]
  node_submissioncontroller["Submission and grading"]
  node_aicontroller["AI exam generation<br/>[aiController.js]"]
  node_authmiddleware["JWT role checks<br/>[authMiddleware.js]"]
end

subgraph group_persistence["Persistence"]
  node_localstorage[("Browser storage<br/>[storage.js]")]
  node_mockdata[("Client mock data<br/>[mockDb.js]")]
  node_database[("Database adapter<br/>[db.js]")]
  node_jsonengine[("JSON DB engine<br/>[jsonDbEngine.js]")]
end

subgraph group_integrations["External services"]
  node_gemini["Gemini AI"]
end

node_student(("Student"))
node_teacher(("Teacher"))

node_student -->|"uses"| node_app
node_teacher -->|"uses"| node_app
node_app -->|"routes to"| node_auth
node_app -->|"routes to"| node_studentportal
node_app -->|"routes to"| node_takeexam
node_app -->|"routes to"| node_teacherdash
node_auth -->|"uses"| node_authstate
node_authstate -->|"calls"| node_authservice
node_authservice -->|"calls"| node_apiclient
node_authservice -->|"stores token"| node_localstorage
node_studentportal -->|"calls"| node_examservice
node_takeexam -->|"calls"| node_examservice
node_teacherdash -->|"calls"| node_examservice
node_teacherdash -->|"renders"| node_exameditor
node_teacherdash -->|"renders"| node_grading
node_teacherdash -->|"renders"| node_analytics
node_examservice -->|"calls"| node_apiclient
node_examservice -.->|"falls back"| node_mockdata
node_apiclient -->|"REST JSON"| node_server
node_server -->|"mounts"| node_authroutes
node_server -->|"mounts"| node_courseroutes
node_server -->|"mounts"| node_examroutes
node_server -->|"mounts"| node_submissionroutes
node_server -->|"mounts"| node_airoutes
node_authroutes -->|"dispatches"| node_authcontroller
node_courseroutes -->|"dispatches"| node_coursecontroller
node_examroutes -->|"dispatches"| node_examcontroller
node_submissionroutes -->|"dispatches"| node_submissioncontroller
node_airoutes -->|"dispatches"| node_aicontroller
node_authroutes -->|"protects routes"| node_authmiddleware
node_courseroutes -->|"protects routes"| node_authmiddleware
node_examroutes -->|"protects routes"| node_authmiddleware
node_submissionroutes -->|"protects routes"| node_authmiddleware
node_authcontroller -->|"queries"| node_database
node_coursecontroller -->|"queries"| node_database
node_examcontroller -->|"queries"| node_database
node_submissioncontroller -->|"queries"| node_database
node_database -->|"selects backend"| node_jsonengine
node_aicontroller -->|"generates exams"| node_gemini

click node_app "https://github.com/nashd31/examapp/blob/main/client/src/App.jsx"
click node_auth "https://github.com/nashd31/examapp/blob/main/client/src/pages/Auth.jsx"
click node_authstate "https://github.com/nashd31/examapp/blob/main/client/src/context/AuthContext.jsx"
click node_studentportal "https://github.com/nashd31/examapp/blob/main/client/src/pages/StudentPortal.jsx"
click node_takeexam "https://github.com/nashd31/examapp/blob/main/client/src/pages/TakeExam.jsx"
click node_teacherdash "https://github.com/nashd31/examapp/blob/main/client/src/pages/TeacherDashboard.jsx"
click node_exameditor "https://github.com/nashd31/examapp/blob/main/client/src/components/ExamEditor.jsx"
click node_grading "https://github.com/nashd31/examapp/blob/main/client/src/components/GradeSubmissionViewer.jsx"
click node_analytics "https://github.com/nashd31/examapp/blob/main/client/src/components/ExamScoresViewer.jsx"
click node_examservice "https://github.com/nashd31/examapp/blob/main/client/src/api/examService.js"
click node_authservice "https://github.com/nashd31/examapp/blob/main/client/src/api/authService.js"
click node_apiclient "https://github.com/nashd31/examapp/blob/main/client/src/services/apiClient.js"
click node_localstorage "https://github.com/nashd31/examapp/blob/main/client/src/services/storage.js"
click node_mockdata "https://github.com/nashd31/examapp/blob/main/client/src/api/mockDb.js"
click node_server "https://github.com/nashd31/examapp/blob/main/server/server.js"
click node_authroutes "https://github.com/nashd31/examapp/blob/main/server/routes/authRoutes.js"
click node_courseroutes "https://github.com/nashd31/examapp/blob/main/server/routes/courseRoutes.js"
click node_examroutes "https://github.com/nashd31/examapp/blob/main/server/routes/examRoutes.js"
click node_submissionroutes "https://github.com/nashd31/examapp/blob/main/server/routes/submissionRoutes.js"
click node_airoutes "https://github.com/nashd31/examapp/blob/main/server/routes/aiRoutes.js"
click node_authcontroller "https://github.com/nashd31/examapp/blob/main/server/controllers/authController.js"
click node_coursecontroller "https://github.com/nashd31/examapp/blob/main/server/controllers/courseController.js"
click node_examcontroller "https://github.com/nashd31/examapp/blob/main/server/controllers/examController.js"
click node_submissioncontroller "https://github.com/nashd31/examapp/blob/main/server/controllers/submissionController.js"
click node_aicontroller "https://github.com/nashd31/examapp/blob/main/server/controllers/aiController.js"
click node_authmiddleware "https://github.com/nashd31/examapp/blob/main/server/middleware/authMiddleware.js"
click node_database "https://github.com/nashd31/examapp/blob/main/server/config/db.js"
click node_jsonengine "https://github.com/nashd31/examapp/blob/main/server/config/jsonDbEngine.js"

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_app,node_auth,node_authstate,node_studentportal,node_takeexam,node_teacherdash,node_exameditor,node_grading,node_analytics,node_examservice,node_authservice,node_apiclient toneBlue
class node_server,node_authroutes,node_courseroutes,node_examroutes,node_submissionroutes,node_airoutes,node_authcontroller,node_coursecontroller,node_examcontroller,node_submissioncontroller,node_aicontroller,node_authmiddleware toneAmber
class node_localstorage,node_mockdata,node_database,node_jsonengine toneMint
class node_gemini toneRose
class node_student,node_teacher toneIndigo
```

## Components

### Client application

- [SPA routing](https://github.com/nashd31/examapp/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Authentication UI](https://github.com/nashd31/examapp/blob/main/client/src/pages/Auth.jsx): `client/src/pages/Auth.jsx`
- [Auth state](https://github.com/nashd31/examapp/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [Student portal](https://github.com/nashd31/examapp/blob/main/client/src/pages/StudentPortal.jsx): `client/src/pages/StudentPortal.jsx`
- [Timed exam](https://github.com/nashd31/examapp/blob/main/client/src/pages/TakeExam.jsx): `client/src/pages/TakeExam.jsx`
- [Teacher dashboard](https://github.com/nashd31/examapp/blob/main/client/src/pages/TeacherDashboard.jsx): `client/src/pages/TeacherDashboard.jsx`
- [Exam composer](https://github.com/nashd31/examapp/blob/main/client/src/components/ExamEditor.jsx): `client/src/components/ExamEditor.jsx`
- [Manual grading](https://github.com/nashd31/examapp/blob/main/client/src/components/GradeSubmissionViewer.jsx): `client/src/components/GradeSubmissionViewer.jsx`
- [Scores and analytics](https://github.com/nashd31/examapp/blob/main/client/src/components/ExamScoresViewer.jsx): `client/src/components/ExamScoresViewer.jsx`
- [Exam and course API](https://github.com/nashd31/examapp/blob/main/client/src/api/examService.js): `client/src/api/examService.js`
- [Auth API](https://github.com/nashd31/examapp/blob/main/client/src/api/authService.js): `client/src/api/authService.js`
- [HTTP client](https://github.com/nashd31/examapp/blob/main/client/src/services/apiClient.js): `client/src/services/apiClient.js`

### API and domain

- [Express application](https://github.com/nashd31/examapp/blob/main/server/server.js): `server/server.js`
- [Auth routes](https://github.com/nashd31/examapp/blob/main/server/routes/authRoutes.js): `server/routes/authRoutes.js`
- [Course routes](https://github.com/nashd31/examapp/blob/main/server/routes/courseRoutes.js): `server/routes/courseRoutes.js`
- [Exam routes](https://github.com/nashd31/examapp/blob/main/server/routes/examRoutes.js): `server/routes/examRoutes.js`
- [Submission routes](https://github.com/nashd31/examapp/blob/main/server/routes/submissionRoutes.js): `server/routes/submissionRoutes.js`
- [AI routes](https://github.com/nashd31/examapp/blob/main/server/routes/aiRoutes.js): `server/routes/aiRoutes.js`
- [Auth operations](https://github.com/nashd31/examapp/blob/main/server/controllers/authController.js): `server/controllers/authController.js`
- [Course operations](https://github.com/nashd31/examapp/blob/main/server/controllers/courseController.js): `server/controllers/courseController.js`
- [Exam operations](https://github.com/nashd31/examapp/blob/main/server/controllers/examController.js): `server/controllers/examController.js`
- [Submission and grading](https://github.com/nashd31/examapp/blob/main/server/controllers/submissionController.js): `server/controllers/submissionController.js`
- [AI exam generation](https://github.com/nashd31/examapp/blob/main/server/controllers/aiController.js): `server/controllers/aiController.js`
- [JWT role checks](https://github.com/nashd31/examapp/blob/main/server/middleware/authMiddleware.js): `server/middleware/authMiddleware.js`

### Persistence

- [Browser storage](https://github.com/nashd31/examapp/blob/main/client/src/services/storage.js): `client/src/services/storage.js`
- [Client mock data](https://github.com/nashd31/examapp/blob/main/client/src/api/mockDb.js): `client/src/api/mockDb.js`
- [Database adapter](https://github.com/nashd31/examapp/blob/main/server/config/db.js): `server/config/db.js`
- [JSON DB engine](https://github.com/nashd31/examapp/blob/main/server/config/jsonDbEngine.js): `server/config/jsonDbEngine.js`

### External services

- **Gemini AI**

### Other components

- **Student**
- **Teacher**

## Connections

- Student → SPA routing: uses
- Teacher → SPA routing: uses
- SPA routing → Authentication UI: routes to (evidence: `client/src/App.jsx`)
- SPA routing → Student portal: routes to (evidence: `client/src/App.jsx`)
- SPA routing → Timed exam: routes to (evidence: `client/src/App.jsx`)
- SPA routing → Teacher dashboard: routes to (evidence: `client/src/App.jsx`)
- Authentication UI → Auth state: uses (evidence: `client/src/pages/Auth.jsx`)
- Auth state → Auth API: calls (evidence: `client/src/context/AuthContext.jsx`)
- Auth API → HTTP client: calls (evidence: `client/src/api/authService.js`)
- Auth API → Browser storage: stores token (evidence: `client/src/api/authService.js`)
- Student portal → Exam and course API: calls (evidence: `client/src/pages/StudentPortal.jsx`)
- Timed exam → Exam and course API: calls (evidence: `client/src/pages/TakeExam.jsx`)
- Teacher dashboard → Exam and course API: calls (evidence: `client/src/pages/TeacherDashboard.jsx`)
- Teacher dashboard → Exam composer: renders (evidence: `client/src/pages/TeacherDashboard.jsx`)
- Teacher dashboard → Manual grading: renders (evidence: `client/src/pages/TeacherDashboard.jsx`)
- Teacher dashboard → Scores and analytics: renders (evidence: `client/src/pages/TeacherDashboard.jsx`)
- Exam and course API → HTTP client: calls (evidence: `client/src/api/examService.js`)
- Exam and course API → Client mock data: falls back
- HTTP client → Express application: REST JSON
- Express application → Auth routes: mounts (evidence: `server/server.js`)
- Express application → Course routes: mounts (evidence: `server/server.js`)
- Express application → Exam routes: mounts (evidence: `server/server.js`)
- Express application → Submission routes: mounts (evidence: `server/server.js`)
- Express application → AI routes: mounts (evidence: `server/server.js`)
- Auth routes → Auth operations: dispatches (evidence: `server/routes/authRoutes.js`)
- Course routes → Course operations: dispatches (evidence: `server/routes/courseRoutes.js`)
- Exam routes → Exam operations: dispatches (evidence: `server/routes/examRoutes.js`)
- Submission routes → Submission and grading: dispatches (evidence: `server/routes/submissionRoutes.js`)
- AI routes → AI exam generation: dispatches (evidence: `server/routes/aiRoutes.js`)
- Auth routes → JWT role checks: protects routes (evidence: `server/routes/authRoutes.js`)
- Course routes → JWT role checks: protects routes (evidence: `server/routes/courseRoutes.js`)
- Exam routes → JWT role checks: protects routes (evidence: `server/routes/examRoutes.js`)
- Submission routes → JWT role checks: protects routes (evidence: `server/routes/submissionRoutes.js`)
- Auth operations → Database adapter: queries (evidence: `server/controllers/authController.js`)
- Course operations → Database adapter: queries (evidence: `server/controllers/courseController.js`)
- Exam operations → Database adapter: queries (evidence: `server/controllers/examController.js`)
- Submission and grading → Database adapter: queries (evidence: `server/controllers/submissionController.js`)
- Database adapter → JSON DB engine: selects backend (evidence: `server/config/db.js`)
- AI exam generation → Gemini AI: generates exams
