# cashhero/fabric-capacity-monitor architecture

> Architecture diagram of the GitHub repository cashhero/fabric-capacity-monitor, 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/cashhero/fabric-capacity-monitor
- Repository: https://github.com/cashhero/fabric-capacity-monitor

## Overview

fabric-capacity-monitor is a read-only CLI for collecting Microsoft Fabric capacity activity and producing utilization, throttling, outlook, and consumption reports without a Power BI Pro licence. The main workflow is user command → authentication and capacity discovery → Fabric/optional Azure data collection → CU normalization → smoothed timeline and analysis → text, JSON, or HTML output. README-documented sub-run redistribution and uncounted workload notes are included; some wiring is not visible in the sampled excerpts, so uncertain relationships are omitted or marked optional.

Main entry points: [`src/fabric_capacity_monitor/cli.py`](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/cli.py) (Command handler), [`src/fabric_capacity_monitor/report/analysis.py`](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/analysis.py) (Report analysis), [`src/fabric_capacity_monitor/collect.py`](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/collect.py) (Activity collector), [`src/fabric_capacity_monitor/fabric_api.py`](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/fabric_api.py) (Fabric API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and setup"]
  node_cli["Command handler<br/>[cli.py]"]
  node_config["User config<br/>[config.py]"]
  node_auth["Token provider<br/>[auth.py]"]
end

subgraph group_collection["Collection and domain"]
  node_fabric["Fabric API client<br/>[fabric_api.py]"]
  node_arm["Azure ARM client<br/>[arm.py]"]
  node_collector["Activity collector<br/>[collect.py]"]
  node_cu["CU estimators<br/>[cu.py]"]
  node_rates["Consumption rates<br/>[rates.py]"]
  node_model["Capacity records<br/>[model.py]"]
  node_subruns["Sub-run resolver<br/>[subruns.py]"]
end

subgraph group_analytics["Usage analysis"]
  node_smoothing["Timeline smoothing<br/>[smoothing.py]"]
  node_analysis["Report analysis<br/>[analysis.py]"]
end

subgraph group_outputs["Report formats"]
  node_text["Text report<br/>[text.py]"]
  node_json["JSON report<br/>[json_out.py]"]
  node_html["HTML dashboard<br/>[html.py]"]
end

node_operator(("CLI user"))
node_azure{{"Azure services"}}
node_fabricservice{{"Fabric REST API"}}
node_workspace[("Fabric workspaces")]

node_operator -->|"runs command"| node_cli
node_cli -->|"loads settings"| node_config
node_cli -->|"creates provider"| node_auth
node_cli -->|"creates client"| node_fabric
node_cli -->|"creates client"| node_arm
node_fabric -->|"gets tokens"| node_auth
node_arm -->|"gets tokens"| node_auth
node_fabric -->|"reads APIs"| node_fabricservice
node_arm -->|"reads capacity data"| node_azure
node_cli -->|"collects activity"| node_collector
node_collector -->|"fetches activity"| node_fabric
node_collector -->|"estimates consumption"| node_cu
node_cu -->|"uses rates"| node_rates
node_collector -->|"builds operations"| node_model
node_cli -->|"loads capacity history"| node_arm
node_cli -->|"loads rates"| node_rates
node_cli -->|"analyses collection"| node_analysis
node_analysis -->|"builds timeline"| node_smoothing
node_smoothing -->|"reads operations"| node_model
node_smoothing -->|"uses windows"| node_rates
node_analysis -->|"aggregates records"| node_model
node_cli -->|"renders report"| node_text
node_cli -->|"renders report"| node_json
node_cli -->|"renders dashboard"| node_html
node_text -->|"formats results"| node_analysis
node_json -->|"serializes results"| node_analysis
node_html -->|"renders charts"| node_analysis
node_subruns -.->|"redistributes CU"| node_model
node_fabricservice -.->|"exposes workspace data"| node_workspace

click node_cli "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/cli.py"
click node_config "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/config.py"
click node_auth "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/auth.py"
click node_fabric "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/fabric_api.py"
click node_arm "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/arm.py"
click node_collector "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/collect.py"
click node_cu "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/cu.py"
click node_rates "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/rates.py"
click node_model "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/model.py"
click node_subruns "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/subruns.py"
click node_smoothing "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/smoothing.py"
click node_analysis "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/analysis.py"
click node_text "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/text.py"
click node_json "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/json_out.py"
click node_html "https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/html.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_config,node_auth,node_operator toneBlue
class node_fabric,node_arm,node_collector,node_cu,node_rates,node_model,node_subruns,node_workspace toneAmber
class node_smoothing,node_analysis,node_fabricservice toneMint
class node_text,node_json,node_html toneRose
class node_azure toneIndigo
```

## Components

### CLI and setup

- [Command handler](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/cli.py): `src/fabric_capacity_monitor/cli.py`
- [User config](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/config.py): `src/fabric_capacity_monitor/config.py`
- [Token provider](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/auth.py): `src/fabric_capacity_monitor/auth.py`

### Collection and domain

- [Fabric API client](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/fabric_api.py): `src/fabric_capacity_monitor/fabric_api.py`
- [Azure ARM client](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/arm.py): `src/fabric_capacity_monitor/arm.py`
- [Activity collector](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/collect.py): `src/fabric_capacity_monitor/collect.py`
- [CU estimators](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/cu.py): `src/fabric_capacity_monitor/cu.py`
- [Consumption rates](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/rates.py): `src/fabric_capacity_monitor/rates.py`
- [Capacity records](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/model.py): `src/fabric_capacity_monitor/model.py`
- [Sub-run resolver](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/subruns.py): `src/fabric_capacity_monitor/subruns.py`

### Usage analysis

- [Timeline smoothing](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/smoothing.py): `src/fabric_capacity_monitor/smoothing.py`
- [Report analysis](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/analysis.py): `src/fabric_capacity_monitor/report/analysis.py`

### Report formats

- [Text report](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/text.py): `src/fabric_capacity_monitor/report/text.py`
- [JSON report](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/json_out.py): `src/fabric_capacity_monitor/report/json_out.py`
- [HTML dashboard](https://github.com/cashhero/fabric-capacity-monitor/blob/main/src/fabric_capacity_monitor/report/html.py): `src/fabric_capacity_monitor/report/html.py`

### Other components

- **CLI user**
- **Azure services**
- **Fabric REST API**
- **Fabric workspaces**

## Connections

- CLI user → Command handler: runs command (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → User config: loads settings (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → Token provider: creates provider (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → Fabric API client: creates client (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → Azure ARM client: creates client (evidence: `src/fabric_capacity_monitor/cli.py`)
- Fabric API client → Token provider: gets tokens (evidence: `src/fabric_capacity_monitor/fabric_api.py`)
- Azure ARM client → Token provider: gets tokens (evidence: `src/fabric_capacity_monitor/arm.py`)
- Fabric API client → Fabric REST API: reads APIs (evidence: `README.md`)
- Azure ARM client → Azure services: reads capacity data (evidence: `src/fabric_capacity_monitor/arm.py`)
- Command handler → Activity collector: collects activity (evidence: `src/fabric_capacity_monitor/cli.py`)
- Activity collector → Fabric API client: fetches activity (evidence: `src/fabric_capacity_monitor/collect.py`)
- Activity collector → CU estimators: estimates consumption (evidence: `src/fabric_capacity_monitor/collect.py`)
- CU estimators → Consumption rates: uses rates (evidence: `src/fabric_capacity_monitor/cu.py`)
- Activity collector → Capacity records: builds operations (evidence: `src/fabric_capacity_monitor/collect.py`)
- Command handler → Azure ARM client: loads capacity history (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → Consumption rates: loads rates (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → Report analysis: analyses collection (evidence: `src/fabric_capacity_monitor/cli.py`)
- Report analysis → Timeline smoothing: builds timeline (evidence: `src/fabric_capacity_monitor/report/analysis.py`)
- Timeline smoothing → Capacity records: reads operations (evidence: `src/fabric_capacity_monitor/smoothing.py`)
- Timeline smoothing → Consumption rates: uses windows (evidence: `src/fabric_capacity_monitor/smoothing.py`)
- Report analysis → Capacity records: aggregates records (evidence: `src/fabric_capacity_monitor/report/analysis.py`)
- Command handler → Text report: renders report (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → JSON report: renders report (evidence: `src/fabric_capacity_monitor/cli.py`)
- Command handler → HTML dashboard: renders dashboard (evidence: `src/fabric_capacity_monitor/cli.py`)
- Text report → Report analysis: formats results (evidence: `src/fabric_capacity_monitor/report/text.py`)
- JSON report → Report analysis: serializes results (evidence: `src/fabric_capacity_monitor/report/json_out.py`)
- HTML dashboard → Report analysis: renders charts (evidence: `src/fabric_capacity_monitor/report/html.py`)
- Sub-run resolver → Capacity records: redistributes CU (evidence: `README.md`)
- Fabric REST API → Fabric workspaces: exposes workspace data (evidence: `README.md`)
