# luun0/trustexam-ideal-structure architecture

> Architecture diagram of the GitHub repository luun0/trustexam-ideal-structure, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/luun0/trustexam-ideal-structure
- Repository: https://github.com/luun0/trustexam-ideal-structure

## Overview

TrustExam is an online-proctoring application with student and proctor roles. Students join an exam, answer questions, share their screen and camera, and are monitored for violations; proctors monitor students, chat, record assessments, and review recordings. The frontend separates exam, monitoring, media, and socket concerns, while backend HTTP and socket entry points dispatch to application services and repositories. README documents additional grading and exam capabilities. Some frontend wiring and backend domain details are represented from README and the tree; those source files were not sampled.

Main entry points: [`back/application/StudentService.ts`](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/StudentService.ts) (Student Service), [`src/presentation/StudentExam.tsx`](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/StudentExam.tsx) (Exam UI), [`back/presentation/Routes.ts`](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/presentation/Routes.ts) (HTTP Routes), [`src/presentation/ProctorDashboard.tsx`](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/ProctorDashboard.tsx) (Proctor Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_student_ui["Student Experience"]
  node_app["Role Login<br/>[App.tsx]"]
  node_exam_ui["Exam UI<br/>[StudentExam.tsx]"]
  node_exam_hooks["Exam Controls"]
  node_proctoring["AI Proctoring<br/>[useProctoring.ts]"]
  node_recording_hook["Media Recording<br/>[useRecording.ts]"]
  node_student_api["Student API<br/>[studentApi.ts]"]
  node_recording_api["Recording API<br/>[recordingApi.ts]"]
end

subgraph group_proctor_ui["Proctor Experience"]
  node_proctor_ui["Proctor Dashboard"]
  node_proctor_hooks["Monitoring Socket"]
  node_chat_ui["Chat Views"]
  node_socket_client["Socket Client<br/>[socketClient.ts]"]
end

subgraph group_backend["Backend Runtime"]
  node_http_routes["HTTP Routes<br/>[Routes.ts]"]
  node_socket_handler["Socket Events<br/>[SocketHandler.ts]"]
  node_student_service["Student Service<br/>[StudentService.ts]"]
  node_recording_service["Recording Service"]
  node_domain_rules["Exam Rules"]
  node_broadcast["Student Broadcast"]
  node_ban_gateway["Ban Gateway<br/>[BanGateway.ts]"]
  node_server["Server Bootstrap<br/>[server.ts]"]
end

subgraph group_state["State and Storage"]
  node_repository_contracts["Repository Contracts<br/>[IRepositories.ts]"]
  node_student_store[("Student Store")]
  node_recording_store[("Recording Files")]
end

subgraph group_contracts["Shared Contracts"]
  node_shared["Shared Types"]
end

node_student(("Student"))
node_proctor(("Proctor"))
node_media_devices["Camera and Screen"]
node_ai_models["AI Model CDN"]

node_student -->|"signs in"| node_app
node_proctor -->|"signs in"| node_app
node_app -->|"opens exam"| node_exam_ui
node_app -->|"opens dashboard"| node_proctor_ui
node_exam_ui -->|"uses controls"| node_exam_hooks
node_exam_ui -->|"starts monitoring"| node_proctoring
node_exam_ui -->|"starts recording"| node_recording_hook
node_exam_ui -->|"submits answers"| node_student_api
node_exam_ui -->|"joins exam"| node_socket_client
node_recording_hook -->|"captures media"| node_media_devices
node_proctoring -->|"reads camera"| node_media_devices
node_proctoring -.->|"loads models"| node_ai_models
node_proctoring -->|"reports violations"| node_socket_client
node_recording_hook -->|"uploads chunks"| node_recording_api
node_proctor_ui -->|"uses monitoring"| node_proctor_hooks
node_proctor_ui -->|"updates students"| node_student_api
node_proctor_ui -->|"lists recordings"| node_recording_api
node_proctor_ui -->|"joins as proctor"| node_socket_client
node_chat_ui -->|"sends chat"| node_socket_client
node_student_api -->|"calls REST"| node_http_routes
node_recording_api -->|"calls REST"| node_http_routes
node_socket_client -->|"exchanges events"| node_socket_handler
node_server -->|"mounts routes"| node_http_routes
node_server -->|"registers events"| node_socket_handler
node_http_routes -->|"dispatches student actions"| node_student_service
node_http_routes -->|"dispatches recording actions"| node_recording_service
node_socket_handler -->|"dispatches student events"| node_student_service
node_student_service -->|"reads and writes"| node_student_store
node_student_service -->|"notifies updates"| node_broadcast
node_student_service -->|"requests bans"| node_ban_gateway
node_student_service -->|"grades answers"| node_domain_rules
node_recording_service -->|"reads and writes"| node_recording_store
node_recording_service -->|"updates recording state"| node_student_service
node_http_routes -->|"streams recordings"| node_recording_service
node_student_store -->|"implements"| node_repository_contracts
node_recording_store -->|"implements"| node_repository_contracts

click node_app "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/App.tsx"
click node_exam_ui "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/StudentExam.tsx"
click node_exam_hooks "https://github.com/luun0/trustexam-ideal-structure/tree/main/src/application/hooks"
click node_proctoring "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/hooks/useProctoring.ts"
click node_recording_hook "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/hooks/useRecording.ts"
click node_student_api "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/api/studentApi.ts"
click node_recording_api "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/api/recordingApi.ts"
click node_proctor_ui "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/ProctorDashboard.tsx"
click node_proctor_hooks "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/hooks/useProctorSocket.ts"
click node_chat_ui "https://github.com/luun0/trustexam-ideal-structure/tree/main/src/presentation"
click node_socket_client "https://github.com/luun0/trustexam-ideal-structure/blob/main/src/infrastructure/socketClient.ts"
click node_http_routes "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/presentation/Routes.ts"
click node_socket_handler "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/presentation/SocketHandler.ts"
click node_student_service "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/StudentService.ts"
click node_recording_service "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/RecordingService.ts"
click node_domain_rules "https://github.com/luun0/trustexam-ideal-structure/tree/main/back/domain"
click node_repository_contracts "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/repositories/IRepositories.ts"
click node_student_store "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/repositories/InMemoryStudentRepository.ts"
click node_recording_store "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/repositories/FileRecordingRepository.ts"
click node_broadcast "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/BroadcastNotifier.ts"
click node_ban_gateway "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/socket/BanGateway.ts"
click node_server "https://github.com/luun0/trustexam-ideal-structure/blob/main/back/server.ts"
click node_shared "https://github.com/luun0/trustexam-ideal-structure/tree/main/shared/types"

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_exam_ui,node_exam_hooks,node_proctoring,node_recording_hook,node_student_api,node_recording_api,node_media_devices toneBlue
class node_proctor_ui,node_proctor_hooks,node_chat_ui,node_socket_client toneAmber
class node_http_routes,node_socket_handler,node_student_service,node_recording_service,node_domain_rules,node_broadcast,node_ban_gateway,node_server toneMint
class node_repository_contracts,node_student_store,node_recording_store toneRose
class node_shared,node_student,node_proctor,node_ai_models toneIndigo
```

## Components

### Student Experience

- [Role Login](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/App.tsx): `src/presentation/App.tsx`
- [Exam UI](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/StudentExam.tsx): `src/presentation/StudentExam.tsx`
- [Exam Controls](https://github.com/luun0/trustexam-ideal-structure/tree/main/src/application/hooks): `src/application/hooks`
- [AI Proctoring](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/hooks/useProctoring.ts): `src/application/hooks/useProctoring.ts`
- [Media Recording](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/hooks/useRecording.ts): `src/application/hooks/useRecording.ts`
- [Student API](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/api/studentApi.ts): `src/application/api/studentApi.ts`
- [Recording API](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/api/recordingApi.ts): `src/application/api/recordingApi.ts`

### Proctor Experience

- [Proctor Dashboard](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/presentation/ProctorDashboard.tsx): `src/presentation/ProctorDashboard.tsx`
- [Monitoring Socket](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/application/hooks/useProctorSocket.ts): `src/application/hooks/useProctorSocket.ts`
- [Chat Views](https://github.com/luun0/trustexam-ideal-structure/tree/main/src/presentation): `src/presentation`
- [Socket Client](https://github.com/luun0/trustexam-ideal-structure/blob/main/src/infrastructure/socketClient.ts): `src/infrastructure/socketClient.ts`

### Backend Runtime

- [HTTP Routes](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/presentation/Routes.ts): `back/presentation/Routes.ts`
- [Socket Events](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/presentation/SocketHandler.ts): `back/presentation/SocketHandler.ts`
- [Student Service](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/StudentService.ts): `back/application/StudentService.ts`
- [Recording Service](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/RecordingService.ts): `back/application/RecordingService.ts`
- [Exam Rules](https://github.com/luun0/trustexam-ideal-structure/tree/main/back/domain): `back/domain`
- [Student Broadcast](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/application/BroadcastNotifier.ts): `back/application/BroadcastNotifier.ts`
- [Ban Gateway](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/socket/BanGateway.ts): `back/infrastructure/socket/BanGateway.ts`
- [Server Bootstrap](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/server.ts): `back/server.ts`

### State and Storage

- [Repository Contracts](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/repositories/IRepositories.ts): `back/infrastructure/repositories/IRepositories.ts`
- [Student Store](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/repositories/InMemoryStudentRepository.ts): `back/infrastructure/repositories/InMemoryStudentRepository.ts`
- [Recording Files](https://github.com/luun0/trustexam-ideal-structure/blob/main/back/infrastructure/repositories/FileRecordingRepository.ts): `back/infrastructure/repositories/FileRecordingRepository.ts`

### Shared Contracts

- [Shared Types](https://github.com/luun0/trustexam-ideal-structure/tree/main/shared/types): `shared/types`

### Other components

- **Student**
- **Proctor**
- **Camera and Screen**
- **AI Model CDN**

## Connections

- Student → Role Login: signs in
- Proctor → Role Login: signs in
- Role Login → Exam UI: opens exam
- Role Login → Proctor Dashboard: opens dashboard
- Exam UI → Exam Controls: uses controls
- Exam UI → AI Proctoring: starts monitoring
- Exam UI → Media Recording: starts recording
- Exam UI → Student API: submits answers
- Exam UI → Socket Client: joins exam
- Media Recording → Camera and Screen: captures media
- AI Proctoring → Camera and Screen: reads camera
- AI Proctoring → AI Model CDN: loads models
- AI Proctoring → Socket Client: reports violations
- Media Recording → Recording API: uploads chunks
- Proctor Dashboard → Monitoring Socket: uses monitoring
- Proctor Dashboard → Student API: updates students
- Proctor Dashboard → Recording API: lists recordings
- Proctor Dashboard → Socket Client: joins as proctor
- Chat Views → Socket Client: sends chat
- Student API → HTTP Routes: calls REST
- Recording API → HTTP Routes: calls REST
- Socket Client → Socket Events: exchanges events
- Server Bootstrap → HTTP Routes: mounts routes
- Server Bootstrap → Socket Events: registers events
- HTTP Routes → Student Service: dispatches student actions
- HTTP Routes → Recording Service: dispatches recording actions
- Socket Events → Student Service: dispatches student events
- Student Service → Student Store: reads and writes
- Student Service → Student Broadcast: notifies updates
- Student Service → Ban Gateway: requests bans
- Student Service → Exam Rules: grades answers
- Recording Service → Recording Files: reads and writes
- Recording Service → Student Service: updates recording state
- HTTP Routes → Recording Service: streams recordings
- Student Store → Repository Contracts: implements
- Recording Files → Repository Contracts: implements
