# manglam620/autograder architecture

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

- Interactive diagram: https://gitdiagram.com/manglam620/autograder
- Repository: https://github.com/manglam620/autograder

## Overview

AutoGrader is a rule-driven C assignment and submission grading service. Teachers define policies, generate and review tests, then publish assignments; students submit C files, which enter a queued sandbox grading workflow and produce weighted, explainable reports. The graph preserves the documented analyzer stages and teacher/student capabilities. Some links are supported by README descriptions or the source index rather than complete call excerpts, so unsampled implementation details are not expanded.

Main entry points: [`backend/agents/grader.py`](https://github.com/manglam620/autograder/blob/main/backend/agents/grader.py) (Grading workflow), [`backend/server/main.py`](https://github.com/manglam620/autograder/blob/main/backend/server/main.py) (Assignment API), [`backend/server/storage.py`](https://github.com/manglam620/autograder/blob/main/backend/server/storage.py) (Assignment and submission store), [`backend/grading/analyzers/edge_cases.py`](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/edge_cases.py) (Edge-case checks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Assignment authoring"]
  node_teacher_ui["Teacher interface<br/>[app.js]"]
  node_test_review["Test review<br/>[review.js]"]
  node_test_generation["Test generation<br/>[testgen.py]"]
end

subgraph group_service["Web service"]
  node_assignment_api["Assignment API<br/>[main.py]"]
  node_student_ui["Student interface<br/>[student.js]"]
  node_submission_ui["Submission review<br/>[submissions.js]"]
  node_grading_jobs["Grading queue<br/>[jobs.py]"]
end

subgraph group_grading["Grading engine"]
  node_grading_graph["Grading workflow<br/>[grader.py]"]
  node_policy_validation["Policy validation<br/>[policy.py]"]
  node_first_pass["Compile and smoke check<br/>[first_pass.py]"]
  node_correctness["Correctness checks<br/>[correctness.py]"]
  node_edge_cases["Edge-case checks<br/>[edge_cases.py]"]
  node_compiler_analysis["Compiler analysis<br/>[compiler.py]"]
  node_source_analysis["Source analysis<br/>[structure.py]"]
  node_memory_analysis["Memory analysis<br/>[memory.py]"]
  node_complexity_analysis["Complexity analysis<br/>[complexity.py]"]
  node_readability_analysis["Readability and originality<br/>[readability.py]"]
  node_input_spec["Input specification<br/>[inputspec.py]"]
  node_output_compare["Output comparison<br/>[compare.py]"]
  node_scoring["Weighted scoring<br/>[scoring.py]"]
  node_reporting["Report generation<br/>[report.py]"]
end

subgraph group_execution["Execution and storage"]
  node_assignment_store[("Assignment and submission store<br/>[storage.py]")]
  node_execution_helpers["Execution jobs<br/>[execution.py]"]
  node_sandbox_service["Sandbox adapter<br/>[sandbox.py]"]
  node_sandbox_runner["Sandbox runner<br/>[runner.py]"]
end

node_teacher(("Teacher"))
node_student(("Student"))
node_ollama["Ollama<br/>external service"]

node_teacher -->|"authors assignment"| node_teacher_ui
node_teacher_ui -->|"manages assignments"| node_assignment_api
node_assignment_api -->|"stores assignment"| node_assignment_store
node_assignment_api -->|"validates policy"| node_policy_validation
node_assignment_api -->|"starts generation"| node_test_generation
node_test_generation -->|"updates generation state"| node_assignment_store
node_teacher -->|"reviews tests"| node_test_review
node_test_review -->|"accepts tests"| node_assignment_api
node_assignment_api -->|"queues submissions"| node_grading_jobs
node_student -->|"submits program"| node_student_ui
node_student_ui -->|"uploads source"| node_assignment_api
node_assignment_api -->|"saves submission"| node_assignment_store
node_grading_jobs -->|"runs grading"| node_grading_graph
node_grading_graph -->|"validates rules"| node_policy_validation
node_grading_graph -->|"checks submission"| node_first_pass
node_grading_graph -->|"runs stage"| node_correctness
node_grading_graph -->|"runs stage"| node_edge_cases
node_grading_graph -->|"runs stage"| node_compiler_analysis
node_grading_graph -->|"runs stage"| node_source_analysis
node_grading_graph -->|"runs stage"| node_memory_analysis
node_grading_graph -->|"runs stage"| node_complexity_analysis
node_grading_graph -->|"runs review"| node_readability_analysis
node_edge_cases -->|"reuses test runs"| node_correctness
node_edge_cases -->|"builds test inputs"| node_input_spec
node_complexity_analysis -->|"scales inputs"| node_input_spec
node_edge_cases -->|"compares outputs"| node_output_compare
node_complexity_analysis -->|"runs measurements"| node_execution_helpers
node_memory_analysis -->|"requests sandbox runs"| node_execution_helpers
node_first_pass -->|"compiles and runs"| node_execution_helpers
node_execution_helpers -->|"submits job"| node_sandbox_service
node_sandbox_service -->|"dispatches job"| node_sandbox_runner
node_grading_graph -->|"aggregates results"| node_scoring
node_grading_graph -->|"writes reports"| node_reporting
node_grading_graph -->|"loads grading data"| node_assignment_store
node_reporting -->|"stores reports"| node_assignment_store
node_student -->|"views results"| node_student_ui
node_teacher -->|"reviews submissions"| node_submission_ui
node_submission_ui -->|"requests reports"| node_assignment_api
node_test_generation -.->|"generates with"| node_ollama
node_readability_analysis -.->|"requests review"| node_ollama
node_ollama -.-> node_test_generation

click node_teacher_ui "https://github.com/manglam620/autograder/blob/main/frontend/app.js"
click node_test_review "https://github.com/manglam620/autograder/blob/main/frontend/review.js"
click node_test_generation "https://github.com/manglam620/autograder/blob/main/backend/agents/testgen.py"
click node_assignment_api "https://github.com/manglam620/autograder/blob/main/backend/server/main.py"
click node_student_ui "https://github.com/manglam620/autograder/blob/main/frontend/student.js"
click node_submission_ui "https://github.com/manglam620/autograder/blob/main/frontend/submissions.js"
click node_grading_jobs "https://github.com/manglam620/autograder/blob/main/backend/server/jobs.py"
click node_assignment_store "https://github.com/manglam620/autograder/blob/main/backend/server/storage.py"
click node_grading_graph "https://github.com/manglam620/autograder/blob/main/backend/agents/grader.py"
click node_policy_validation "https://github.com/manglam620/autograder/blob/main/backend/grading/policy.py"
click node_first_pass "https://github.com/manglam620/autograder/blob/main/backend/grading/first_pass.py"
click node_correctness "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/correctness.py"
click node_edge_cases "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/edge_cases.py"
click node_compiler_analysis "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/compiler.py"
click node_source_analysis "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/structure.py"
click node_memory_analysis "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/memory.py"
click node_complexity_analysis "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/complexity.py"
click node_readability_analysis "https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/readability.py"
click node_input_spec "https://github.com/manglam620/autograder/blob/main/backend/grading/inputspec.py"
click node_output_compare "https://github.com/manglam620/autograder/blob/main/backend/grading/compare.py"
click node_execution_helpers "https://github.com/manglam620/autograder/blob/main/backend/grading/execution.py"
click node_sandbox_service "https://github.com/manglam620/autograder/blob/main/backend/server/sandbox.py"
click node_sandbox_runner "https://github.com/manglam620/autograder/blob/main/sandbox/runner.py"
click node_scoring "https://github.com/manglam620/autograder/blob/main/backend/grading/scoring.py"
click node_reporting "https://github.com/manglam620/autograder/blob/main/backend/grading/report.py"

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_teacher_ui,node_test_review,node_test_generation toneBlue
class node_assignment_api,node_student_ui,node_submission_ui,node_grading_jobs toneAmber
class node_grading_graph,node_policy_validation,node_first_pass,node_correctness,node_edge_cases,node_compiler_analysis,node_source_analysis,node_memory_analysis,node_complexity_analysis,node_readability_analysis,node_input_spec,node_output_compare,node_scoring,node_reporting toneMint
class node_assignment_store,node_execution_helpers,node_sandbox_service,node_sandbox_runner toneRose
class node_teacher,node_student,node_ollama toneIndigo
```

## Components

### Assignment authoring

- [Teacher interface](https://github.com/manglam620/autograder/blob/main/frontend/app.js): `frontend/app.js`
- [Test review](https://github.com/manglam620/autograder/blob/main/frontend/review.js): `frontend/review.js`
- [Test generation](https://github.com/manglam620/autograder/blob/main/backend/agents/testgen.py): `backend/agents/testgen.py`

### Web service

- [Assignment API](https://github.com/manglam620/autograder/blob/main/backend/server/main.py): `backend/server/main.py`
- [Student interface](https://github.com/manglam620/autograder/blob/main/frontend/student.js): `frontend/student.js`
- [Submission review](https://github.com/manglam620/autograder/blob/main/frontend/submissions.js): `frontend/submissions.js`
- [Grading queue](https://github.com/manglam620/autograder/blob/main/backend/server/jobs.py): `backend/server/jobs.py`

### Grading engine

- [Grading workflow](https://github.com/manglam620/autograder/blob/main/backend/agents/grader.py): `backend/agents/grader.py`
- [Policy validation](https://github.com/manglam620/autograder/blob/main/backend/grading/policy.py): `backend/grading/policy.py`
- [Compile and smoke check](https://github.com/manglam620/autograder/blob/main/backend/grading/first_pass.py): `backend/grading/first_pass.py`
- [Correctness checks](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/correctness.py): `backend/grading/analyzers/correctness.py`
- [Edge-case checks](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/edge_cases.py): `backend/grading/analyzers/edge_cases.py`
- [Compiler analysis](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/compiler.py): `backend/grading/analyzers/compiler.py`
- [Source analysis](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/structure.py): `backend/grading/analyzers/structure.py`
- [Memory analysis](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/memory.py): `backend/grading/analyzers/memory.py`
- [Complexity analysis](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/complexity.py): `backend/grading/analyzers/complexity.py`
- [Readability and originality](https://github.com/manglam620/autograder/blob/main/backend/grading/analyzers/readability.py): `backend/grading/analyzers/readability.py`
- [Input specification](https://github.com/manglam620/autograder/blob/main/backend/grading/inputspec.py): `backend/grading/inputspec.py`
- [Output comparison](https://github.com/manglam620/autograder/blob/main/backend/grading/compare.py): `backend/grading/compare.py`
- [Weighted scoring](https://github.com/manglam620/autograder/blob/main/backend/grading/scoring.py): `backend/grading/scoring.py`
- [Report generation](https://github.com/manglam620/autograder/blob/main/backend/grading/report.py): `backend/grading/report.py`

### Execution and storage

- [Assignment and submission store](https://github.com/manglam620/autograder/blob/main/backend/server/storage.py): `backend/server/storage.py`
- [Execution jobs](https://github.com/manglam620/autograder/blob/main/backend/grading/execution.py): `backend/grading/execution.py`
- [Sandbox adapter](https://github.com/manglam620/autograder/blob/main/backend/server/sandbox.py): `backend/server/sandbox.py`
- [Sandbox runner](https://github.com/manglam620/autograder/blob/main/sandbox/runner.py): `sandbox/runner.py`

### Other components

- **Teacher**
- **Student**
- **Ollama**: external service

## Connections

- Teacher → Teacher interface: authors assignment (evidence: `README.md`)
- Teacher interface → Assignment API: manages assignments (evidence: `README.md`)
- Assignment API → Assignment and submission store: stores assignment (evidence: `backend/server/main.py`)
- Assignment API → Policy validation: validates policy (evidence: `backend/server/main.py`)
- Assignment API → Test generation: starts generation (evidence: `backend/server/main.py`)
- Test generation → Assignment and submission store: updates generation state (evidence: `README.md`)
- Teacher → Test review: reviews tests (evidence: `README.md`)
- Test review → Assignment API: accepts tests (evidence: `README.md`)
- Assignment API → Grading queue: queues submissions (evidence: `backend/server/main.py`)
- Student → Student interface: submits program (evidence: `README.md`)
- Student interface → Assignment API: uploads source (evidence: `backend/server/main.py`)
- Assignment API → Assignment and submission store: saves submission (evidence: `backend/server/main.py`)
- Grading queue → Grading workflow: runs grading (evidence: `backend/server/jobs.py`)
- Grading workflow → Policy validation: validates rules (evidence: `backend/agents/grader.py`)
- Grading workflow → Compile and smoke check: checks submission (evidence: `README.md`)
- Grading workflow → Correctness checks: runs stage (evidence: `README.md`)
- Grading workflow → Edge-case checks: runs stage (evidence: `README.md`)
- Grading workflow → Compiler analysis: runs stage (evidence: `README.md`)
- Grading workflow → Source analysis: runs stage (evidence: `README.md`)
- Grading workflow → Memory analysis: runs stage (evidence: `README.md`)
- Grading workflow → Complexity analysis: runs stage (evidence: `README.md`)
- Grading workflow → Readability and originality: runs review (evidence: `README.md`)
- Edge-case checks → Correctness checks: reuses test runs (evidence: `backend/grading/analyzers/edge_cases.py`)
- Edge-case checks → Input specification: builds test inputs (evidence: `backend/grading/analyzers/edge_cases.py`)
- Complexity analysis → Input specification: scales inputs (evidence: `backend/grading/analyzers/complexity.py`)
- Edge-case checks → Output comparison: compares outputs (evidence: `backend/grading/analyzers/edge_cases.py`)
- Complexity analysis → Execution jobs: runs measurements (evidence: `backend/grading/analyzers/complexity.py`)
- Memory analysis → Execution jobs: requests sandbox runs (evidence: `backend/grading/analyzers/memory.py`)
- Compile and smoke check → Execution jobs: compiles and runs (evidence: `backend/grading/first_pass.py`)
- Execution jobs → Sandbox adapter: submits job (evidence: `backend/grading/execution.py`)
- Sandbox adapter → Sandbox runner: dispatches job (evidence: `README.md`)
- Grading workflow → Weighted scoring: aggregates results (evidence: `backend/agents/grader.py`)
- Grading workflow → Report generation: writes reports (evidence: `backend/agents/grader.py`)
- Grading workflow → Assignment and submission store: loads grading data (evidence: `backend/server/jobs.py`)
- Report generation → Assignment and submission store: stores reports (evidence: `README.md`)
- Student → Student interface: views results (evidence: `README.md`)
- Teacher → Submission review: reviews submissions (evidence: `README.md`)
- Submission review → Assignment API: requests reports (evidence: `README.md`)
- Test generation → Ollama: generates with (evidence: `README.md`)
- Readability and originality → Ollama: requests review (evidence: `README.md`)
- Ollama → Test generation
