# mithilesh-24/pet-application architecture

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

- Interactive diagram: https://gitdiagram.com/mithilesh-24/pet-application
- Repository: https://github.com/mithilesh-24/pet-application

## Overview

PET Prep is a local-first mock-exam platform. Students import encrypted or draft papers, start a timed forward-only exam, answer MCQs and code questions in a native OS sandbox, then review scores, analytics, and attempt history. The graph follows the documented workflow and preserves the paper, exam, execution, results, and settings capabilities. Evidence is limited to the supplied excerpts, SOURCE INDEX references, and README; unsampled subsystem links are omitted where their callers are not shown.

Main entry points: [`frontend/src/App.jsx`](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/App.jsx) (Page routing), [`backend/server.js`](https://github.com/mithilesh-24/pet-application/blob/main/backend/server.js) (HTTP server), [`frontend/src/services/apiClient.js`](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/services/apiClient.js) (API client), [`backend/services/paperImportService.js`](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/paperImportService.js) (Paper import)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Student experience"]
  node_app["Page routing<br/>[App.jsx]"]
  node_home["Home and prompts<br/>[Home.jsx]"]
  node_upload["Paper upload<br/>[Upload.jsx]"]
  node_examui["Exam workspace<br/>[Exam.jsx]"]
  node_codingui["Coding workspace"]
  node_historyui["Attempt history<br/>[History.jsx]"]
  node_resultsui["Results review<br/>[Results.jsx]"]
  node_settingsui["Settings and syllabus<br/>[Settings.jsx]"]
  node_api["API client<br/>[apiClient.js]"]
end

subgraph group_papers["Paper management"]
  node_paperroute["Paper routes<br/>[paperRoutes.js]"]
  node_importer["Paper import"]
  node_validator["Question validation"]
  node_crypto["Paper encryption"]
  node_keys["Key store<br/>[keyStore.js]"]
end

subgraph group_exam["Exam and scoring"]
  node_examroute["Exam routes<br/>[examRoutes.js]"]
  node_engine["Exam engine<br/>[examEngine.js]"]
  node_judge["Code judging<br/>[judgeService.js]"]
  node_evaluation["Evaluation"]
  node_results["Results service<br/>[resultService.js]"]
  node_history["History service<br/>[historyService.js]"]
end

subgraph group_execution["Code execution"]
  node_execution["Execution engine<br/>[executionEngine.js]"]
  node_runner["Language runners<br/>[languageRunner.js]"]
  node_sandbox["Sandbox driver<br/>[sandboxDriver.js]"]
  node_detector["Compiler detection"]
end

subgraph group_platform["Local platform"]
  node_server["HTTP server<br/>[server.js]"]
  node_database[("SQLite database<br/>[database.js]")]
  node_repositories["Data repositories<br/>[repositories.js]"]
  node_config["Runtime config<br/>[config.js]"]
end

node_student(("Student"))

node_student -->|"uses"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_upload
node_app -->|"routes to"| node_examui
node_app -->|"routes to"| node_historyui
node_app -->|"routes to"| node_resultsui
node_app -->|"routes to"| node_settingsui
node_home -.->|"generates prompts"| node_student
node_upload -.->|"sends upload"| node_api
node_api -.->|"requests API"| node_paperroute
node_paperroute -->|"imports paper"| node_importer
node_importer -->|"validates questions"| node_validator
node_importer -->|"encrypts paper"| node_crypto
node_importer -->|"uses keys"| node_keys
node_examui -->|"calls exam API"| node_api
node_examui -->|"renders"| node_codingui
node_api -.->|"requests API"| node_examroute
node_examroute -->|"dispatches exam actions"| node_engine
node_examroute -->|"dispatches code actions"| node_judge
node_judge -->|"runs submissions"| node_execution
node_engine -->|"decrypts paper"| node_crypto
node_codingui -.->|"submits code"| node_student
node_execution -->|"selects runner"| node_runner
node_execution -->|"dispatches execution"| node_sandbox
node_sandbox -.->|"isolates code"| node_student
node_detector -->|"checks sandbox"| node_sandbox
node_historyui -->|"loads attempts"| node_api
node_resultsui -->|"loads results"| node_api
node_server -->|"creates engine"| node_engine
node_server -->|"creates service"| node_evaluation
node_server -->|"creates service"| node_results
node_server -->|"opens database"| node_database
node_server -->|"loads repositories"| node_repositories
node_server -->|"configures execution"| node_execution
node_database -->|"reads storage config"| node_config
node_evaluation -.->|"evaluates for"| node_results
node_results -.->|"supports attempt review"| node_history

click node_app "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Home.jsx"
click node_upload "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Upload.jsx"
click node_examui "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Exam.jsx"
click node_codingui "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/components/CodingWorkspace.jsx"
click node_historyui "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/History.jsx"
click node_resultsui "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Results.jsx"
click node_settingsui "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Settings.jsx"
click node_api "https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/services/apiClient.js"
click node_paperroute "https://github.com/mithilesh-24/pet-application/blob/main/backend/routes/paperRoutes.js"
click node_importer "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/paperImportService.js"
click node_validator "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/questionValidator.js"
click node_crypto "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/encryptionService.js"
click node_keys "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/keyStore.js"
click node_examroute "https://github.com/mithilesh-24/pet-application/blob/main/backend/routes/examRoutes.js"
click node_engine "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/examEngine.js"
click node_judge "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/judgeService.js"
click node_evaluation "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/evaluationService.js"
click node_results "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/resultService.js"
click node_history "https://github.com/mithilesh-24/pet-application/blob/main/backend/services/historyService.js"
click node_execution "https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/executionEngine.js"
click node_runner "https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/languageRunner.js"
click node_sandbox "https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/sandbox/sandboxDriver.js"
click node_detector "https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/compilerDetector.js"
click node_server "https://github.com/mithilesh-24/pet-application/blob/main/backend/server.js"
click node_database "https://github.com/mithilesh-24/pet-application/blob/main/backend/database/database.js"
click node_repositories "https://github.com/mithilesh-24/pet-application/blob/main/backend/database/repositories.js"
click node_config "https://github.com/mithilesh-24/pet-application/blob/main/backend/config.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_home,node_upload,node_examui,node_codingui,node_historyui,node_resultsui,node_settingsui,node_api toneBlue
class node_paperroute,node_importer,node_validator,node_crypto,node_keys toneAmber
class node_examroute,node_engine,node_judge,node_evaluation,node_results,node_history toneMint
class node_execution,node_runner,node_sandbox,node_detector toneRose
class node_server,node_database,node_repositories,node_config,node_student toneIndigo
```

## Components

### Student experience

- [Page routing](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Home and prompts](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [Paper upload](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Upload.jsx): `frontend/src/pages/Upload.jsx`
- [Exam workspace](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Exam.jsx): `frontend/src/pages/Exam.jsx`
- [Coding workspace](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/components/CodingWorkspace.jsx): `frontend/src/components/CodingWorkspace.jsx`
- [Attempt history](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/History.jsx): `frontend/src/pages/History.jsx`
- [Results review](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Results.jsx): `frontend/src/pages/Results.jsx`
- [Settings and syllabus](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/pages/Settings.jsx): `frontend/src/pages/Settings.jsx`
- [API client](https://github.com/mithilesh-24/pet-application/blob/main/frontend/src/services/apiClient.js): `frontend/src/services/apiClient.js`

### Paper management

- [Paper routes](https://github.com/mithilesh-24/pet-application/blob/main/backend/routes/paperRoutes.js): `backend/routes/paperRoutes.js`
- [Paper import](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/paperImportService.js): `backend/services/paperImportService.js`
- [Question validation](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/questionValidator.js): `backend/services/questionValidator.js`
- [Paper encryption](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/encryptionService.js): `backend/services/encryptionService.js`
- [Key store](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/keyStore.js): `backend/services/keyStore.js`

### Exam and scoring

- [Exam routes](https://github.com/mithilesh-24/pet-application/blob/main/backend/routes/examRoutes.js): `backend/routes/examRoutes.js`
- [Exam engine](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/examEngine.js): `backend/services/examEngine.js`
- [Code judging](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/judgeService.js): `backend/services/judgeService.js`
- [Evaluation](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/evaluationService.js): `backend/services/evaluationService.js`
- [Results service](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/resultService.js): `backend/services/resultService.js`
- [History service](https://github.com/mithilesh-24/pet-application/blob/main/backend/services/historyService.js): `backend/services/historyService.js`

### Code execution

- [Execution engine](https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/executionEngine.js): `backend/compiler/executionEngine.js`
- [Language runners](https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/languageRunner.js): `backend/compiler/languageRunner.js`
- [Sandbox driver](https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/sandbox/sandboxDriver.js): `backend/compiler/sandbox/sandboxDriver.js`
- [Compiler detection](https://github.com/mithilesh-24/pet-application/blob/main/backend/compiler/compilerDetector.js): `backend/compiler/compilerDetector.js`

### Local platform

- [HTTP server](https://github.com/mithilesh-24/pet-application/blob/main/backend/server.js): `backend/server.js`
- [SQLite database](https://github.com/mithilesh-24/pet-application/blob/main/backend/database/database.js): `backend/database/database.js`
- [Data repositories](https://github.com/mithilesh-24/pet-application/blob/main/backend/database/repositories.js): `backend/database/repositories.js`
- [Runtime config](https://github.com/mithilesh-24/pet-application/blob/main/backend/config.js): `backend/config.js`

### Other components

- **Student**

## Connections

- Student → Page routing: uses
- Page routing → Home and prompts: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Paper upload: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Exam workspace: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Attempt history: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Results review: routes to (evidence: `frontend/src/App.jsx`)
- Page routing → Settings and syllabus: routes to (evidence: `frontend/src/App.jsx`)
- Home and prompts → Student: generates prompts
- Paper upload → API client: sends upload
- API client → Paper routes: requests API
- Paper routes → Paper import: imports paper (evidence: `backend/routes/paperRoutes.js`)
- Paper import → Question validation: validates questions (evidence: `backend/services/paperImportService.js`)
- Paper import → Paper encryption: encrypts paper (evidence: `backend/services/paperImportService.js`)
- Paper import → Key store: uses keys (evidence: `backend/services/paperImportService.js`)
- Exam workspace → API client: calls exam API (evidence: `frontend/src/pages/Exam.jsx`)
- Exam workspace → Coding workspace: renders (evidence: `frontend/src/pages/Exam.jsx`)
- API client → Exam routes: requests API
- Exam routes → Exam engine: dispatches exam actions (evidence: `backend/routes/examRoutes.js`)
- Exam routes → Code judging: dispatches code actions (evidence: `backend/routes/examRoutes.js`)
- Code judging → Execution engine: runs submissions (evidence: `backend/services/judgeService.js`)
- Exam engine → Paper encryption: decrypts paper (evidence: `backend/services/examEngine.js`)
- Coding workspace → Student: submits code
- Execution engine → Language runners: selects runner (evidence: `backend/compiler/executionEngine.js`)
- Execution engine → Sandbox driver: dispatches execution (evidence: `backend/compiler/executionEngine.js`)
- Sandbox driver → Student: isolates code
- Compiler detection → Sandbox driver: checks sandbox (evidence: `backend/compiler/compilerDetector.js`)
- Attempt history → API client: loads attempts (evidence: `frontend/src/pages/History.jsx`)
- Results review → API client: loads results (evidence: `frontend/src/pages/Results.jsx`)
- HTTP server → Exam engine: creates engine (evidence: `backend/server.js`)
- HTTP server → Evaluation: creates service (evidence: `backend/server.js`)
- HTTP server → Results service: creates service (evidence: `backend/server.js`)
- HTTP server → SQLite database: opens database (evidence: `backend/server.js`)
- HTTP server → Data repositories: loads repositories (evidence: `backend/server.js`)
- HTTP server → Execution engine: configures execution (evidence: `backend/server.js`)
- SQLite database → Runtime config: reads storage config (evidence: `backend/database/database.js`)
- Evaluation → Results service: evaluates for
- Results service → History service: supports attempt review
