# violet-3/account_book architecture

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

- Interactive diagram: https://gitdiagram.com/violet-3/account_book
- Repository: https://github.com/violet-3/account_book

## Overview

旺财 is a local-first attendance, payroll-estimation, savings, and work-record app delivered as a web app/PWA and wrapped for Android and iOS. The user records attendance and settings, reviews calendar and pay estimates, manages savings goals, and can keep an evidence timeline and export a ZIP. The browser-side app coordinates the domain modules and encrypted local storage; holiday schedules can be fetched on request. The README documents capabilities beyond the sampled excerpts, so unshown calculation and savings wiring is marked unverified rather than treated as a confirmed call. Both root `js/` and packaged `www/js/` copies exist.

Main entry points: [`js/app.js`](https://github.com/violet-3/account_book/blob/main/js/app.js) (App coordinator), [`index.html`](https://github.com/violet-3/account_book/blob/main/index.html) (Web interface), [`js/evidence.js`](https://github.com/violet-3/account_book/blob/main/js/evidence.js) (Evidence timeline), [`js/holiday.js`](https://github.com/violet-3/account_book/blob/main/js/holiday.js) (Holiday updates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["App experience"]
  node_web_ui["Web interface<br/>[index.html]"]
  node_app_logic["App coordinator<br/>[app.js]"]
end

subgraph group_work_money["Work and money"]
  node_attendance["Attendance records<br/>[app.js]"]
  node_payroll["Pay estimates<br/>[calc.js]"]
  node_schedule_data["Rates and holidays<br/>[data.js]"]
  node_holiday_rules["Holiday updates<br/>[holiday.js]"]
  node_savings["Savings goals<br/>[savings.js]"]
end

subgraph group_local_data["Local data and evidence"]
  node_vault_crypto["Vault encryption<br/>[secure.js]"]
  node_ledger_store[("Ledger and exports<br/>[db.js]")]
  node_evidence["Evidence timeline<br/>[evidence.js]"]
  node_attachment_store[("Encrypted attachments<br/>[evidence.js]")]
end

subgraph group_clients["Offline and clients"]
  node_pwa_cache[("Offline cache<br/>[sw.js]")]
  node_static_host["Static file server<br/>[server.js]"]
  node_android_client["Android wrapper<br/>[MainActivity.java]"]
  node_ios_client["iOS bridge"]
end

node_worker(("Worker"))
node_holiday_service["Holiday source"]

node_worker -->|"uses"| node_web_ui
node_web_ui -.->|"mounts"| node_app_logic
node_app_logic -->|"records"| node_attendance
node_app_logic -->|"creates events"| node_evidence
node_app_logic -->|"writes vault"| node_ledger_store
node_app_logic -->|"opens vault"| node_vault_crypto
node_evidence -->|"encrypts attachments"| node_vault_crypto
node_evidence -->|"reads and writes"| node_attachment_store
node_app_logic -.->|"calculates pay"| node_payroll
node_app_logic -.->|"manages goals"| node_savings
node_app_logic -->|"updates schedules"| node_holiday_rules
node_holiday_rules -.->|"fetches year"| node_holiday_service
node_worker -->|"requests app"| node_static_host
node_static_host -->|"serves files"| node_web_ui
node_web_ui -.->|"registers offline use"| node_pwa_cache
node_worker -->|"uses"| node_android_client
node_worker -->|"uses"| node_ios_client

click node_web_ui "https://github.com/violet-3/account_book/blob/main/index.html"
click node_app_logic "https://github.com/violet-3/account_book/blob/main/js/app.js"
click node_attendance "https://github.com/violet-3/account_book/blob/main/js/app.js"
click node_payroll "https://github.com/violet-3/account_book/blob/main/js/calc.js"
click node_schedule_data "https://github.com/violet-3/account_book/blob/main/js/data.js"
click node_holiday_rules "https://github.com/violet-3/account_book/blob/main/js/holiday.js"
click node_savings "https://github.com/violet-3/account_book/blob/main/js/savings.js"
click node_vault_crypto "https://github.com/violet-3/account_book/blob/main/js/secure.js"
click node_ledger_store "https://github.com/violet-3/account_book/blob/main/js/db.js"
click node_evidence "https://github.com/violet-3/account_book/blob/main/js/evidence.js"
click node_attachment_store "https://github.com/violet-3/account_book/blob/main/js/evidence.js"
click node_pwa_cache "https://github.com/violet-3/account_book/blob/main/sw.js"
click node_static_host "https://github.com/violet-3/account_book/blob/main/server.js"
click node_android_client "https://github.com/violet-3/account_book/blob/main/android/app/src/main/java/com/violet3/dagongledger/MainActivity.java"
click node_ios_client "https://github.com/violet-3/account_book/blob/main/ios/App/App/SceneDelegate.swift"

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_web_ui,node_app_logic toneBlue
class node_attendance,node_payroll,node_schedule_data,node_holiday_rules,node_savings toneAmber
class node_vault_crypto,node_ledger_store,node_evidence,node_attachment_store toneMint
class node_pwa_cache,node_static_host,node_android_client,node_ios_client,node_worker toneRose
class node_holiday_service toneIndigo
```

## Components

### App experience

- [Web interface](https://github.com/violet-3/account_book/blob/main/index.html): `index.html`
- [App coordinator](https://github.com/violet-3/account_book/blob/main/js/app.js): `js/app.js`

### Work and money

- [Attendance records](https://github.com/violet-3/account_book/blob/main/js/app.js): `js/app.js`
- [Pay estimates](https://github.com/violet-3/account_book/blob/main/js/calc.js): `js/calc.js`
- [Rates and holidays](https://github.com/violet-3/account_book/blob/main/js/data.js): `js/data.js`
- [Holiday updates](https://github.com/violet-3/account_book/blob/main/js/holiday.js): `js/holiday.js`
- [Savings goals](https://github.com/violet-3/account_book/blob/main/js/savings.js): `js/savings.js`

### Local data and evidence

- [Vault encryption](https://github.com/violet-3/account_book/blob/main/js/secure.js): `js/secure.js`
- [Ledger and exports](https://github.com/violet-3/account_book/blob/main/js/db.js): `js/db.js`
- [Evidence timeline](https://github.com/violet-3/account_book/blob/main/js/evidence.js): `js/evidence.js`
- [Encrypted attachments](https://github.com/violet-3/account_book/blob/main/js/evidence.js): `js/evidence.js`

### Offline and clients

- [Offline cache](https://github.com/violet-3/account_book/blob/main/sw.js): `sw.js`
- [Static file server](https://github.com/violet-3/account_book/blob/main/server.js): `server.js`
- [Android wrapper](https://github.com/violet-3/account_book/blob/main/android/app/src/main/java/com/violet3/dagongledger/MainActivity.java): `android/app/src/main/java/com/violet3/dagongledger/MainActivity.java`
- [iOS bridge](https://github.com/violet-3/account_book/blob/main/ios/App/App/SceneDelegate.swift): `ios/App/App/SceneDelegate.swift`

### Other components

- **Worker**
- **Holiday source**

## Connections

- Worker → Web interface: uses (evidence: `README.md`)
- Web interface → App coordinator: mounts
- App coordinator → Attendance records: records (evidence: `js/app.js`)
- App coordinator → Evidence timeline: creates events (evidence: `js/app.js`)
- App coordinator → Ledger and exports: writes vault (evidence: `js/app.js`)
- App coordinator → Vault encryption: opens vault (evidence: `js/app.js`)
- Evidence timeline → Vault encryption: encrypts attachments (evidence: `js/evidence.js`)
- Evidence timeline → Encrypted attachments: reads and writes (evidence: `js/evidence.js`)
- App coordinator → Pay estimates: calculates pay
- App coordinator → Savings goals: manages goals
- App coordinator → Holiday updates: updates schedules (evidence: `js/app.js`)
- Holiday updates → Holiday source: fetches year
- Worker → Static file server: requests app (evidence: `README.md`)
- Static file server → Web interface: serves files (evidence: `server.js`)
- Web interface → Offline cache: registers offline use
- Worker → Android wrapper: uses (evidence: `README.md`)
- Worker → iOS bridge: uses (evidence: `README.md`)
