# namanpahariya2009/pcb-auditor-knight-divers architecture

> Architecture diagram of the GitHub repository namanpahariya2009/pcb-auditor-knight-divers, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/namanpahariya2009/pcb-auditor-knight-divers
- Repository: https://github.com/namanpahariya2009/pcb-auditor-knight-divers

## Overview

PCB Safety Auditor turns built-in tasks or parsed board files into an interactive audit: an agent or user requests electrical checks, the environment evaluates the topology, and a grader scores the findings and verdict. The same product is exposed through a FastAPI API, a Gradio diagnostic UI, and a model-driven inference runner. The README documents parser formats and safety checks beyond the sampled excerpts; the graph groups those capabilities without assuming unshown call paths.

Main entry points: [`environment.py`](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py) (Audit environment), [`server.py`](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/server.py) (REST API), [`netlist_parser.py`](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py) (Board parsers), [`inference.py`](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/inference.py) (Inference runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Board input"]
  node_board_parser["Board parsers<br/>[netlist_parser.py]"]
  node_component_inference["Component inference<br/>[netlist_parser.py]"]
  node_connection_normalization["Connection normalization<br/>[netlist_parser.py]"]
end

subgraph group_audit["Audit environment"]
  node_environment["Audit environment<br/>[environment.py]"]
  node_topology["Board topology<br/>[environment.py]"]
  node_diagnostics["Safety diagnostics<br/>[environment.py]"]
end

subgraph group_grading["Tasks and grading"]
  node_task_catalog["Benchmark tasks<br/>[tasks.py]"]
  node_grader["Verdict grader<br/>[tasks.py]"]
end

subgraph group_interfaces["User interfaces"]
  node_api["REST API<br/>[server.py]"]
  node_ui["Diagnostic UI<br/>[server.py]"]
end

subgraph group_agent["Automated agent"]
  node_inference["Inference runner<br/>[inference.py]"]
end

node_user(("User"))
node_agent_actor(("Audit agent"))
node_model(("Model service"))

node_user -->|"sends requests"| node_api
node_user -->|"runs audits"| node_ui
node_agent_actor -->|"starts runs"| node_inference
node_model -->|"returns actions"| node_inference
node_api -->|"resets and steps"| node_environment
node_ui -->|"runs checks"| node_environment
node_api -->|"lists tasks"| node_task_catalog
node_api -->|"uses parser"| node_board_parser
node_ui -->|"accepts custom boards"| node_board_parser
node_board_parser -->|"infers parts"| node_component_inference
node_board_parser -->|"normalizes nets"| node_connection_normalization
node_environment -->|"loads tasks"| node_task_catalog
node_environment -->|"builds graph"| node_topology
node_environment -->|"runs checks"| node_diagnostics
node_environment -->|"grades findings"| node_grader
node_inference -->|"resets and steps"| node_environment
node_inference -->|"selects tasks"| node_task_catalog

click node_board_parser "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py"
click node_component_inference "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py"
click node_connection_normalization "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py"
click node_task_catalog "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/tasks.py"
click node_environment "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py"
click node_topology "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py"
click node_diagnostics "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py"
click node_grader "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/tasks.py"
click node_api "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/server.py"
click node_ui "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/server.py"
click node_inference "https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/inference.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_board_parser,node_component_inference,node_connection_normalization,node_user toneBlue
class node_environment,node_topology,node_diagnostics toneAmber
class node_task_catalog,node_grader toneMint
class node_api,node_ui toneRose
class node_inference,node_agent_actor,node_model toneIndigo
```

## Components

### Board input

- [Board parsers](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py): `netlist_parser.py`
- [Component inference](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py): `netlist_parser.py`
- [Connection normalization](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/netlist_parser.py): `netlist_parser.py`

### Audit environment

- [Audit environment](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py): `environment.py`
- [Board topology](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py): `environment.py`
- [Safety diagnostics](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/environment.py): `environment.py`

### Tasks and grading

- [Benchmark tasks](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/tasks.py): `tasks.py`
- [Verdict grader](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/tasks.py): `tasks.py`

### User interfaces

- [REST API](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/server.py): `server.py`
- [Diagnostic UI](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/server.py): `server.py`

### Automated agent

- [Inference runner](https://github.com/namanpahariya2009/pcb-auditor-knight-divers/blob/main/inference.py): `inference.py`

### Other components

- **User**
- **Audit agent**
- **Model service**

## Connections

- User → REST API: sends requests (evidence: `README.md`)
- User → Diagnostic UI: runs audits (evidence: `README.md`)
- Audit agent → Inference runner: starts runs (evidence: `README.md`)
- Model service → Inference runner: returns actions (evidence: `inference.py`)
- REST API → Audit environment: resets and steps (evidence: `server.py`)
- Diagnostic UI → Audit environment: runs checks (evidence: `server.py`)
- REST API → Benchmark tasks: lists tasks (evidence: `server.py`)
- REST API → Board parsers: uses parser (evidence: `server.py`)
- Diagnostic UI → Board parsers: accepts custom boards (evidence: `README.md`)
- Board parsers → Component inference: infers parts (evidence: `netlist_parser.py`)
- Board parsers → Connection normalization: normalizes nets (evidence: `netlist_parser.py`)
- Audit environment → Benchmark tasks: loads tasks (evidence: `environment.py`)
- Audit environment → Board topology: builds graph (evidence: `environment.py`)
- Audit environment → Safety diagnostics: runs checks (evidence: `environment.py`)
- Audit environment → Verdict grader: grades findings (evidence: `environment.py`)
- Inference runner → Audit environment: resets and steps (evidence: `inference.py`)
- Inference runner → Benchmark tasks: selects tasks (evidence: `inference.py`)
