# zoey-0314/dayforge architecture

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

- Interactive diagram: https://gitdiagram.com/zoey-0314/dayforge
- Repository: https://github.com/zoey-0314/dayforge

## Overview

Dayforge is a Windows desktop productivity widget: users expand a compact heatmap-and-level view to manage tasks, check in habits, run focus sessions, and record sleep. The main UI initializes local storage and daily rewards, then coordinates feature services and displays saved EXP history and level progress. Task, habit, timer, login, and online activity rewards feed a durable EXP ledger; sleep is tracked separately. The Rust/Tauri layer configures the desktop window and SQLite migrations. The README describes capped online/active-app EXP, but the tree excerpt does not establish an active-app detection path.

Main entry points: [`src/app/App.tsx`](https://github.com/zoey-0314/dayforge/blob/main/src/app/App.tsx) (Widget app), [`src/db/database.ts`](https://github.com/zoey-0314/dayforge/blob/main/src/db/database.ts) (Database access), [`src/features/timer/timerService.ts`](https://github.com/zoey-0314/dayforge/blob/main/src/features/timer/timerService.ts) (Focus timer), [`src/features/experience/onlineExperienceService.ts`](https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/onlineExperienceService.ts) (Online EXP)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Widget interface"]
  node_app["Widget app<br/>[App.tsx]"]
  node_heatmap["EXP heatmap<br/>[Heatmap.tsx]"]
  node_sleep_panel["Sleep panel<br/>[SleepPanel.tsx]"]
  node_effects["EXP effects"]
end

subgraph group_features["Product features"]
  node_todo["To-do service<br/>[todoService.ts]"]
  node_habits["Habit service<br/>[habitService.ts]"]
  node_timer["Focus timer<br/>[timerService.ts]"]
  node_sleep["Sleep records<br/>[sleepService.ts]"]
end

subgraph group_progress["Experience progress"]
  node_daily_login["Daily login reward"]
  node_online_exp["Online EXP"]
  node_experience["EXP and levels"]
end

subgraph group_desktop["Desktop and storage"]
  node_database["Database access<br/>[database.ts]"]
  node_sqlite[("Local SQLite")]
  node_frontend_entry["Frontend entry<br/>[main.tsx]"]
  node_lifecycle["Desktop lifecycle"]
  node_tauri["Tauri backend<br/>[lib.rs]"]
end

node_user(("User"))
node_active_app(("Active-app source"))

node_user -->|"uses widget"| node_app
node_frontend_entry -->|"renders"| node_app
node_frontend_entry -->|"initializes"| node_lifecycle
node_app -->|"opens storage"| node_database
node_app -->|"checks login reward"| node_daily_login
node_app -->|"recovers and lists sessions"| node_timer
node_app -->|"manages tasks"| node_todo
node_app -->|"manages check-ins"| node_habits
node_app -->|"shows sleep panel"| node_sleep_panel
node_app -->|"passes EXP history"| node_heatmap
node_app -->|"shows progress effects"| node_effects
node_sleep_panel -->|"reads and saves"| node_sleep
node_todo -->|"reads and writes"| node_database
node_habits -->|"reads and writes"| node_database
node_timer -->|"reads and writes"| node_database
node_timer -->|"grants timer EXP"| node_experience
node_daily_login -->|"writes login reward"| node_database
node_online_exp -->|"reads daily total"| node_database
node_online_exp -->|"grants capped EXP"| node_experience
node_experience -->|"records EXP"| node_database
node_app -->|"queries daily EXP"| node_database
node_database -->|"executes SQL"| node_sqlite
node_tauri -->|"migrates schema"| node_sqlite
node_tauri -->|"hosts window"| node_app
node_active_app -.->|"verified time input"| node_online_exp

click node_app "https://github.com/zoey-0314/dayforge/blob/main/src/app/App.tsx"
click node_heatmap "https://github.com/zoey-0314/dayforge/blob/main/src/features/heatmap/Heatmap.tsx"
click node_sleep_panel "https://github.com/zoey-0314/dayforge/blob/main/src/features/sleep/SleepPanel.tsx"
click node_todo "https://github.com/zoey-0314/dayforge/blob/main/src/features/todo/todoService.ts"
click node_habits "https://github.com/zoey-0314/dayforge/blob/main/src/features/habits/habitService.ts"
click node_timer "https://github.com/zoey-0314/dayforge/blob/main/src/features/timer/timerService.ts"
click node_sleep "https://github.com/zoey-0314/dayforge/blob/main/src/features/sleep/sleepService.ts"
click node_daily_login "https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/dailyLoginService.ts"
click node_online_exp "https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/onlineExperienceService.ts"
click node_experience "https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/experienceService.ts"
click node_effects "https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/ExperienceEffects.tsx"
click node_database "https://github.com/zoey-0314/dayforge/blob/main/src/db/database.ts"
click node_frontend_entry "https://github.com/zoey-0314/dayforge/blob/main/src/main.tsx"
click node_lifecycle "https://github.com/zoey-0314/dayforge/blob/main/src/services/desktopLifecycle.ts"
click node_tauri "https://github.com/zoey-0314/dayforge/blob/main/src-tauri/src/lib.rs"

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_app,node_heatmap,node_sleep_panel,node_effects,node_user toneBlue
class node_todo,node_habits,node_timer,node_sleep toneAmber
class node_daily_login,node_online_exp,node_experience toneMint
class node_database,node_sqlite,node_frontend_entry,node_lifecycle,node_tauri toneRose
class node_active_app toneIndigo
```

## Components

### Widget interface

- [Widget app](https://github.com/zoey-0314/dayforge/blob/main/src/app/App.tsx): `src/app/App.tsx`
- [EXP heatmap](https://github.com/zoey-0314/dayforge/blob/main/src/features/heatmap/Heatmap.tsx): `src/features/heatmap/Heatmap.tsx`
- [Sleep panel](https://github.com/zoey-0314/dayforge/blob/main/src/features/sleep/SleepPanel.tsx): `src/features/sleep/SleepPanel.tsx`
- [EXP effects](https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/ExperienceEffects.tsx): `src/features/experience/ExperienceEffects.tsx`

### Product features

- [To-do service](https://github.com/zoey-0314/dayforge/blob/main/src/features/todo/todoService.ts): `src/features/todo/todoService.ts`
- [Habit service](https://github.com/zoey-0314/dayforge/blob/main/src/features/habits/habitService.ts): `src/features/habits/habitService.ts`
- [Focus timer](https://github.com/zoey-0314/dayforge/blob/main/src/features/timer/timerService.ts): `src/features/timer/timerService.ts`
- [Sleep records](https://github.com/zoey-0314/dayforge/blob/main/src/features/sleep/sleepService.ts): `src/features/sleep/sleepService.ts`

### Experience progress

- [Daily login reward](https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/dailyLoginService.ts): `src/features/experience/dailyLoginService.ts`
- [Online EXP](https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/onlineExperienceService.ts): `src/features/experience/onlineExperienceService.ts`
- [EXP and levels](https://github.com/zoey-0314/dayforge/blob/main/src/features/experience/experienceService.ts): `src/features/experience/experienceService.ts`

### Desktop and storage

- [Database access](https://github.com/zoey-0314/dayforge/blob/main/src/db/database.ts): `src/db/database.ts`
- **Local SQLite**
- [Frontend entry](https://github.com/zoey-0314/dayforge/blob/main/src/main.tsx): `src/main.tsx`
- [Desktop lifecycle](https://github.com/zoey-0314/dayforge/blob/main/src/services/desktopLifecycle.ts): `src/services/desktopLifecycle.ts`
- [Tauri backend](https://github.com/zoey-0314/dayforge/blob/main/src-tauri/src/lib.rs): `src-tauri/src/lib.rs`

### Other components

- **User**
- **Active-app source**

## Connections

- User → Widget app: uses widget
- Frontend entry → Widget app: renders
- Frontend entry → Desktop lifecycle: initializes
- Widget app → Database access: opens storage
- Widget app → Daily login reward: checks login reward
- Widget app → Focus timer: recovers and lists sessions
- Widget app → To-do service: manages tasks
- Widget app → Habit service: manages check-ins
- Widget app → Sleep panel: shows sleep panel
- Widget app → EXP heatmap: passes EXP history
- Widget app → EXP effects: shows progress effects
- Sleep panel → Sleep records: reads and saves
- To-do service → Database access: reads and writes
- Habit service → Database access: reads and writes
- Focus timer → Database access: reads and writes
- Focus timer → EXP and levels: grants timer EXP
- Daily login reward → Database access: writes login reward
- Online EXP → Database access: reads daily total
- Online EXP → EXP and levels: grants capped EXP
- EXP and levels → Database access: records EXP
- Widget app → Database access: queries daily EXP
- Database access → Local SQLite: executes SQL
- Tauri backend → Local SQLite: migrates schema
- Tauri backend → Widget app: hosts window
- Active-app source → Online EXP: verified time input
