# code-aarush/kestral architecture

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

- Interactive diagram: https://gitdiagram.com/code-aarush/kestral
- Repository: https://github.com/code-aarush/kestral

## Overview

KESTREL is a C++ spatial-indexing and hazard-assessment simulation with a decoupled Canvas viewer. The primary workflow runs seeded entity motion, maintains the entity store and dynamic R-tree, then answers mission region, proximity, and corridor queries. A separate exporter serializes simulation, index, and query state for the frontend to render. The graph follows the README and shown entry points; some internal calls are documented only at subsystem level, so unsampled implementation details are not expanded.

Main entry points: [`src/export.cpp`](https://github.com/code-aarush/kestral/blob/main/src/export.cpp) (State Exporter), [`src/mission.cpp`](https://github.com/code-aarush/kestral/blob/main/src/mission.cpp) (Mission Queries), [`src/simulator.cpp`](https://github.com/code-aarush/kestral/blob/main/src/simulator.cpp) (Kepler Simulator), [`src/rtree.cpp`](https://github.com/code-aarush/kestral/blob/main/src/rtree.cpp) (Dynamic R-Tree)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_simulation["Simulation &amp; State"]
  node_demo["Demo Entry<br/>[main.cpp]"]
  node_simulator["Kepler Simulator<br/>[simulator.cpp]"]
  node_entity_store[("Entity Store<br/>[entity_store.cpp]")]
  node_entity["Entity Model<br/>[entity.h]"]
end

subgraph group_spatial["Spatial Index"]
  node_rtree["Dynamic R-Tree<br/>[rtree.cpp]"]
  node_rtree_node["R-Tree Nodes<br/>[rtree_node.cpp]"]
  node_geometry["Geometry Operations<br/>[geometry.cpp]"]
end

subgraph group_assessment["Hazard Assessment"]
  node_mission["Mission Queries<br/>[mission.cpp]"]
end

subgraph group_visualization["Export &amp; Visualization"]
  node_exporter["State Exporter<br/>[export.cpp]"]
  node_frontend["Mission Control Canvas<br/>[app.js]"]
end

node_operator(("Demo Operator"))

node_operator -->|"starts"| node_demo
node_demo -->|"steps"| node_simulator
node_demo -->|"runs queries"| node_mission
node_simulator -->|"updates entities"| node_entity_store
node_simulator -->|"updates index"| node_rtree
node_entity_store -->|"stores"| node_entity
node_rtree -->|"manages nodes"| node_rtree_node
node_rtree_node -->|"uses bounds"| node_geometry
node_mission -->|"retrieves candidates"| node_rtree
node_mission -->|"checks candidates"| node_geometry
node_mission -->|"reads entities"| node_entity_store
node_exporter -->|"runs steps"| node_simulator
node_exporter -->|"queries region"| node_mission
node_exporter -->|"exports index"| node_rtree
node_operator -->|"requests state"| node_exporter
node_exporter -->|"provides JSON"| node_frontend
node_frontend -->|"renders results"| node_operator

click node_demo "https://github.com/code-aarush/kestral/blob/main/src/main.cpp"
click node_simulator "https://github.com/code-aarush/kestral/blob/main/src/simulator.cpp"
click node_entity_store "https://github.com/code-aarush/kestral/blob/main/src/entity_store.cpp"
click node_entity "https://github.com/code-aarush/kestral/blob/main/src/entity.h"
click node_rtree "https://github.com/code-aarush/kestral/blob/main/src/rtree.cpp"
click node_rtree_node "https://github.com/code-aarush/kestral/blob/main/src/rtree_node.cpp"
click node_geometry "https://github.com/code-aarush/kestral/blob/main/src/geometry.cpp"
click node_mission "https://github.com/code-aarush/kestral/blob/main/src/mission.cpp"
click node_exporter "https://github.com/code-aarush/kestral/blob/main/src/export.cpp"
click node_frontend "https://github.com/code-aarush/kestral/blob/main/frontend/app.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_demo,node_simulator,node_entity_store,node_entity toneBlue
class node_rtree,node_rtree_node,node_geometry toneAmber
class node_mission toneMint
class node_exporter,node_frontend toneRose
class node_operator toneIndigo
```

## Components

### Simulation & State

- [Demo Entry](https://github.com/code-aarush/kestral/blob/main/src/main.cpp): `src/main.cpp`
- [Kepler Simulator](https://github.com/code-aarush/kestral/blob/main/src/simulator.cpp): `src/simulator.cpp`
- [Entity Store](https://github.com/code-aarush/kestral/blob/main/src/entity_store.cpp): `src/entity_store.cpp`
- [Entity Model](https://github.com/code-aarush/kestral/blob/main/src/entity.h): `src/entity.h`

### Spatial Index

- [Dynamic R-Tree](https://github.com/code-aarush/kestral/blob/main/src/rtree.cpp): `src/rtree.cpp`
- [R-Tree Nodes](https://github.com/code-aarush/kestral/blob/main/src/rtree_node.cpp): `src/rtree_node.cpp`
- [Geometry Operations](https://github.com/code-aarush/kestral/blob/main/src/geometry.cpp): `src/geometry.cpp`

### Hazard Assessment

- [Mission Queries](https://github.com/code-aarush/kestral/blob/main/src/mission.cpp): `src/mission.cpp`

### Export & Visualization

- [State Exporter](https://github.com/code-aarush/kestral/blob/main/src/export.cpp): `src/export.cpp`
- [Mission Control Canvas](https://github.com/code-aarush/kestral/blob/main/frontend/app.js): `frontend/app.js`

### Other components

- **Demo Operator**

## Connections

- Demo Operator → Demo Entry: starts (evidence: `README.md`)
- Demo Entry → Kepler Simulator: steps (evidence: `src/main.cpp`)
- Demo Entry → Mission Queries: runs queries (evidence: `src/main.cpp`)
- Kepler Simulator → Entity Store: updates entities (evidence: `README.md`)
- Kepler Simulator → Dynamic R-Tree: updates index (evidence: `README.md`)
- Entity Store → Entity Model: stores
- Dynamic R-Tree → R-Tree Nodes: manages nodes
- R-Tree Nodes → Geometry Operations: uses bounds
- Mission Queries → Dynamic R-Tree: retrieves candidates (evidence: `README.md`)
- Mission Queries → Geometry Operations: checks candidates (evidence: `README.md`)
- Mission Queries → Entity Store: reads entities
- State Exporter → Kepler Simulator: runs steps (evidence: `src/export.cpp`)
- State Exporter → Mission Queries: queries region (evidence: `src/export.cpp`)
- State Exporter → Dynamic R-Tree: exports index (evidence: `src/export.cpp`)
- Demo Operator → State Exporter: requests state (evidence: `README.md`)
- State Exporter → Mission Control Canvas: provides JSON (evidence: `README.md`)
- Mission Control Canvas → Demo Operator: renders results (evidence: `frontend/app.js`)
