# ajay-1011-git/copyzero architecture

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

- Interactive diagram: https://gitdiagram.com/ajay-1011-git/copyzero
- Repository: https://github.com/ajay-1011-git/copyzero

## Overview

CopyZero is a dual-role academic integrity platform. Professors create assignments and timed assessments; students join with codes, submit work or take exams, and professors review evaluation results. Assessments add question generation, browser-side code execution, and live proctoring; assignment evaluation combines plagiarism, AI-text, and rubric signals, with professor confirmation before scores persist. The graph reflects documented capabilities and sampled routing/controller behavior; some route-to-controller wiring and unsampled subsystem details are represented only at the supported subsystem level.

Main entry points: [`backend/src/services/databaseService.js`](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/databaseService.js) (Firestore access), [`frontend/src/services/api.js`](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/services/api.js) (API client), [`backend/src/routes/studentRoutes.js`](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/routes/studentRoutes.js) (Student routes), [`backend/src/routes/professorRoutes.js`](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/routes/professorRoutes.js) (Professor routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_app["Role-based UI<br/>[App.jsx]"]
  node_authui["Sign-in context<br/>[AuthContext.jsx]"]
  node_api["API client<br/>[api.js]"]
  node_assignmentui["Assignment pages"]
  node_studentui["Student pages"]
  node_examui["Assessment pages<br/>[TakeAssessment.jsx]"]
  node_codeexec["Browser code runner"]
  node_proctorui["Proctoring monitor<br/>[useProctoring.js]"]
end

subgraph group_assignment["Assignments"]
  node_assignroutes["Professor routes<br/>[professorRoutes.js]"]
  node_studentroutes["Student routes<br/>[studentRoutes.js]"]
  node_assignments["Assignment management"]
  node_enrollment["Code enrollment"]
  node_submissions["Assignment submissions"]
end

subgraph group_assessment["Assessments"]
  node_assessments["Assessment lifecycle"]
  node_attempts["Exam attempts"]
  node_questiongen["Question generation"]
end

subgraph group_integrity["Integrity and AI"]
  node_evaluation["Score review"]
  node_ai_eval["AI evaluation"]
  node_ai_service["AI provider logic"]
  node_events["Proctor events<br/>[eventController.js]"]
  node_integrityscore["Integrity scoring"]
end

subgraph group_platform["Backend platform"]
  node_server["Express API<br/>[server.js]"]
  node_auth["Auth middleware<br/>[auth.js]"]
  node_dbservice["Firestore access<br/>[databaseService.js]"]
  node_firestore[("Firestore")]
  node_firebaseauth["Firebase Auth"]
end

node_professor(("Professor"))
node_student(("Student"))
node_groq["Groq AI"]
node_nimhf["NIM / HuggingFace"]

node_professor -->|"uses"| node_app
node_student -->|"uses"| node_app
node_app -->|"provides auth"| node_authui
node_authui -->|"authenticates"| node_firebaseauth
node_assignmentui -->|"requests"| node_api
node_studentui -->|"requests"| node_api
node_examui -->|"requests"| node_api
node_api -->|"sends requests"| node_server
node_server -->|"mounts"| node_assignroutes
node_server -->|"mounts"| node_studentroutes
node_assignroutes -->|"dispatches"| node_assignments
node_assignroutes -->|"dispatches"| node_evaluation
node_assignroutes -->|"dispatches"| node_ai_eval
node_studentroutes -->|"dispatches"| node_enrollment
node_studentroutes -->|"dispatches"| node_submissions
node_studentroutes -->|"dispatches"| node_assessments
node_studentroutes -->|"dispatches"| node_attempts
node_assignments -->|"reads / writes"| node_dbservice
node_enrollment -->|"reads / writes"| node_dbservice
node_submissions -->|"reads / writes"| node_dbservice
node_evaluation -->|"persists scores"| node_dbservice
node_assessments -->|"reads / writes"| node_dbservice
node_attempts -->|"reads / writes"| node_dbservice
node_dbservice -->|"accesses"| node_firestore
node_auth -->|"verifies tokens"| node_firebaseauth
node_server -->|"guards API"| node_auth
node_ai_eval -->|"evaluates"| node_ai_service
node_ai_service -->|"calls"| node_groq
node_ai_service -.->|"fallback calls"| node_nimhf
node_assessments -->|"generates questions"| node_questiongen
node_questiongen -.->|"calls"| node_groq
node_examui -->|"runs code"| node_codeexec
node_examui -->|"monitors exam"| node_proctorui
node_proctorui -->|"uploads evidence"| node_api
node_api -->|"posts events"| node_events
node_events -->|"records events"| node_dbservice
node_integrityscore -->|"reads / writes"| node_dbservice

click node_app "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/context/AuthContext.jsx"
click node_api "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/services/api.js"
click node_assignmentui "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/pages/professor/CreateAssignment.jsx"
click node_studentui "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/pages/student/SubmitAssignment.jsx"
click node_examui "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/pages/student/TakeAssessment.jsx"
click node_codeexec "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/services/codeExecutionService.js"
click node_proctorui "https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/hooks/useProctoring.js"
click node_assignroutes "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/routes/professorRoutes.js"
click node_studentroutes "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/routes/studentRoutes.js"
click node_assignments "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/assignmentController.js"
click node_enrollment "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/enrollmentController.js"
click node_submissions "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/submissionController.js"
click node_evaluation "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/evaluationController.js"
click node_ai_eval "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/groqEvaluationController.js"
click node_ai_service "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/aiProviderService.js"
click node_assessments "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/assessmentController.js"
click node_attempts "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/assessmentSubmissionController.js"
click node_questiongen "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/questionGenerationService.js"
click node_events "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/eventController.js"
click node_integrityscore "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/integrityScoreService.js"
click node_server "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/server.js"
click node_auth "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/middleware/auth.js"
click node_dbservice "https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/databaseService.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_authui,node_api,node_assignmentui,node_studentui,node_examui,node_codeexec,node_proctorui toneBlue
class node_assignroutes,node_studentroutes,node_assignments,node_enrollment,node_submissions toneAmber
class node_assessments,node_attempts,node_questiongen toneMint
class node_evaluation,node_ai_eval,node_ai_service,node_events,node_integrityscore toneRose
class node_server,node_auth,node_dbservice,node_firestore,node_firebaseauth,node_professor,node_student,node_groq,node_nimhf toneIndigo
```

## Components

### Web application

- [Role-based UI](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in context](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [API client](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Assignment pages](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/pages/professor/CreateAssignment.jsx): `frontend/src/pages/professor/CreateAssignment.jsx`
- [Student pages](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/pages/student/SubmitAssignment.jsx): `frontend/src/pages/student/SubmitAssignment.jsx`
- [Assessment pages](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/pages/student/TakeAssessment.jsx): `frontend/src/pages/student/TakeAssessment.jsx`
- [Browser code runner](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/services/codeExecutionService.js): `frontend/src/services/codeExecutionService.js`
- [Proctoring monitor](https://github.com/ajay-1011-git/copyzero/blob/main/frontend/src/hooks/useProctoring.js): `frontend/src/hooks/useProctoring.js`

### Assignments

- [Professor routes](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/routes/professorRoutes.js): `backend/src/routes/professorRoutes.js`
- [Student routes](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/routes/studentRoutes.js): `backend/src/routes/studentRoutes.js`
- [Assignment management](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/assignmentController.js): `backend/src/controllers/assignmentController.js`
- [Code enrollment](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/enrollmentController.js): `backend/src/controllers/enrollmentController.js`
- [Assignment submissions](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/submissionController.js): `backend/src/controllers/submissionController.js`

### Assessments

- [Assessment lifecycle](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/assessmentController.js): `backend/src/controllers/assessmentController.js`
- [Exam attempts](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/assessmentSubmissionController.js): `backend/src/controllers/assessmentSubmissionController.js`
- [Question generation](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/questionGenerationService.js): `backend/src/services/questionGenerationService.js`

### Integrity and AI

- [Score review](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/evaluationController.js): `backend/src/controllers/evaluationController.js`
- [AI evaluation](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/groqEvaluationController.js): `backend/src/controllers/groqEvaluationController.js`
- [AI provider logic](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/aiProviderService.js): `backend/src/services/aiProviderService.js`
- [Proctor events](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/controllers/eventController.js): `backend/src/controllers/eventController.js`
- [Integrity scoring](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/integrityScoreService.js): `backend/src/services/integrityScoreService.js`

### Backend platform

- [Express API](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/server.js): `backend/src/server.js`
- [Auth middleware](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Firestore access](https://github.com/ajay-1011-git/copyzero/blob/main/backend/src/services/databaseService.js): `backend/src/services/databaseService.js`
- **Firestore**
- **Firebase Auth**

### Other components

- **Professor**
- **Student**
- **Groq AI**
- **NIM / HuggingFace**

## Connections

- Professor → Role-based UI: uses
- Student → Role-based UI: uses
- Role-based UI → Sign-in context: provides auth
- Sign-in context → Firebase Auth: authenticates
- Assignment pages → API client: requests
- Student pages → API client: requests
- Assessment pages → API client: requests
- API client → Express API: sends requests
- Express API → Professor routes: mounts
- Express API → Student routes: mounts
- Professor routes → Assignment management: dispatches
- Professor routes → Score review: dispatches
- Professor routes → AI evaluation: dispatches
- Student routes → Code enrollment: dispatches
- Student routes → Assignment submissions: dispatches
- Student routes → Assessment lifecycle: dispatches
- Student routes → Exam attempts: dispatches
- Assignment management → Firestore access: reads / writes
- Code enrollment → Firestore access: reads / writes
- Assignment submissions → Firestore access: reads / writes
- Score review → Firestore access: persists scores
- Assessment lifecycle → Firestore access: reads / writes
- Exam attempts → Firestore access: reads / writes
- Firestore access → Firestore: accesses
- Auth middleware → Firebase Auth: verifies tokens
- Express API → Auth middleware: guards API
- AI evaluation → AI provider logic: evaluates
- AI provider logic → Groq AI: calls
- AI provider logic → NIM / HuggingFace: fallback calls
- Assessment lifecycle → Question generation: generates questions
- Question generation → Groq AI: calls
- Assessment pages → Browser code runner: runs code
- Assessment pages → Proctoring monitor: monitors exam
- Proctoring monitor → API client: uploads evidence
- API client → Proctor events: posts events
- Proctor events → Firestore access: records events
- Integrity scoring → Firestore access: reads / writes
