# fernandalumin/superlight architecture

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

- Interactive diagram: https://gitdiagram.com/fernandalumin/superlight
- Repository: https://github.com/fernandalumin/superlight

## Overview

SuperLight is a local Codex usage collector and cost dashboard, with optional HTTP forwarding. The workflow is: configure Codex to send OTLP events and use the local proxy; the server receives events, usage normalization filters and deduplicates completed responses, and SQLite persists a private ledger. Pricing and calendar aggregation produce summaries for the CLI and local dashboard, while the macOS menu-bar app presents today’s estimate and dashboard. The README documents export, bilingual UI, and optional upstream proxy; unsampled relationships are omitted unless documented or visible in excerpts.

Main entry points: [`superlight/server.py`](https://github.com/fernandalumin/superlight/blob/main/superlight/server.py) (Local server), [`superlight/store.py`](https://github.com/fernandalumin/superlight/blob/main/superlight/store.py) (SQLite ledger), [`superlight/pricing.py`](https://github.com/fernandalumin/superlight/blob/main/superlight/pricing.py) (Price estimates), [`superlight/cli.py`](https://github.com/fernandalumin/superlight/blob/main/superlight/cli.py) (CLI commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop experience"]
  node_appkit["Menu bar app<br/>[SuperLight.swift]"]
  node_webui["Dashboard UI<br/>[app.js]"]
  node_webassets["Dashboard page<br/>[index.html]"]
end

subgraph group_collection["Collection and forwarding"]
  node_server["Local server<br/>[server.py]"]
  node_proxy["HTTP forwarding<br/>[proxy.py]"]
end

subgraph group_ledger["Usage ledger"]
  node_normalizer["OTLP normalizer<br/>[usage.py]"]
  node_store[("SQLite ledger<br/>[store.py]")]
end

subgraph group_insights["Cost and reporting"]
  node_pricing["Price estimates<br/>[pricing.py]"]
  node_price_catalog["Price catalog<br/>[prices.json]"]
  node_dashboard["Period aggregation<br/>[dashboard.py]"]
  node_cli["CLI commands<br/>[cli.py]"]
end

node_user(("Codex user"))
node_codex["Codex CLI"]
node_upstream["Optional upstream proxy"]
node_browser(("Local browser"))

node_user -->|"uses"| node_appkit
node_user -->|"configures"| node_codex
node_codex -->|"posts OTLP"| node_server
node_codex -->|"forwards traffic"| node_proxy
node_appkit -->|"queries status"| node_server
node_server -->|"normalizes events"| node_normalizer
node_server -->|"dispatches traffic"| node_proxy
node_proxy -.->|"forwards optionally"| node_upstream
node_server -->|"persists usage"| node_store
node_normalizer -->|"provides events"| node_store
node_cli -->|"starts service"| node_server
node_pricing -->|"loads rates"| node_price_catalog
node_pricing -->|"reads records"| node_store
node_dashboard -->|"summarizes costs"| node_pricing
node_dashboard -->|"reads records"| node_store
node_server -->|"serves dashboard data"| node_dashboard
node_browser -->|"requests dashboard"| node_server
node_server -.->|"serves interface"| node_webui
node_webui -.->|"renders page"| node_webassets
node_cli -->|"summarizes estimates"| node_pricing
node_cli -->|"exports records"| node_store

click node_appkit "https://github.com/fernandalumin/superlight/blob/main/native/SuperLight.swift"
click node_webui "https://github.com/fernandalumin/superlight/blob/main/superlight/web/app.js"
click node_webassets "https://github.com/fernandalumin/superlight/blob/main/superlight/web/index.html"
click node_server "https://github.com/fernandalumin/superlight/blob/main/superlight/server.py"
click node_proxy "https://github.com/fernandalumin/superlight/blob/main/superlight/proxy.py"
click node_normalizer "https://github.com/fernandalumin/superlight/blob/main/superlight/usage.py"
click node_store "https://github.com/fernandalumin/superlight/blob/main/superlight/store.py"
click node_pricing "https://github.com/fernandalumin/superlight/blob/main/superlight/pricing.py"
click node_price_catalog "https://github.com/fernandalumin/superlight/blob/main/superlight/prices.json"
click node_dashboard "https://github.com/fernandalumin/superlight/blob/main/superlight/dashboard.py"
click node_cli "https://github.com/fernandalumin/superlight/blob/main/superlight/cli.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_appkit,node_webui,node_webassets,node_user,node_browser toneBlue
class node_server,node_proxy toneAmber
class node_normalizer,node_store toneMint
class node_pricing,node_price_catalog,node_dashboard,node_cli toneRose
class node_codex,node_upstream toneIndigo
```

## Components

### Desktop experience

- [Menu bar app](https://github.com/fernandalumin/superlight/blob/main/native/SuperLight.swift): `native/SuperLight.swift`
- [Dashboard UI](https://github.com/fernandalumin/superlight/blob/main/superlight/web/app.js): `superlight/web/app.js`
- [Dashboard page](https://github.com/fernandalumin/superlight/blob/main/superlight/web/index.html): `superlight/web/index.html`

### Collection and forwarding

- [Local server](https://github.com/fernandalumin/superlight/blob/main/superlight/server.py): `superlight/server.py`
- [HTTP forwarding](https://github.com/fernandalumin/superlight/blob/main/superlight/proxy.py): `superlight/proxy.py`

### Usage ledger

- [OTLP normalizer](https://github.com/fernandalumin/superlight/blob/main/superlight/usage.py): `superlight/usage.py`
- [SQLite ledger](https://github.com/fernandalumin/superlight/blob/main/superlight/store.py): `superlight/store.py`

### Cost and reporting

- [Price estimates](https://github.com/fernandalumin/superlight/blob/main/superlight/pricing.py): `superlight/pricing.py`
- [Price catalog](https://github.com/fernandalumin/superlight/blob/main/superlight/prices.json): `superlight/prices.json`
- [Period aggregation](https://github.com/fernandalumin/superlight/blob/main/superlight/dashboard.py): `superlight/dashboard.py`
- [CLI commands](https://github.com/fernandalumin/superlight/blob/main/superlight/cli.py): `superlight/cli.py`

### Other components

- **Codex user**
- **Codex CLI**
- **Optional upstream proxy**
- **Local browser**

## Connections

- Codex user → Menu bar app: uses (evidence: `README.md`)
- Codex user → Codex CLI: configures (evidence: `README.md`)
- Codex CLI → Local server: posts OTLP (evidence: `README.md`)
- Codex CLI → HTTP forwarding: forwards traffic (evidence: `README.md`)
- Menu bar app → Local server: queries status (evidence: `README.md`)
- Local server → OTLP normalizer: normalizes events (evidence: `superlight/server.py`)
- Local server → HTTP forwarding: dispatches traffic (evidence: `superlight/server.py`)
- HTTP forwarding → Optional upstream proxy: forwards optionally (evidence: `README.md`)
- Local server → SQLite ledger: persists usage (evidence: `superlight/server.py`)
- OTLP normalizer → SQLite ledger: provides events
- CLI commands → Local server: starts service (evidence: `superlight/cli.py`)
- Price estimates → Price catalog: loads rates (evidence: `superlight/pricing.py`)
- Price estimates → SQLite ledger: reads records (evidence: `superlight/pricing.py`)
- Period aggregation → Price estimates: summarizes costs (evidence: `superlight/dashboard.py`)
- Period aggregation → SQLite ledger: reads records (evidence: `superlight/dashboard.py`)
- Local server → Period aggregation: serves dashboard data (evidence: `superlight/server.py`)
- Local browser → Local server: requests dashboard (evidence: `README.md`)
- Local server → Dashboard UI: serves interface
- Dashboard UI → Dashboard page: renders page
- CLI commands → Price estimates: summarizes estimates (evidence: `superlight/cli.py`)
- CLI commands → SQLite ledger: exports records (evidence: `superlight/cli.py`)
