# oscard-06/fenn-ai_usage architecture

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

- Interactive diagram: https://gitdiagram.com/oscard-06/fenn-ai_usage
- Repository: https://github.com/oscard-06/fenn-ai_usage
- Video tour (about a minute): https://gitdiagram.com/oscard-06/fenn-ai_usage/video

## Overview

AI Usage for Fenn is a Windows taskbar and floating-notch plugin that aggregates live quotas across AI providers. Users link detected CLI credentials or configure tokens/custom JSON; Fenn events enter the plugin controller, which updates persistent account state, refreshes providers, and renders taskbar, popup, and notch views. Provider fetchers and parsers normalize quota data for display and cached recovery. README capabilities include per-counter settings, alerts, custom icons, and Antigravity statusLine sync. Some source excerpts are partial, so unverified subsystem links are omitted.

Main entry points: [`ai_usage/views.py`](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/views.py) (Surface orchestrator), [`ai_usage/state.py`](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/state.py) (Account and quota state), [`ai_usage/fetchers.py`](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/fetchers.py) (Provider fetchers), [`main.py`](https://github.com/oscard-06/fenn-ai_usage/blob/main/main.py) (Plugin controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Plugin runtime"]
  node_controller["Plugin controller<br/>[main.py]"]
  node_fenn_api["Fenn plugin API<br/>[fenn.py]"]
end

subgraph group_accounts["Accounts and state"]
  node_state["Account and quota state<br/>[state.py]"]
end

subgraph group_provider["Quota providers"]
  node_models["Normalized quota models<br/>[models.py]"]
  node_fetchers["Provider fetchers<br/>[fetchers.py]"]
  node_parsers["Quota parsers<br/>[parsers.py]"]
  node_http["HTTP client<br/>[http_client.py]"]
end

subgraph group_surfaces["Display and settings"]
  node_plugin_views["Surface orchestrator<br/>[views.py]"]
  node_ui_canvas["Canvas layouts<br/>[ui_canvas.py]"]
  node_compact_views["Compact displays<br/>[compact_views.py]"]
  node_account_views["Account screens<br/>[account_views.py]"]
  node_settings_views["Settings screens<br/>[settings_views.py]"]
end

subgraph group_integrations["Local integrations"]
  node_cli_auth["CLI credentials and refresh<br/>[cli_auth.py]"]
  node_statusline["Antigravity statusLine<br/>[agy_statusline.py]"]
  node_icons["Provider and custom icons<br/>[icons.py]"]
end

node_developer(("Fenn user"))
node_fenn_host(("Fenn host"))

node_developer -->|"uses plugin"| node_fenn_host
node_fenn_host -->|"dispatches events"| node_fenn_api
node_fenn_api -->|"runs handlers"| node_controller
node_controller -->|"updates state"| node_state
node_controller -->|"requests render"| node_plugin_views
node_plugin_views -->|"builds surfaces"| node_fenn_api
node_plugin_views -->|"renders accounts"| node_account_views
node_plugin_views -->|"renders compact"| node_compact_views
node_plugin_views -->|"renders settings"| node_settings_views
node_plugin_views -->|"builds layouts"| node_ui_canvas
node_state -->|"refreshes accounts"| node_fetchers
node_fetchers -->|"reads credentials"| node_cli_auth
node_fetchers -->|"requests APIs"| node_http
node_fetchers -->|"parses responses"| node_parsers
node_parsers -->|"creates windows"| node_models
node_fetchers -->|"builds results"| node_models
node_state -->|"formats quotas"| node_models
node_account_views -->|"reuses components"| node_compact_views
node_settings_views -->|"reuses components"| node_compact_views
node_account_views -->|"formats account data"| node_models
node_settings_views -->|"reads settings"| node_state
node_compact_views -->|"resolves icons"| node_icons
node_state -->|"manages custom icons"| node_icons
node_state -->|"scans CLIs"| node_cli_auth
node_controller -.->|"enables sync"| node_statusline

click node_controller "https://github.com/oscard-06/fenn-ai_usage/blob/main/main.py"
click node_fenn_api "https://github.com/oscard-06/fenn-ai_usage/blob/main/fenn.py"
click node_plugin_views "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/views.py"
click node_ui_canvas "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/ui_canvas.py"
click node_compact_views "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/compact_views.py"
click node_account_views "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/account_views.py"
click node_settings_views "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/settings_views.py"
click node_state "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/state.py"
click node_models "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/models.py"
click node_fetchers "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/fetchers.py"
click node_parsers "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/parsers.py"
click node_http "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/http_client.py"
click node_cli_auth "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/cli_auth.py"
click node_statusline "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/agy_statusline.py"
click node_icons "https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/icons.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_controller,node_fenn_api,node_developer toneBlue
class node_state toneAmber
class node_models,node_fetchers,node_parsers,node_http toneMint
class node_plugin_views,node_ui_canvas,node_compact_views,node_account_views,node_settings_views toneRose
class node_cli_auth,node_statusline,node_icons,node_fenn_host toneIndigo
```

## Components

### Plugin runtime

- [Plugin controller](https://github.com/oscard-06/fenn-ai_usage/blob/main/main.py): `main.py`
- [Fenn plugin API](https://github.com/oscard-06/fenn-ai_usage/blob/main/fenn.py): `fenn.py`

### Accounts and state

- [Account and quota state](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/state.py): `ai_usage/state.py`

### Quota providers

- [Normalized quota models](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/models.py): `ai_usage/models.py`
- [Provider fetchers](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/fetchers.py): `ai_usage/fetchers.py`
- [Quota parsers](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/parsers.py): `ai_usage/parsers.py`
- [HTTP client](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/http_client.py): `ai_usage/http_client.py`

### Display and settings

- [Surface orchestrator](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/views.py): `ai_usage/views.py`
- [Canvas layouts](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/ui_canvas.py): `ai_usage/ui_canvas.py`
- [Compact displays](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/compact_views.py): `ai_usage/compact_views.py`
- [Account screens](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/account_views.py): `ai_usage/account_views.py`
- [Settings screens](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/settings_views.py): `ai_usage/settings_views.py`

### Local integrations

- [CLI credentials and refresh](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/cli_auth.py): `ai_usage/cli_auth.py`
- [Antigravity statusLine](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/agy_statusline.py): `ai_usage/agy_statusline.py`
- [Provider and custom icons](https://github.com/oscard-06/fenn-ai_usage/blob/main/ai_usage/icons.py): `ai_usage/icons.py`

### Other components

- **Fenn user**
- **Fenn host**

## Connections

- Fenn user → Fenn host: uses plugin (evidence: `README.md`)
- Fenn host → Fenn plugin API: dispatches events (evidence: `fenn.py`)
- Fenn plugin API → Plugin controller: runs handlers (evidence: `main.py`)
- Plugin controller → Account and quota state: updates state (evidence: `main.py`)
- Plugin controller → Surface orchestrator: requests render (evidence: `main.py`)
- Surface orchestrator → Fenn plugin API: builds surfaces (evidence: `ai_usage/views.py`)
- Surface orchestrator → Account screens: renders accounts (evidence: `ai_usage/views.py`)
- Surface orchestrator → Compact displays: renders compact (evidence: `ai_usage/views.py`)
- Surface orchestrator → Settings screens: renders settings (evidence: `ai_usage/views.py`)
- Surface orchestrator → Canvas layouts: builds layouts (evidence: `ai_usage/views.py`)
- Account and quota state → Provider fetchers: refreshes accounts (evidence: `ai_usage/state.py`)
- Provider fetchers → CLI credentials and refresh: reads credentials (evidence: `ai_usage/fetchers.py`)
- Provider fetchers → HTTP client: requests APIs (evidence: `ai_usage/fetchers.py`)
- Provider fetchers → Quota parsers: parses responses (evidence: `ai_usage/fetchers.py`)
- Quota parsers → Normalized quota models: creates windows (evidence: `ai_usage/parsers.py`)
- Provider fetchers → Normalized quota models: builds results (evidence: `ai_usage/fetchers.py`)
- Account and quota state → Normalized quota models: formats quotas (evidence: `ai_usage/state.py`)
- Account screens → Compact displays: reuses components (evidence: `ai_usage/account_views.py`)
- Settings screens → Compact displays: reuses components (evidence: `ai_usage/settings_views.py`)
- Account screens → Normalized quota models: formats account data (evidence: `ai_usage/account_views.py`)
- Settings screens → Account and quota state: reads settings (evidence: `ai_usage/settings_views.py`)
- Compact displays → Provider and custom icons: resolves icons (evidence: `ai_usage/compact_views.py`)
- Account and quota state → Provider and custom icons: manages custom icons (evidence: `ai_usage/state.py`)
- Account and quota state → CLI credentials and refresh: scans CLIs (evidence: `ai_usage/state.py`)
- Plugin controller → Antigravity statusLine: enables sync
