# hchju777/deepagent-template architecture

> Architecture diagram of the GitHub repository hchju777/deepagent-template, 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/hchju777/deepagent-template
- Repository: https://github.com/hchju777/deepagent-template

## Overview

This is a read-only operations-monitoring agent for digital-twin service stacks. People can submit symptoms for interactive intake, while scheduled patrol checks can open cases automatically; both feed the shared investigation engine, which gathers evidence, forms and verifies causal verdicts, then produces reports for human action. The HTTP API is a separate case-and-events surface, and fleet rollups and feedback labels are distinct capabilities. Relationships for unsampled subsystems are included only where the README documents them; source excerpts also show API routing and report-model responsibilities.

Main entry points: [`src/patrol/daemon.py`](https://github.com/hchju777/deepagent-template/blob/main/src/patrol/daemon.py) (Patrol daemon), [`src/domain/cases.py`](https://github.com/hchju777/deepagent-template/blob/main/src/domain/cases.py) (Case repository), [`src/api/app.py`](https://github.com/hchju777/deepagent-template/blob/main/src/api/app.py) (HTTP API), [`src/application/worker.py`](https://github.com/hchju777/deepagent-template/blob/main/src/application/worker.py) (Investigation worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry surfaces"]
  node_cli["CLI<br/>[__main__.py]"]
  node_api["HTTP API<br/>[app.py]"]
  node_config["Configuration<br/>[loader.py]"]
end

subgraph group_investigation["Case investigation"]
  node_intake["Symptom intake<br/>[intake.py]"]
  node_investigation_worker["Investigation worker<br/>[worker.py]"]
  node_engine["Investigation graph<br/>[graph.py]"]
  node_investigation_nodes["Investigation stages<br/>[nodes.py]"]
  node_subagents["Evidence subagents<br/>[subagents.py]"]
  node_target_adapters["Read-only adapters"]
  node_knowledge["Topology knowledge<br/>[topology.py]"]
end

subgraph group_patrol["Monitoring and patrol"]
  node_patrol_daemon["Patrol daemon<br/>[daemon.py]"]
  node_checks["Checks and probes<br/>[probes.py]"]
  node_rules["Rule judge<br/>[rules.py]"]
  node_gate["Finding gate<br/>[gate.py]"]
end

subgraph group_state["Domain and persistence"]
  node_case_models["Case models<br/>[case.py]"]
  node_case_repository["Case repository<br/>[cases.py]"]
  node_mongo[("Mongo persistence<br/>[mongo_store.py]")]
  node_event_service["Event service<br/>[events.py]"]
end

subgraph group_outputs["Reporting and learning"]
  node_labels["Feedback labels<br/>[labels.py]"]
  node_report_model["Report model<br/>[report_model.py]"]
  node_report["Report renderers<br/>[report.py]"]
  node_html_report["HTML renderer<br/>[report_html.py]"]
  node_fleet["Fleet aggregation<br/>[run.py]"]
  node_fleet_report["Fleet report<br/>[fleet_report.py]"]
end

node_person(("Operator"))
node_http_user(("API client"))

node_person -->|"invokes"| node_cli
node_person -->|"starts patrol"| node_patrol_daemon
node_http_user -->|"calls"| node_api
node_cli -->|"submits symptoms"| node_intake
node_api -->|"submits cases"| node_intake
node_intake -->|"opens case"| node_case_repository
node_patrol_daemon -->|"schedules checks"| node_checks
node_checks -->|"evaluates"| node_rules
node_patrol_daemon -->|"admits findings"| node_gate
node_gate -->|"opens case"| node_case_repository
node_patrol_daemon -->|"runs worker"| node_investigation_worker
node_investigation_worker -->|"investigates"| node_engine
node_engine -->|"dispatches stages"| node_investigation_nodes
node_investigation_nodes -->|"delegates evidence"| node_subagents
node_subagents -->|"reads targets"| node_target_adapters
node_investigation_nodes -->|"uses topology"| node_knowledge
node_investigation_worker -->|"claims cases"| node_case_repository
node_case_repository -->|"stores records"| node_case_models
node_case_repository -->|"persists cases"| node_mongo
node_investigation_worker -->|"publishes events"| node_event_service
node_api -->|"reads events"| node_event_service
node_api -->|"builds report data"| node_report_model
node_report_model -->|"renders markdown"| node_report
node_report_model -->|"renders HTML"| node_html_report
node_person -->|"supplies actual cause"| node_labels
node_patrol_daemon -->|"runs fleet rollup"| node_fleet
node_fleet -->|"produces report"| node_fleet_report
node_cli -->|"loads configuration"| node_config
node_config -->|"configures patrol"| node_patrol_daemon

click node_cli "https://github.com/hchju777/deepagent-template/blob/main/src/__main__.py"
click node_api "https://github.com/hchju777/deepagent-template/blob/main/src/api/app.py"
click node_intake "https://github.com/hchju777/deepagent-template/blob/main/src/application/intake.py"
click node_patrol_daemon "https://github.com/hchju777/deepagent-template/blob/main/src/patrol/daemon.py"
click node_checks "https://github.com/hchju777/deepagent-template/blob/main/src/patrol/probes.py"
click node_rules "https://github.com/hchju777/deepagent-template/blob/main/src/patrol/rules.py"
click node_gate "https://github.com/hchju777/deepagent-template/blob/main/src/patrol/gate.py"
click node_investigation_worker "https://github.com/hchju777/deepagent-template/blob/main/src/application/worker.py"
click node_engine "https://github.com/hchju777/deepagent-template/blob/main/src/application/graph.py"
click node_investigation_nodes "https://github.com/hchju777/deepagent-template/blob/main/src/application/nodes.py"
click node_subagents "https://github.com/hchju777/deepagent-template/blob/main/src/application/subagents.py"
click node_target_adapters "https://github.com/hchju777/deepagent-template/tree/main/src/infrastructure"
click node_case_models "https://github.com/hchju777/deepagent-template/blob/main/src/domain/case.py"
click node_case_repository "https://github.com/hchju777/deepagent-template/blob/main/src/domain/cases.py"
click node_mongo "https://github.com/hchju777/deepagent-template/blob/main/src/infrastructure/mongo_store.py"
click node_event_service "https://github.com/hchju777/deepagent-template/blob/main/src/application/events.py"
click node_labels "https://github.com/hchju777/deepagent-template/blob/main/src/application/labels.py"
click node_report_model "https://github.com/hchju777/deepagent-template/blob/main/src/domain/report_model.py"
click node_report "https://github.com/hchju777/deepagent-template/blob/main/src/presentation/report.py"
click node_html_report "https://github.com/hchju777/deepagent-template/blob/main/src/presentation/report_html.py"
click node_fleet "https://github.com/hchju777/deepagent-template/blob/main/src/fleet/run.py"
click node_fleet_report "https://github.com/hchju777/deepagent-template/blob/main/src/presentation/fleet_report.py"
click node_config "https://github.com/hchju777/deepagent-template/blob/main/src/config/loader.py"
click node_knowledge "https://github.com/hchju777/deepagent-template/blob/main/src/knowledge/topology.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_cli,node_api,node_config,node_http_user toneBlue
class node_intake,node_investigation_worker,node_engine,node_investigation_nodes,node_subagents,node_target_adapters,node_knowledge toneAmber
class node_patrol_daemon,node_checks,node_rules,node_gate toneMint
class node_case_models,node_case_repository,node_mongo,node_event_service toneRose
class node_labels,node_report_model,node_report,node_html_report,node_fleet,node_fleet_report,node_person toneIndigo
```

## Components

### Entry surfaces

- [CLI](https://github.com/hchju777/deepagent-template/blob/main/src/__main__.py): `src/__main__.py`
- [HTTP API](https://github.com/hchju777/deepagent-template/blob/main/src/api/app.py): `src/api/app.py`
- [Configuration](https://github.com/hchju777/deepagent-template/blob/main/src/config/loader.py): `src/config/loader.py`

### Case investigation

- [Symptom intake](https://github.com/hchju777/deepagent-template/blob/main/src/application/intake.py): `src/application/intake.py`
- [Investigation worker](https://github.com/hchju777/deepagent-template/blob/main/src/application/worker.py): `src/application/worker.py`
- [Investigation graph](https://github.com/hchju777/deepagent-template/blob/main/src/application/graph.py): `src/application/graph.py`
- [Investigation stages](https://github.com/hchju777/deepagent-template/blob/main/src/application/nodes.py): `src/application/nodes.py`
- [Evidence subagents](https://github.com/hchju777/deepagent-template/blob/main/src/application/subagents.py): `src/application/subagents.py`
- [Read-only adapters](https://github.com/hchju777/deepagent-template/tree/main/src/infrastructure): `src/infrastructure`
- [Topology knowledge](https://github.com/hchju777/deepagent-template/blob/main/src/knowledge/topology.py): `src/knowledge/topology.py`

### Monitoring and patrol

- [Patrol daemon](https://github.com/hchju777/deepagent-template/blob/main/src/patrol/daemon.py): `src/patrol/daemon.py`
- [Checks and probes](https://github.com/hchju777/deepagent-template/blob/main/src/patrol/probes.py): `src/patrol/probes.py`
- [Rule judge](https://github.com/hchju777/deepagent-template/blob/main/src/patrol/rules.py): `src/patrol/rules.py`
- [Finding gate](https://github.com/hchju777/deepagent-template/blob/main/src/patrol/gate.py): `src/patrol/gate.py`

### Domain and persistence

- [Case models](https://github.com/hchju777/deepagent-template/blob/main/src/domain/case.py): `src/domain/case.py`
- [Case repository](https://github.com/hchju777/deepagent-template/blob/main/src/domain/cases.py): `src/domain/cases.py`
- [Mongo persistence](https://github.com/hchju777/deepagent-template/blob/main/src/infrastructure/mongo_store.py): `src/infrastructure/mongo_store.py`
- [Event service](https://github.com/hchju777/deepagent-template/blob/main/src/application/events.py): `src/application/events.py`

### Reporting and learning

- [Feedback labels](https://github.com/hchju777/deepagent-template/blob/main/src/application/labels.py): `src/application/labels.py`
- [Report model](https://github.com/hchju777/deepagent-template/blob/main/src/domain/report_model.py): `src/domain/report_model.py`
- [Report renderers](https://github.com/hchju777/deepagent-template/blob/main/src/presentation/report.py): `src/presentation/report.py`
- [HTML renderer](https://github.com/hchju777/deepagent-template/blob/main/src/presentation/report_html.py): `src/presentation/report_html.py`
- [Fleet aggregation](https://github.com/hchju777/deepagent-template/blob/main/src/fleet/run.py): `src/fleet/run.py`
- [Fleet report](https://github.com/hchju777/deepagent-template/blob/main/src/presentation/fleet_report.py): `src/presentation/fleet_report.py`

### Other components

- **Operator**
- **API client**

## Connections

- Operator → CLI: invokes
- Operator → Patrol daemon: starts patrol
- API client → HTTP API: calls (evidence: `src/api/app.py`)
- CLI → Symptom intake: submits symptoms (evidence: `src/__main__.py`)
- HTTP API → Symptom intake: submits cases (evidence: `src/api/routes_cases.py`)
- Symptom intake → Case repository: opens case (evidence: `src/application/intake.py`)
- Patrol daemon → Checks and probes: schedules checks (evidence: `src/patrol/daemon.py`)
- Checks and probes → Rule judge: evaluates
- Patrol daemon → Finding gate: admits findings (evidence: `src/patrol/daemon.py`)
- Finding gate → Case repository: opens case
- Patrol daemon → Investigation worker: runs worker (evidence: `src/patrol/daemon.py`)
- Investigation worker → Investigation graph: investigates (evidence: `src/application/worker.py`)
- Investigation graph → Investigation stages: dispatches stages
- Investigation stages → Evidence subagents: delegates evidence (evidence: `src/application/nodes.py`)
- Evidence subagents → Read-only adapters: reads targets
- Investigation stages → Topology knowledge: uses topology (evidence: `src/application/nodes.py`)
- Investigation worker → Case repository: claims cases (evidence: `src/application/worker.py`)
- Case repository → Case models: stores records (evidence: `src/domain/cases.py`)
- Case repository → Mongo persistence: persists cases (evidence: `src/infrastructure/mongo_store.py`)
- Investigation worker → Event service: publishes events (evidence: `src/application/worker.py`)
- HTTP API → Event service: reads events (evidence: `src/api/routes_reads.py`)
- HTTP API → Report model: builds report data (evidence: `src/api/routes_reads.py`)
- Report model → Report renderers: renders markdown (evidence: `src/presentation/report.py`)
- Report model → HTML renderer: renders HTML (evidence: `src/presentation/report_html.py`)
- Operator → Feedback labels: supplies actual cause
- Patrol daemon → Fleet aggregation: runs fleet rollup (evidence: `src/patrol/daemon.py`)
- Fleet aggregation → Fleet report: produces report (evidence: `src/fleet/run.py`)
- CLI → Configuration: loads configuration (evidence: `src/__main__.py`)
- Configuration → Patrol daemon: configures patrol (evidence: `src/patrol/daemon.py`)
