# rama-l7/upf-insight architecture

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

- Interactive diagram: https://gitdiagram.com/rama-l7/upf-insight
- Repository: https://github.com/rama-l7/upf-insight

## Overview

UPF-Insight is a local-first IEEE 1801 power-intent analysis tool. The main workflow preprocesses UPF text, builds a provenance-aware domain model, validates and analyzes it, then exposes findings through CLI/API/workspace reports and regression gates. Separate capabilities generate UPF and semantically diff versions. The graph follows documented orchestration and source-index references; some unsampled feature details and UI wiring are therefore omitted.

Main entry points: [`upf_insight/engine/engine.py`](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/engine.py) (Analysis orchestrator), [`upf_insight/cli/cli.py`](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/cli/cli.py) (CLI), [`upf_insight/api/api_server.py`](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/api/api_server.py) (Local HTTP API), [`upf_insight/engine/rules/checker.py`](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/checker.py) (Rule checker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_cli["CLI<br/>[cli.py]"]
  node_api["Local HTTP API<br/>[api_server.py]"]
  node_mcp["MCP server<br/>[mcp_server.py]"]
end

subgraph group_ingestion["UPF ingestion and model"]
  node_preprocess["UPF preprocessor<br/>[upf_preprocess.py]"]
  node_builder["Model builder<br/>[builder.py]"]
  node_model["Power-intent model<br/>[power_model.py]"]
  node_relations["Domain relations<br/>[relations.py]"]
end

subgraph group_analysis["Validation and analysis"]
  node_engine["Analysis orchestrator<br/>[engine.py]"]
  node_checker["Rule checker<br/>[checker.py]"]
  node_registry["Rules registry<br/>[rules_registry.py]"]
  node_rules["UPF rule handlers<br/>[upf_rules.py]"]
  node_pst["PST analysis<br/>[analyzer.py]"]
  node_readiness["Readiness<br/>[readiness.py]"]
  node_design["Design-aware checks<br/>[design_context.py]"]
  node_strategy["Strategy interactions"]
  node_coverage["Coverage analysis<br/>[coverage.py]"]
  node_support["Support boundary"]
end

subgraph group_change["Generation and change control"]
  node_generator["UPF generator<br/>[generator.py]"]
  node_differ["Semantic diff<br/>[differ.py]"]
  node_policy["CI policy gate<br/>[policy_engine.py]"]
end

subgraph group_outputs["Results and reporting"]
  node_reporter["Report formatter<br/>[reporter.py]"]
end

node_author(("UPF author"))
node_implementation(("Power-aware implementation"))

node_author -->|"submits UPF"| node_cli
node_author -->|"submits UPF"| node_api
node_cli -->|"validates"| node_engine
node_api -->|"preprocesses text"| node_preprocess
node_api -->|"validates records"| node_engine
node_mcp -->|"invokes analysis"| node_engine
node_engine -->|"preprocesses files"| node_preprocess
node_engine -->|"builds model"| node_builder
node_builder -->|"populates"| node_model
node_engine -->|"checks model"| node_checker
node_checker -->|"loads rules"| node_registry
node_checker -->|"dispatches rules"| node_rules
node_engine -->|"analyzes PST"| node_pst
node_engine -->|"computes readiness"| node_readiness
node_engine -->|"analyzes coverage"| node_coverage
node_engine -->|"computes support"| node_support
node_engine -->|"derives relations"| node_relations
node_engine -->|"checks design context"| node_design
node_engine -->|"analyzes interactions"| node_strategy
node_cli -->|"generates UPF"| node_generator
node_cli -->|"diffs versions"| node_differ
node_differ -->|"validates inputs"| node_engine
node_cli -->|"evaluates gate"| node_policy
node_cli -->|"formats results"| node_reporter
node_api -->|"diffs versions"| node_differ
node_api -->|"generates UPF"| node_generator
node_api -->|"formats results"| node_reporter
node_engine -->|"supplies results"| node_reporter
node_engine -->|"informs handoff"| node_implementation

click node_cli "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/cli/cli.py"
click node_api "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/api/api_server.py"
click node_mcp "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/api/mcp_server.py"
click node_preprocess "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/preprocess/upf_preprocess.py"
click node_builder "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/model/builder.py"
click node_model "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/model/power_model.py"
click node_relations "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/model/relations.py"
click node_engine "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/engine.py"
click node_checker "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/checker.py"
click node_registry "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/rules_registry.py"
click node_rules "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/upf_rules.py"
click node_pst "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/pst/analyzer.py"
click node_readiness "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/readiness/readiness.py"
click node_design "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/design/design_context.py"
click node_strategy "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/analysis/strategy_interactions.py"
click node_coverage "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/coverage/coverage.py"
click node_support "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/trust/support_boundary.py"
click node_generator "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/generate/generator.py"
click node_differ "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/diff/differ.py"
click node_policy "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/policy/policy_engine.py"
click node_reporter "https://github.com/rama-l7/upf-insight/blob/main/upf_insight/report/reporter.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_mcp toneBlue
class node_preprocess,node_builder,node_model,node_relations toneAmber
class node_engine,node_checker,node_registry,node_rules,node_pst,node_readiness,node_design,node_strategy,node_coverage,node_support toneMint
class node_generator,node_differ,node_policy toneRose
class node_reporter,node_author,node_implementation toneIndigo
```

## Components

### User interfaces

- [CLI](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/cli/cli.py): `upf_insight/cli/cli.py`
- [Local HTTP API](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/api/api_server.py): `upf_insight/api/api_server.py`
- [MCP server](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/api/mcp_server.py): `upf_insight/api/mcp_server.py`

### UPF ingestion and model

- [UPF preprocessor](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/preprocess/upf_preprocess.py): `upf_insight/preprocess/upf_preprocess.py`
- [Model builder](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/model/builder.py): `upf_insight/model/builder.py`
- [Power-intent model](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/model/power_model.py): `upf_insight/model/power_model.py`
- [Domain relations](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/model/relations.py): `upf_insight/model/relations.py`

### Validation and analysis

- [Analysis orchestrator](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/engine.py): `upf_insight/engine/engine.py`
- [Rule checker](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/checker.py): `upf_insight/engine/rules/checker.py`
- [Rules registry](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/rules_registry.py): `upf_insight/engine/rules/rules_registry.py`
- [UPF rule handlers](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/rules/upf_rules.py): `upf_insight/engine/rules/upf_rules.py`
- [PST analysis](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/pst/analyzer.py): `upf_insight/engine/pst/analyzer.py`
- [Readiness](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/readiness/readiness.py): `upf_insight/engine/readiness/readiness.py`
- [Design-aware checks](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/design/design_context.py): `upf_insight/engine/design/design_context.py`
- [Strategy interactions](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/analysis/strategy_interactions.py): `upf_insight/engine/analysis/strategy_interactions.py`
- [Coverage analysis](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/coverage/coverage.py): `upf_insight/engine/coverage/coverage.py`
- [Support boundary](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/trust/support_boundary.py): `upf_insight/engine/trust/support_boundary.py`

### Generation and change control

- [UPF generator](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/generate/generator.py): `upf_insight/generate/generator.py`
- [Semantic diff](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/diff/differ.py): `upf_insight/diff/differ.py`
- [CI policy gate](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/engine/policy/policy_engine.py): `upf_insight/engine/policy/policy_engine.py`

### Results and reporting

- [Report formatter](https://github.com/rama-l7/upf-insight/blob/main/upf_insight/report/reporter.py): `upf_insight/report/reporter.py`

### Other components

- **UPF author**
- **Power-aware implementation**

## Connections

- UPF author → CLI: submits UPF (evidence: `README.md`)
- UPF author → Local HTTP API: submits UPF (evidence: `README.md`)
- CLI → Analysis orchestrator: validates (evidence: `upf_insight/cli/cli.py`)
- Local HTTP API → UPF preprocessor: preprocesses text (evidence: `upf_insight/api/api_server.py`)
- Local HTTP API → Analysis orchestrator: validates records (evidence: `upf_insight/api/api_server.py`)
- MCP server → Analysis orchestrator: invokes analysis (evidence: `upf_insight/api/mcp_server.py`)
- Analysis orchestrator → UPF preprocessor: preprocesses files (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Model builder: builds model (evidence: `upf_insight/engine/engine.py`)
- Model builder → Power-intent model: populates (evidence: `upf_insight/model/builder.py`)
- Analysis orchestrator → Rule checker: checks model (evidence: `upf_insight/engine/engine.py`)
- Rule checker → Rules registry: loads rules (evidence: `upf_insight/engine/rules/checker.py`)
- Rule checker → UPF rule handlers: dispatches rules (evidence: `upf_insight/engine/rules/checker.py`)
- Analysis orchestrator → PST analysis: analyzes PST (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Readiness: computes readiness (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Coverage analysis: analyzes coverage (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Support boundary: computes support (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Domain relations: derives relations (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Design-aware checks: checks design context (evidence: `upf_insight/engine/engine.py`)
- Analysis orchestrator → Strategy interactions: analyzes interactions (evidence: `upf_insight/engine/engine.py`)
- CLI → UPF generator: generates UPF (evidence: `upf_insight/cli/cli.py`)
- CLI → Semantic diff: diffs versions (evidence: `upf_insight/cli/cli.py`)
- Semantic diff → Analysis orchestrator: validates inputs (evidence: `upf_insight/diff/differ.py`)
- CLI → CI policy gate: evaluates gate (evidence: `upf_insight/cli/cli.py`)
- CLI → Report formatter: formats results (evidence: `upf_insight/cli/cli.py`)
- Local HTTP API → Semantic diff: diffs versions (evidence: `upf_insight/api/api_server.py`)
- Local HTTP API → UPF generator: generates UPF (evidence: `upf_insight/api/api_server.py`)
- Local HTTP API → Report formatter: formats results (evidence: `upf_insight/api/api_server.py`)
- Analysis orchestrator → Report formatter: supplies results (evidence: `upf_insight/report/reporter.py`)
- Analysis orchestrator → Power-aware implementation: informs handoff (evidence: `README.md`)
