# luora/ninja-pce architecture

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

- Interactive diagram: https://gitdiagram.com/luora/ninja-pce
- Repository: https://github.com/luora/ninja-pce

## Overview

ninja-pce is an external RSVP-TE path-computation and topology-reconciliation tool, not a PCEP controller. Operators provide a topology/TED, service demands, and device inventory; the CLI computes and ranks feasible CSPF paths, renders review artifacts, and can deliver approved configuration. Reconciliation and daemon operation add change detection, persistent state, audit, and policy-gated delivery. Some implementation excerpts are partial, so the graph includes documented capabilities while omitting uncertain internal wiring.

Main entry points: [`src/ninja_pce/cli.py`](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/cli.py) (CLI Commands), [`src/ninja_pce/reconcile.py`](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/reconcile.py) (Reconciliation Cycle), [`src/ninja_pce/render.py`](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/render.py) (Config Renderer), [`src/ninja_pce/loaders.py`](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/loaders.py) (Input Loaders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Inputs and Models"]
  node_loaders["Input Loaders<br/>[loaders.py]"]
  node_models["Domain Models<br/>[models.py]"]
  node_inventory["Inventory Validation<br/>[inventory.py]"]
end

subgraph group_compute["Path Computation"]
  node_cspf["CSPF Engine<br/>[cspf.py]"]
end

subgraph group_delivery["Render and Delivery"]
  node_render["Config Renderer<br/>[render.py]"]
  node_templates["Platform Templates"]
  node_outputs["Plans and Summaries<br/>[render.py]"]
  node_southbound["Push Planning<br/>[southbound.py]"]
end

subgraph group_operations["Reconcile and Operate"]
  node_cli["CLI Commands<br/>[cli.py]"]
  node_reconcile["Reconciliation Cycle<br/>[reconcile.py]"]
  node_state[("State and Audit<br/>[reconcile.py]")]
  node_daemon["Multi-demand Daemon<br/>[daemon.py]"]
end

node_operator(("Network Operator"))
node_topology["Topology TED"]
node_demand["Service Demand"]
node_inventory_file["Device Inventory"]
node_routers(("Managed Routers"))
node_netmiko["Netmiko"]
node_monitor(("Health Consumers"))

node_operator -->|"invokes"| node_cli
node_operator -->|"supplies"| node_topology
node_operator -->|"supplies"| node_demand
node_operator -->|"supplies"| node_inventory_file
node_cli -->|"loads inputs"| node_loaders
node_loaders -->|"builds models"| node_models
node_cli -->|"validates mapping"| node_inventory
node_cli -->|"computes paths"| node_cspf
node_cspf -->|"uses models"| node_models
node_cli -->|"writes outputs"| node_render
node_render -->|"renders with"| node_templates
node_render -->|"writes artifacts"| node_outputs
node_cli -->|"plans delivery"| node_southbound
node_southbound -->|"renders config"| node_render
node_cli -->|"executes approved push"| node_netmiko
node_netmiko -->|"configures and checks"| node_routers
node_cli -->|"starts cycle"| node_reconcile
node_reconcile -->|"loads inputs"| node_loaders
node_reconcile -->|"validates mapping"| node_inventory
node_reconcile -->|"computes desired path"| node_cspf
node_reconcile -->|"plans and pushes"| node_southbound
node_reconcile -->|"reads and writes"| node_state
node_reconcile -->|"writes artifacts"| node_outputs
node_daemon -->|"reconciles demands"| node_reconcile
node_daemon -->|"serves health metrics"| node_monitor

click node_cli "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/cli.py"
click node_loaders "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/loaders.py"
click node_models "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/models.py"
click node_inventory "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/inventory.py"
click node_cspf "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/cspf.py"
click node_render "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/render.py"
click node_templates "https://github.com/luora/ninja-pce/tree/main/src/ninja_pce/templates"
click node_outputs "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/render.py"
click node_southbound "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/southbound.py"
click node_reconcile "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/reconcile.py"
click node_state "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/reconcile.py"
click node_daemon "https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/daemon.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_loaders,node_models,node_inventory toneBlue
class node_cspf toneAmber
class node_render,node_templates,node_outputs,node_southbound,node_routers toneMint
class node_cli,node_reconcile,node_state,node_daemon toneRose
class node_operator,node_topology,node_demand,node_inventory_file,node_netmiko,node_monitor toneIndigo
```

## Components

### Inputs and Models

- [Input Loaders](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/loaders.py): `src/ninja_pce/loaders.py`
- [Domain Models](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/models.py): `src/ninja_pce/models.py`
- [Inventory Validation](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/inventory.py): `src/ninja_pce/inventory.py`

### Path Computation

- [CSPF Engine](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/cspf.py): `src/ninja_pce/cspf.py`

### Render and Delivery

- [Config Renderer](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/render.py): `src/ninja_pce/render.py`
- [Platform Templates](https://github.com/luora/ninja-pce/tree/main/src/ninja_pce/templates): `src/ninja_pce/templates`
- [Plans and Summaries](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/render.py): `src/ninja_pce/render.py`
- [Push Planning](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/southbound.py): `src/ninja_pce/southbound.py`

### Reconcile and Operate

- [CLI Commands](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/cli.py): `src/ninja_pce/cli.py`
- [Reconciliation Cycle](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/reconcile.py): `src/ninja_pce/reconcile.py`
- [State and Audit](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/reconcile.py): `src/ninja_pce/reconcile.py`
- [Multi-demand Daemon](https://github.com/luora/ninja-pce/blob/main/src/ninja_pce/daemon.py): `src/ninja_pce/daemon.py`

### Other components

- **Network Operator**
- **Topology TED**
- **Service Demand**
- **Device Inventory**
- **Managed Routers**
- **Netmiko**
- **Health Consumers**

## Connections

- Network Operator → CLI Commands: invokes
- Network Operator → Topology TED: supplies
- Network Operator → Service Demand: supplies
- Network Operator → Device Inventory: supplies
- CLI Commands → Input Loaders: loads inputs
- Input Loaders → Domain Models: builds models
- CLI Commands → Inventory Validation: validates mapping
- CLI Commands → CSPF Engine: computes paths
- CSPF Engine → Domain Models: uses models
- CLI Commands → Config Renderer: writes outputs
- Config Renderer → Platform Templates: renders with
- Config Renderer → Plans and Summaries: writes artifacts
- CLI Commands → Push Planning: plans delivery
- Push Planning → Config Renderer: renders config
- CLI Commands → Netmiko: executes approved push
- Netmiko → Managed Routers: configures and checks
- CLI Commands → Reconciliation Cycle: starts cycle
- Reconciliation Cycle → Input Loaders: loads inputs
- Reconciliation Cycle → Inventory Validation: validates mapping
- Reconciliation Cycle → CSPF Engine: computes desired path
- Reconciliation Cycle → Push Planning: plans and pushes
- Reconciliation Cycle → State and Audit: reads and writes
- Reconciliation Cycle → Plans and Summaries: writes artifacts
- Multi-demand Daemon → Reconciliation Cycle: reconciles demands
- Multi-demand Daemon → Health Consumers: serves health metrics
