# mrdatascientist/finops-agentos architecture

> Architecture diagram of the GitHub repository mrdatascientist/finops-agentos, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrdatascientist/finops-agentos
- Repository: https://github.com/mrdatascientist/finops-agentos

## Overview

FinOps-AgentOS is a prototype policy-gated inference control plane. Its main workflow accepts a typed task at the FastAPI gateway, asks the router and fail-closed policy engine for an eligible route, and returns a dry-run plan by default; explicitly enabled inference dispatches to a provider and records illustrative usage. The Stormscope demo converts synthetic risk evidence into an explanation task without changing the authoritative risk score. Offline evaluation exercises route planning, while metrics and example dashboards expose prototype observability. The graph reflects sampled call sites and README capabilities; unsampled observability wiring is shown only as documented, optional integration.

Main entry points: [`app/gateway/api.py`](https://github.com/mrdatascientist/finops-agentos/blob/main/app/gateway/api.py) (FastAPI gateway), [`app/providers/client.py`](https://github.com/mrdatascientist/finops-agentos/blob/main/app/providers/client.py) (Provider clients), [`app/main.py`](https://github.com/mrdatascientist/finops-agentos/blob/main/app/main.py) (App factory), [`app/policies/engine.py`](https://github.com/mrdatascientist/finops-agentos/blob/main/app/policies/engine.py) (Route policy)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["API Control Plane"]
  node_main["App factory<br/>[main.py]"]
  node_api["FastAPI gateway<br/>[api.py]"]
  node_models["Typed API contracts<br/>[models.py]"]
  node_config["Runtime settings<br/>[config.py]"]
end

subgraph group_policy["Policy and Routing"]
  node_router["Policy router<br/>[router.py]"]
  node_engine["Route policy<br/>[engine.py]"]
end

subgraph group_execution["Inference and Accounting"]
  node_provider["Provider clients<br/>[client.py]"]
  node_ledger[("Usage ledger<br/>[ledger.py]")]
end

subgraph group_integration["Stormscope Integration"]
  node_stormcontract["Risk contract<br/>[contract.py]"]
  node_stormadapter["Task adapter<br/>[adapter.py]"]
  node_stormdemo["Synthetic demo<br/>[demo.py]"]
end

subgraph group_evaluation["Evaluation and Observability"]
  node_eval["Offline policy evaluation<br/>[offline.py]"]
  node_evalcontracts["Evaluation contracts<br/>[contracts.py]"]
  node_prometheus["Prometheus example"]
  node_grafana["Grafana dashboard"]
end

node_caller(("Backend caller"))
node_ollama{{"Ollama service"}}
node_azure{{"Azure OpenAI"}}

node_caller -->|"submits task"| node_api
node_main -->|"registers routes"| node_api
node_main -->|"creates ledger"| node_ledger
node_main -->|"loads settings"| node_config
node_api -->|"accepts contracts"| node_models
node_api -->|"requests decision"| node_router
node_router -->|"chooses route"| node_engine
node_engine -->|"checks settings"| node_config
node_engine -->|"returns decision"| node_models
node_api -->|"dispatches inference"| node_provider
node_provider -->|"posts request"| node_ollama
node_provider -->|"posts request"| node_azure
node_provider -->|"reads settings"| node_config
node_api -->|"records estimate"| node_ledger
node_api -.->|"exposes metrics"| node_prometheus
node_prometheus -.->|"feeds dashboards"| node_grafana
node_stormdemo -->|"builds task"| node_stormcontract
node_stormcontract -->|"creates task"| node_stormadapter
node_stormdemo -->|"posts route plan"| node_api
node_eval -->|"posts route plans"| node_api
node_eval -->|"creates app"| node_main

click node_main "https://github.com/mrdatascientist/finops-agentos/blob/main/app/main.py"
click node_api "https://github.com/mrdatascientist/finops-agentos/blob/main/app/gateway/api.py"
click node_models "https://github.com/mrdatascientist/finops-agentos/blob/main/app/models.py"
click node_config "https://github.com/mrdatascientist/finops-agentos/blob/main/app/config.py"
click node_router "https://github.com/mrdatascientist/finops-agentos/blob/main/app/routing/router.py"
click node_engine "https://github.com/mrdatascientist/finops-agentos/blob/main/app/policies/engine.py"
click node_provider "https://github.com/mrdatascientist/finops-agentos/blob/main/app/providers/client.py"
click node_ledger "https://github.com/mrdatascientist/finops-agentos/blob/main/app/accounting/ledger.py"
click node_stormcontract "https://github.com/mrdatascientist/finops-agentos/blob/main/integrations/stormscope/contract.py"
click node_stormadapter "https://github.com/mrdatascientist/finops-agentos/blob/main/integrations/stormscope/adapter.py"
click node_stormdemo "https://github.com/mrdatascientist/finops-agentos/blob/main/integrations/stormscope/demo.py"
click node_eval "https://github.com/mrdatascientist/finops-agentos/blob/main/app/evaluation/offline.py"
click node_evalcontracts "https://github.com/mrdatascientist/finops-agentos/blob/main/app/evaluation/contracts.py"
click node_prometheus "https://github.com/mrdatascientist/finops-agentos/tree/main/observability/prometheus"
click node_grafana "https://github.com/mrdatascientist/finops-agentos/tree/main/observability/grafana"

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_main,node_api,node_models,node_config toneBlue
class node_router,node_engine toneAmber
class node_provider,node_ledger toneMint
class node_stormcontract,node_stormadapter,node_stormdemo toneRose
class node_eval,node_evalcontracts,node_prometheus,node_grafana,node_caller,node_ollama,node_azure toneIndigo
```

## Components

### API Control Plane

- [App factory](https://github.com/mrdatascientist/finops-agentos/blob/main/app/main.py): `app/main.py`
- [FastAPI gateway](https://github.com/mrdatascientist/finops-agentos/blob/main/app/gateway/api.py): `app/gateway/api.py`
- [Typed API contracts](https://github.com/mrdatascientist/finops-agentos/blob/main/app/models.py): `app/models.py`
- [Runtime settings](https://github.com/mrdatascientist/finops-agentos/blob/main/app/config.py): `app/config.py`

### Policy and Routing

- [Policy router](https://github.com/mrdatascientist/finops-agentos/blob/main/app/routing/router.py): `app/routing/router.py`
- [Route policy](https://github.com/mrdatascientist/finops-agentos/blob/main/app/policies/engine.py): `app/policies/engine.py`

### Inference and Accounting

- [Provider clients](https://github.com/mrdatascientist/finops-agentos/blob/main/app/providers/client.py): `app/providers/client.py`
- [Usage ledger](https://github.com/mrdatascientist/finops-agentos/blob/main/app/accounting/ledger.py): `app/accounting/ledger.py`

### Stormscope Integration

- [Risk contract](https://github.com/mrdatascientist/finops-agentos/blob/main/integrations/stormscope/contract.py): `integrations/stormscope/contract.py`
- [Task adapter](https://github.com/mrdatascientist/finops-agentos/blob/main/integrations/stormscope/adapter.py): `integrations/stormscope/adapter.py`
- [Synthetic demo](https://github.com/mrdatascientist/finops-agentos/blob/main/integrations/stormscope/demo.py): `integrations/stormscope/demo.py`

### Evaluation and Observability

- [Offline policy evaluation](https://github.com/mrdatascientist/finops-agentos/blob/main/app/evaluation/offline.py): `app/evaluation/offline.py`
- [Evaluation contracts](https://github.com/mrdatascientist/finops-agentos/blob/main/app/evaluation/contracts.py): `app/evaluation/contracts.py`
- [Prometheus example](https://github.com/mrdatascientist/finops-agentos/tree/main/observability/prometheus): `observability/prometheus`
- [Grafana dashboard](https://github.com/mrdatascientist/finops-agentos/tree/main/observability/grafana): `observability/grafana`

### Other components

- **Backend caller**
- **Ollama service**
- **Azure OpenAI**

## Connections

- Backend caller → FastAPI gateway: submits task (evidence: `README.md`)
- App factory → FastAPI gateway: registers routes (evidence: `app/main.py`)
- App factory → Usage ledger: creates ledger (evidence: `app/main.py`)
- App factory → Runtime settings: loads settings (evidence: `app/main.py`)
- FastAPI gateway → Typed API contracts: accepts contracts (evidence: `app/gateway/api.py`)
- FastAPI gateway → Policy router: requests decision (evidence: `app/gateway/api.py`)
- Policy router → Route policy: chooses route (evidence: `app/routing/router.py`)
- Route policy → Runtime settings: checks settings (evidence: `app/policies/engine.py`)
- Route policy → Typed API contracts: returns decision (evidence: `app/policies/engine.py`)
- FastAPI gateway → Provider clients: dispatches inference (evidence: `app/gateway/api.py`)
- Provider clients → Ollama service: posts request (evidence: `app/providers/client.py`)
- Provider clients → Azure OpenAI: posts request (evidence: `app/providers/client.py`)
- Provider clients → Runtime settings: reads settings (evidence: `app/providers/client.py`)
- FastAPI gateway → Usage ledger: records estimate (evidence: `app/gateway/api.py`)
- FastAPI gateway → Prometheus example: exposes metrics (evidence: `README.md`)
- Prometheus example → Grafana dashboard: feeds dashboards (evidence: `README.md`)
- Synthetic demo → Risk contract: builds task (evidence: `integrations/stormscope/demo.py`)
- Risk contract → Task adapter: creates task (evidence: `integrations/stormscope/contract.py`)
- Synthetic demo → FastAPI gateway: posts route plan (evidence: `integrations/stormscope/demo.py`)
- Offline policy evaluation → FastAPI gateway: posts route plans (evidence: `app/evaluation/offline.py`)
- Offline policy evaluation → App factory: creates app (evidence: `app/evaluation/offline.py`)
