# albertoreyescastro/modelhawk architecture

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

- Interactive diagram: https://gitdiagram.com/albertoreyescastro/modelhawk
- Repository: https://github.com/albertoreyescastro/modelhawk

## Overview

ModelHawk is a web application for static technical audits of uploaded Jupyter notebooks. The main workflow accepts a notebook in the upload UI, returns deterministic findings and scores, optionally adds examiner narrative, and can render the result as a PDF. The README also describes report contents and a sample audit. Source excerpts show the audit-to-heuristics call and PDF UI request; the UI-to-audit and UI-to-AI request wiring is not visible in the supplied excerpts, so those edges are omitted. The PDF route’s internal rendering and external provider details are summarized from README documentation where applicable.

Main entry points: [`app/api/report/pdf/route.ts`](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/report/pdf/route.ts) (PDF report generator), [`app/api/audit/route.ts`](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/route.ts) (Notebook audit API), [`app/api/audit/ai/route.ts`](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/ai/route.ts) (Examiner narrative API), [`app/upload/page.tsx`](https://github.com/albertoreyescastro/modelhawk/blob/main/app/upload/page.tsx) (PDF request UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_landing["Product overview<br/>[page.tsx]"]
  node_upload["Upload and results UI<br/>[page.tsx]"]
  node_pdf_ui["PDF request UI<br/>[page.tsx]"]
  node_demo["Sample audit page<br/>[page.tsx]"]
  node_layout["Application shell<br/>[layout.tsx]"]
end

subgraph group_audit["Deterministic audit"]
  node_audit_api["Notebook audit API<br/>[route.ts]"]
  node_heuristics["ML rule detectors"]
  node_structured_result["Structured audit<br/>[route.ts]"]
end

subgraph group_reporting["Examiner and reports"]
  node_examiner_api["Examiner narrative API<br/>[route.ts]"]
  node_narrative["Examiner guidance<br/>[route.ts]"]
  node_pdf_api["PDF report generator<br/>[route.ts]"]
  node_pdf["Generated PDF<br/>[route.ts]"]
end

subgraph group_ops["Service operations"]
  node_health["Health endpoint<br/>[route.ts]"]
end

node_user(("Notebook reviewer"))
node_provider{{"Optional AI provider"}}
node_latex{{"LaTeX engine"}}

node_user -->|"views"| node_landing
node_user -->|"submits notebook"| node_upload
node_audit_api -->|"calls detectors"| node_heuristics
node_audit_api -->|"returns audit"| node_structured_result
node_examiner_api -.->|"requests narrative"| node_provider
node_examiner_api -->|"builds guidance"| node_narrative
node_user -->|"views sample"| node_demo
node_pdf_ui -->|"posts result"| node_pdf_api
node_pdf_api -->|"spawns"| node_latex
node_pdf_api -->|"generates"| node_pdf
node_user -->|"checks service"| node_health

click node_landing "https://github.com/albertoreyescastro/modelhawk/blob/main/app/page.tsx"
click node_upload "https://github.com/albertoreyescastro/modelhawk/blob/main/app/upload/page.tsx"
click node_audit_api "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/route.ts"
click node_heuristics "https://github.com/albertoreyescastro/modelhawk/blob/main/lib/audit-heuristics.mjs"
click node_structured_result "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/route.ts"
click node_examiner_api "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/ai/route.ts"
click node_narrative "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/ai/route.ts"
click node_pdf_ui "https://github.com/albertoreyescastro/modelhawk/blob/main/app/upload/page.tsx"
click node_pdf_api "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/report/pdf/route.ts"
click node_pdf "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/report/pdf/route.ts"
click node_demo "https://github.com/albertoreyescastro/modelhawk/blob/main/app/demo/page.tsx"
click node_health "https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/health/route.ts"
click node_layout "https://github.com/albertoreyescastro/modelhawk/blob/main/app/layout.tsx"

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_landing,node_upload,node_pdf_ui,node_demo,node_layout,node_user toneBlue
class node_audit_api,node_heuristics,node_structured_result toneAmber
class node_examiner_api,node_narrative,node_pdf_api,node_pdf toneMint
class node_health toneRose
class node_provider,node_latex toneIndigo
```

## Components

### Web experience

- [Product overview](https://github.com/albertoreyescastro/modelhawk/blob/main/app/page.tsx): `app/page.tsx`
- [Upload and results UI](https://github.com/albertoreyescastro/modelhawk/blob/main/app/upload/page.tsx): `app/upload/page.tsx`
- [PDF request UI](https://github.com/albertoreyescastro/modelhawk/blob/main/app/upload/page.tsx): `app/upload/page.tsx`
- [Sample audit page](https://github.com/albertoreyescastro/modelhawk/blob/main/app/demo/page.tsx): `app/demo/page.tsx`
- [Application shell](https://github.com/albertoreyescastro/modelhawk/blob/main/app/layout.tsx): `app/layout.tsx`

### Deterministic audit

- [Notebook audit API](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/route.ts): `app/api/audit/route.ts`
- [ML rule detectors](https://github.com/albertoreyescastro/modelhawk/blob/main/lib/audit-heuristics.mjs): `lib/audit-heuristics.mjs`
- [Structured audit](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/route.ts): `app/api/audit/route.ts`

### Examiner and reports

- [Examiner narrative API](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/ai/route.ts): `app/api/audit/ai/route.ts`
- [Examiner guidance](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/audit/ai/route.ts): `app/api/audit/ai/route.ts`
- [PDF report generator](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/report/pdf/route.ts): `app/api/report/pdf/route.ts`
- [Generated PDF](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/report/pdf/route.ts): `app/api/report/pdf/route.ts`

### Service operations

- [Health endpoint](https://github.com/albertoreyescastro/modelhawk/blob/main/app/api/health/route.ts): `app/api/health/route.ts`

### Other components

- **Notebook reviewer**
- **Optional AI provider**
- **LaTeX engine**

## Connections

- Notebook reviewer → Product overview: views (evidence: `README.md`)
- Notebook reviewer → Upload and results UI: submits notebook (evidence: `README.md`)
- Notebook audit API → ML rule detectors: calls detectors (evidence: `app/api/audit/route.ts`)
- Notebook audit API → Structured audit: returns audit (evidence: `README.md`)
- Examiner narrative API → Optional AI provider: requests narrative (evidence: `app/api/audit/ai/route.ts`)
- Examiner narrative API → Examiner guidance: builds guidance (evidence: `app/api/audit/ai/route.ts`)
- Notebook reviewer → Sample audit page: views sample (evidence: `README.md`)
- PDF request UI → PDF report generator: posts result (evidence: `app/upload/page.tsx`)
- PDF report generator → LaTeX engine: spawns (evidence: `app/api/report/pdf/route.ts`)
- PDF report generator → Generated PDF: generates (evidence: `README.md`)
- Notebook reviewer → Health endpoint: checks service (evidence: `README.md`)
