# sylva1027/waifu-agent-usage architecture

> Architecture diagram of the GitHub repository sylva1027/waifu-agent-usage, 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/sylva1027/waifu-agent-usage
- Repository: https://github.com/sylva1027/waifu-agent-usage

## Overview

Waifu Agent Usage is a local dashboard for aggregating AI-coding usage, exploring token trends and quotas, estimating costs, and personalizing or sharing results. The main workflow is: a local user starts the service, scans or imports harness logs, the service exposes usage for the dashboard, and the user reviews and manages the resulting history. The graph also preserves documented pricing, achievements, sharing, themes, and Lite capabilities. Some internal modules were not sampled; those subsystems are represented only where the README or source index supports them.

Main entry points: [`src/server.js`](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/server.js) (HTTP service), [`public/app.js`](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/app.js) (Dashboard app), [`src/waifu/usage-reader.js`](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/waifu/usage-reader.js) (Usage reader), [`public/lite/app.js`](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/lite/app.js) (Lite dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Service and ingestion"]
  node_cli["CLI launch<br/>[cli.js]"]
  node_server["HTTP service<br/>[server.js]"]
  node_executor["Usage executor"]
  node_sources["Harness sources<br/>[usage-sources.js]"]
  node_proof["Windows source proof<br/>[main.rs]"]
end

subgraph group_analytics["Usage analytics"]
  node_reader["Usage reader<br/>[usage-reader.js]"]
  node_query["Usage queries<br/>[usage-query.js]"]
  node_rollups["Usage rollups<br/>[usage-rollups.js]"]
  node_usagefields["Usage field rules<br/>[usage-fields.js]"]
  node_pricing["Pricing estimates<br/>[pricing.js]"]
  node_quota["Quota usage"]
end

subgraph group_dashboard["Dashboard experience"]
  node_dashboard["Dashboard app<br/>[app.js]"]
  node_lite["Lite dashboard<br/>[app.js]"]
  node_render["Dashboard rendering"]
  node_calendar["Date and ranges<br/>[calendar.js]"]
  node_locale["Localization<br/>[locale.js]"]
end

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

subgraph group_retention["History management"]
  node_archive["History archive<br/>[history-archive.js]"]
  node_backup["History backup<br/>[history-backup.js]"]
end

node_user(("Local user"))

node_user -->|"starts service"| node_cli
node_cli -.->|"launches"| node_server
node_user -->|"scans or imports"| node_sources
node_server -->|"creates"| node_executor
node_server -.->|"serves usage"| node_reader
node_server -->|"configures pricing"| node_pricing
node_server -->|"loads archive imports"| node_archive
node_sources -.->|"uses native proof"| node_proof
node_reader -->|"resolves ranges"| node_query
node_reader -->|"uses aggregates"| node_rollups
node_query -->|"uses field rules"| node_usagefields
node_reader -->|"prices usage"| node_pricing
node_user -->|"opens dashboard"| node_dashboard
node_server -.->|"provides dashboard"| node_dashboard
node_dashboard -->|"renders views"| node_render
node_dashboard -->|"uses date picker"| node_calendar
node_dashboard -->|"translates page"| node_locale
node_lite -->|"renders views"| node_render
node_lite -->|"uses date picker"| node_calendar
node_user -->|"chooses themes"| node_skins
node_user -->|"creates share cards"| node_share
node_user -->|"reviews achievements"| node_achievements
node_user -->|"backs up history"| node_backup
node_user -->|"imports or restores"| node_archive

click node_cli "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/cli.js"
click node_server "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/server.js"
click node_executor "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-executor-waifu.js"
click node_sources "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-sources.js"
click node_proof "https://github.com/sylva1027/waifu-agent-usage/blob/main/native/windows-source-proof/src/main.rs"
click node_reader "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/waifu/usage-reader.js"
click node_query "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-query.js"
click node_rollups "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-rollups.js"
click node_usagefields "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/usage-fields.js"
click node_pricing "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/pricing.js"
click node_quota "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/quota-usage-source.js"
click node_dashboard "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/app.js"
click node_lite "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/lite/app.js"
click node_render "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/dashboard-render.js"
click node_calendar "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/calendar.js"
click node_locale "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/locale.js"
click node_skins "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/skins.js"
click node_share "https://github.com/sylva1027/waifu-agent-usage/blob/main/public/share-dialog.js"
click node_achievements "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/achievement-runtime.js"
click node_archive "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/history-archive.js"
click node_backup "https://github.com/sylva1027/waifu-agent-usage/blob/main/src/history-backup.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_executor,node_sources,node_proof,node_user toneBlue
class node_reader,node_query,node_rollups,node_usagefields,node_pricing,node_quota toneAmber
class node_dashboard,node_lite,node_render,node_calendar,node_locale toneMint
class node_skins,node_share,node_achievements toneRose
class node_archive,node_backup toneIndigo
```

## Components

### Service and ingestion

- [CLI launch](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/cli.js): `src/cli.js`
- [HTTP service](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/server.js): `src/server.js`
- [Usage executor](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-executor-waifu.js): `src/usage-executor-waifu.js`
- [Harness sources](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-sources.js): `src/usage-sources.js`
- [Windows source proof](https://github.com/sylva1027/waifu-agent-usage/blob/main/native/windows-source-proof/src/main.rs): `native/windows-source-proof/src/main.rs`

### Usage analytics

- [Usage reader](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/waifu/usage-reader.js): `src/waifu/usage-reader.js`
- [Usage queries](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-query.js): `src/usage-query.js`
- [Usage rollups](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/usage-rollups.js): `src/usage-rollups.js`
- [Usage field rules](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/usage-fields.js): `public/usage-fields.js`
- [Pricing estimates](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/pricing.js): `src/pricing.js`
- [Quota usage](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/quota-usage-source.js): `src/quota-usage-source.js`

### Dashboard experience

- [Dashboard app](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/app.js): `public/app.js`
- [Lite dashboard](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/lite/app.js): `public/lite/app.js`
- [Dashboard rendering](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/dashboard-render.js): `public/dashboard-render.js`
- [Date and ranges](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/calendar.js): `public/calendar.js`
- [Localization](https://github.com/sylva1027/waifu-agent-usage/blob/main/public/locale.js): `public/locale.js`

### Personal features

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

### History management

- [History archive](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/history-archive.js): `src/history-archive.js`
- [History backup](https://github.com/sylva1027/waifu-agent-usage/blob/main/src/history-backup.js): `src/history-backup.js`

### Other components

- **Local user**

## Connections

- Local user → CLI launch: starts service (evidence: `README.md`)
- CLI launch → HTTP service: launches
- Local user → Harness sources: scans or imports (evidence: `README.md`)
- HTTP service → Usage executor: creates (evidence: `src/server.js`)
- HTTP service → Usage reader: serves usage
- HTTP service → Pricing estimates: configures pricing (evidence: `src/server.js`)
- HTTP service → History archive: loads archive imports (evidence: `src/server.js`)
- Harness sources → Windows source proof: uses native proof
- Usage reader → Usage queries: resolves ranges (evidence: `src/waifu/usage-reader.js`)
- Usage reader → Usage rollups: uses aggregates (evidence: `src/waifu/usage-reader.js`)
- Usage queries → Usage field rules: uses field rules (evidence: `src/usage-query.js`)
- Usage reader → Pricing estimates: prices usage (evidence: `src/waifu/usage-reader.js`)
- Local user → Dashboard app: opens dashboard (evidence: `README.md`)
- HTTP service → Dashboard app: provides dashboard
- Dashboard app → Dashboard rendering: renders views (evidence: `public/app.js`)
- Dashboard app → Date and ranges: uses date picker (evidence: `public/app.js`)
- Dashboard app → Localization: translates page (evidence: `public/app.js`)
- Lite dashboard → Dashboard rendering: renders views (evidence: `public/lite/app.js`)
- Lite dashboard → Date and ranges: uses date picker (evidence: `public/lite/app.js`)
- Local user → Character themes: chooses themes (evidence: `README.md`)
- Local user → Share cards: creates share cards (evidence: `README.md`)
- Local user → Achievements: reviews achievements (evidence: `README.md`)
- Local user → History backup: backs up history (evidence: `README.md`)
- Local user → History archive: imports or restores (evidence: `README.md`)
