# sylva1027/waifu-usage architecture

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

- Interactive diagram: https://gitdiagram.com/sylva1027/waifu-usage
- Repository: https://github.com/sylva1027/waifu-usage

## Overview

Waifu Usage is a local dashboard for aggregating AI-coding-tool usage. The main workflow is: the user launches the local service, imports or scans harness logs, the service normalizes and stores usage, then queries and presents metrics, trends, quota windows and cost estimates in the browser. The full edition adds skins, sharing and achievements; Lite retains usage, trends and history management. Relationships involving unsampled modules are included only where the README or source index supports them; several feature branches are documented capabilities rather than inspected call paths.

Main entry points: [`src/waifu/usage-reader.js`](https://github.com/sylva1027/waifu-usage/blob/main/src/waifu/usage-reader.js) (Usage reader), [`src/server.js`](https://github.com/sylva1027/waifu-usage/blob/main/src/server.js) (HTTP service), [`public/app.js`](https://github.com/sylva1027/waifu-usage/blob/main/public/app.js) (Dashboard application), [`src/cli.js`](https://github.com/sylva1027/waifu-usage/blob/main/src/cli.js) (CLI launch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Local service"]
  node_cli["CLI launch<br/>[cli.js]"]
  node_server["HTTP service<br/>[server.js]"]
  node_core["Server core<br/>[server-core.js]"]
  node_executor["Usage executor"]
end

subgraph group_data["Usage data"]
  node_acquisition["Source acquisition"]
  node_adapters["Harness adapters<br/>[usage-sources.js]"]
  node_records[("Usage records")]
  node_metadata[("Usage metadata")]
  node_history["History archive<br/>[history-archive.js]"]
end

subgraph group_analysis["Queries and pricing"]
  node_reader["Usage reader<br/>[usage-reader.js]"]
  node_query["Range and grouping<br/>[usage-query.js]"]
  node_rollups["Usage rollups<br/>[usage-rollups.js]"]
  node_pricing["Pricing catalog<br/>[pricing.js]"]
  node_pricingstore[("Pricing persistence<br/>[pricing-store.js]")]
end

subgraph group_dashboard["Dashboard experience"]
  node_app["Dashboard application<br/>[app.js]"]
  node_lite["Lite application<br/>[app.js]"]
  node_render["Dashboard rendering"]
  node_trend["Trend analysis"]
  node_calendar["Calendar ranges<br/>[calendar.js]"]
  node_locale["Localization<br/>[locale.js]"]
end

subgraph group_personal["Personal features"]
  node_skins["Character skins<br/>[skins.js]"]
  node_sharing["Share cards<br/>[share-card.js]"]
  node_achievements["Achievements"]
end

node_user(("User"))
node_harnesses["Harness logs"]

node_user -->|"launches"| node_cli
node_cli -->|"starts"| node_server
node_server -->|"configures"| node_core
node_server -->|"creates"| node_executor
node_user -->|"selects logs"| node_harnesses
node_harnesses -->|"scans or imports"| node_acquisition
node_acquisition -.->|"dispatches sources"| node_adapters
node_executor -.->|"serves usage"| node_reader
node_reader -->|"reads"| node_records
node_reader -->|"reads"| node_metadata
node_reader -->|"resolves ranges"| node_query
node_reader -->|"aggregates with"| node_rollups
node_server -->|"supports archive import"| node_history
node_server -->|"loads catalog"| node_pricingstore
node_pricingstore -->|"provides catalog"| node_pricing
node_reader -->|"estimates costs"| node_pricing
node_user -->|"views dashboard"| node_app
node_app -->|"renders metrics"| node_render
node_app -->|"uses trend data"| node_trend
node_app -->|"uses date ranges"| node_calendar
node_app -->|"translates view"| node_locale
node_user -->|"chooses Lite"| node_lite
node_lite -->|"renders metrics"| node_render
node_user -->|"chooses themes"| node_skins
node_user -->|"creates share cards"| node_sharing
node_user -->|"reviews milestones"| node_achievements

click node_cli "https://github.com/sylva1027/waifu-usage/blob/main/src/cli.js"
click node_server "https://github.com/sylva1027/waifu-usage/blob/main/src/server.js"
click node_core "https://github.com/sylva1027/waifu-usage/blob/main/src/server-core.js"
click node_executor "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-executor-waifu.js"
click node_acquisition "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-source-acquisition.js"
click node_adapters "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-sources.js"
click node_records "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-record-store.js"
click node_metadata "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-metadata-store.js"
click node_history "https://github.com/sylva1027/waifu-usage/blob/main/src/history-archive.js"
click node_reader "https://github.com/sylva1027/waifu-usage/blob/main/src/waifu/usage-reader.js"
click node_query "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-query.js"
click node_rollups "https://github.com/sylva1027/waifu-usage/blob/main/src/usage-rollups.js"
click node_pricing "https://github.com/sylva1027/waifu-usage/blob/main/src/pricing.js"
click node_pricingstore "https://github.com/sylva1027/waifu-usage/blob/main/src/pricing-store.js"
click node_app "https://github.com/sylva1027/waifu-usage/blob/main/public/app.js"
click node_lite "https://github.com/sylva1027/waifu-usage/blob/main/public/lite/app.js"
click node_render "https://github.com/sylva1027/waifu-usage/blob/main/public/dashboard-render.js"
click node_trend "https://github.com/sylva1027/waifu-usage/blob/main/public/overview-trend-data.js"
click node_calendar "https://github.com/sylva1027/waifu-usage/blob/main/public/calendar.js"
click node_locale "https://github.com/sylva1027/waifu-usage/blob/main/public/locale.js"
click node_skins "https://github.com/sylva1027/waifu-usage/blob/main/public/skins.js"
click node_sharing "https://github.com/sylva1027/waifu-usage/blob/main/public/share-card.js"
click node_achievements "https://github.com/sylva1027/waifu-usage/blob/main/src/achievement-runtime.js"

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_server,node_core,node_executor,node_user toneBlue
class node_acquisition,node_adapters,node_records,node_metadata,node_history toneAmber
class node_reader,node_query,node_rollups,node_pricing,node_pricingstore toneMint
class node_app,node_lite,node_render,node_trend,node_calendar,node_locale toneRose
class node_skins,node_sharing,node_achievements,node_harnesses toneIndigo
```

## Components

### Local service

- [CLI launch](https://github.com/sylva1027/waifu-usage/blob/main/src/cli.js): `src/cli.js`
- [HTTP service](https://github.com/sylva1027/waifu-usage/blob/main/src/server.js): `src/server.js`
- [Server core](https://github.com/sylva1027/waifu-usage/blob/main/src/server-core.js): `src/server-core.js`
- [Usage executor](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-executor-waifu.js): `src/usage-executor-waifu.js`

### Usage data

- [Source acquisition](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-source-acquisition.js): `src/usage-source-acquisition.js`
- [Harness adapters](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-sources.js): `src/usage-sources.js`
- [Usage records](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-record-store.js): `src/usage-record-store.js`
- [Usage metadata](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-metadata-store.js): `src/usage-metadata-store.js`
- [History archive](https://github.com/sylva1027/waifu-usage/blob/main/src/history-archive.js): `src/history-archive.js`

### Queries and pricing

- [Usage reader](https://github.com/sylva1027/waifu-usage/blob/main/src/waifu/usage-reader.js): `src/waifu/usage-reader.js`
- [Range and grouping](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-query.js): `src/usage-query.js`
- [Usage rollups](https://github.com/sylva1027/waifu-usage/blob/main/src/usage-rollups.js): `src/usage-rollups.js`
- [Pricing catalog](https://github.com/sylva1027/waifu-usage/blob/main/src/pricing.js): `src/pricing.js`
- [Pricing persistence](https://github.com/sylva1027/waifu-usage/blob/main/src/pricing-store.js): `src/pricing-store.js`

### Dashboard experience

- [Dashboard application](https://github.com/sylva1027/waifu-usage/blob/main/public/app.js): `public/app.js`
- [Lite application](https://github.com/sylva1027/waifu-usage/blob/main/public/lite/app.js): `public/lite/app.js`
- [Dashboard rendering](https://github.com/sylva1027/waifu-usage/blob/main/public/dashboard-render.js): `public/dashboard-render.js`
- [Trend analysis](https://github.com/sylva1027/waifu-usage/blob/main/public/overview-trend-data.js): `public/overview-trend-data.js`
- [Calendar ranges](https://github.com/sylva1027/waifu-usage/blob/main/public/calendar.js): `public/calendar.js`
- [Localization](https://github.com/sylva1027/waifu-usage/blob/main/public/locale.js): `public/locale.js`

### Personal features

- [Character skins](https://github.com/sylva1027/waifu-usage/blob/main/public/skins.js): `public/skins.js`
- [Share cards](https://github.com/sylva1027/waifu-usage/blob/main/public/share-card.js): `public/share-card.js`
- [Achievements](https://github.com/sylva1027/waifu-usage/blob/main/src/achievement-runtime.js): `src/achievement-runtime.js`

### Other components

- **User**
- **Harness logs**

## Connections

- User → CLI launch: launches (evidence: `README.md`)
- CLI launch → HTTP service: starts (evidence: `README.md`)
- HTTP service → Server core: configures (evidence: `src/server.js`)
- HTTP service → Usage executor: creates (evidence: `src/server.js`)
- User → Harness logs: selects logs (evidence: `README.md`)
- Harness logs → Source acquisition: scans or imports (evidence: `README.md`)
- Source acquisition → Harness adapters: dispatches sources
- Usage executor → Usage reader: serves usage
- Usage reader → Usage records: reads (evidence: `src/waifu/usage-reader.js`)
- Usage reader → Usage metadata: reads (evidence: `src/waifu/usage-reader.js`)
- Usage reader → Range and grouping: resolves ranges (evidence: `src/waifu/usage-reader.js`)
- Usage reader → Usage rollups: aggregates with (evidence: `src/waifu/usage-reader.js`)
- HTTP service → History archive: supports archive import (evidence: `src/server.js`)
- HTTP service → Pricing persistence: loads catalog (evidence: `src/server.js`)
- Pricing persistence → Pricing catalog: provides catalog (evidence: `src/server.js`)
- Usage reader → Pricing catalog: estimates costs (evidence: `src/waifu/usage-reader.js`)
- User → Dashboard application: views dashboard (evidence: `README.md`)
- Dashboard application → Dashboard rendering: renders metrics (evidence: `public/app.js`)
- Dashboard application → Trend analysis: uses trend data (evidence: `public/app.js`)
- Dashboard application → Calendar ranges: uses date ranges (evidence: `public/app.js`)
- Dashboard application → Localization: translates view (evidence: `public/app.js`)
- User → Lite application: chooses Lite (evidence: `README.md`)
- Lite application → Dashboard rendering: renders metrics (evidence: `public/lite/app.js`)
- User → Character skins: chooses themes (evidence: `README.md`)
- User → Share cards: creates share cards (evidence: `README.md`)
- User → Achievements: reviews milestones (evidence: `README.md`)
