# mirbyte/daylane architecture

> Architecture diagram of the GitHub repository mirbyte/daylane, 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/mirbyte/daylane
- Repository: https://github.com/mirbyte/daylane

## Overview

Daylane is a portable Windows activity tracker. Its main workflow captures keyboard/mouse counts and foreground/open-window activity, classifies away time, persists activity locally, then serves day and week/month summaries to the desktop UI. The app startup layer also manages the tray and optional Windows startup registration. The graph reflects the sampled source and README; unsampled UI and tracking details are represented only where the source index or README documents them, so some capability links are intentionally omitted.

Main entry points: [`Services/TrackingService.cs`](https://github.com/mirbyte/daylane/blob/main/Services/TrackingService.cs) (Tracking coordinator), [`ViewModels/MainWindowViewModel.cs`](https://github.com/mirbyte/daylane/blob/main/ViewModels/MainWindowViewModel.cs) (Screen state and insights), [`Services/DailyStatsStore.cs`](https://github.com/mirbyte/daylane/blob/main/Services/DailyStatsStore.cs) (History store), [`App.axaml.cs`](https://github.com/mirbyte/daylane/blob/main/App.axaml.cs) (App startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_startup["App lifecycle"]
  node_app["App startup<br/>[App.axaml.cs]"]
  node_startup_registration["Startup registration"]
end

subgraph group_capture["Activity capture"]
  node_tracking["Tracking coordinator<br/>[TrackingService.cs]"]
  node_input_hook["Input capture<br/>[InputHook.cs]"]
  node_idle_monitor["Away detection<br/>[IdleMonitor.cs]"]
  node_foreground["Foreground tracking"]
  node_open_apps["Open-app tracking<br/>[OpenAppTracker.cs]"]
  node_input_event["Input event<br/>[InputEvent.cs]"]
  node_foreground_app["App identity<br/>[ForegroundApp.cs]"]
end

subgraph group_persistence["Local history"]
  node_activity_segment["Activity segments<br/>[ActivitySegment.cs]"]
  node_daily_store["History store<br/>[DailyStatsStore.cs]"]
  node_database[("Local SQLite data")]
  node_day_snapshot["Day summary<br/>[DaySnapshot.cs]"]
  node_range_snapshot["Range summary<br/>[RangeSnapshot.cs]"]
  node_app_usage["App usage summary<br/>[AppUsageSummary.cs]"]
  node_open_summary["Open-app summary<br/>[OpenAppSummary.cs]"]
end

subgraph group_presentation["Insights and UI"]
  node_view["Main window"]
  node_viewmodel["Screen state and insights"]
  node_timeline["Day timeline<br/>[TimelineBar.cs]"]
  node_icons["App icons and colors<br/>[AppIconLoader.cs]"]
end

node_user(("User"))
node_windows{{"Windows input and app APIs"}}

node_user -->|"uses"| node_view
node_app -->|"starts"| node_tracking
node_app -->|"creates"| node_viewmodel
node_app -->|"refreshes"| node_startup_registration
node_view -->|"binds"| node_viewmodel
node_viewmodel -->|"reads activity"| node_tracking
node_viewmodel -->|"loads icons"| node_icons
node_timeline -->|"renders"| node_activity_segment
node_timeline -->|"loads icons"| node_icons
node_tracking -->|"starts; receives events"| node_input_hook
node_tracking -->|"starts; handles changes"| node_foreground
node_tracking -->|"starts; handles changes"| node_open_apps
node_foreground -->|"checks idleness"| node_idle_monitor
node_input_hook -->|"emits"| node_input_event
node_tracking -->|"counts"| node_input_event
node_foreground -->|"reports"| node_foreground_app
node_open_apps -->|"uses identity"| node_foreground_app
node_tracking -->|"writes and queries"| node_daily_store
node_daily_store -->|"reads and writes"| node_database
node_daily_store -->|"stores and returns"| node_activity_segment
node_tracking -->|"builds"| node_day_snapshot
node_tracking -->|"builds"| node_range_snapshot
node_daily_store -->|"aggregates"| node_app_usage
node_daily_store -->|"aggregates"| node_open_summary
node_input_hook -->|"captures input"| node_windows
node_idle_monitor -->|"queries last input"| node_windows
node_startup_registration -.->|"registers startup"| node_windows
node_viewmodel -.->|"shows week/month insights"| node_range_snapshot
node_viewmodel -.->|"shows open-app time"| node_open_summary

click node_app "https://github.com/mirbyte/daylane/blob/main/App.axaml.cs"
click node_startup_registration "https://github.com/mirbyte/daylane/blob/main/Services/StartupRegistration.cs"
click node_view "https://github.com/mirbyte/daylane/blob/main/MainWindow.axaml.cs"
click node_viewmodel "https://github.com/mirbyte/daylane/blob/main/ViewModels/MainWindowViewModel.cs"
click node_timeline "https://github.com/mirbyte/daylane/blob/main/Controls/TimelineBar.cs"
click node_icons "https://github.com/mirbyte/daylane/blob/main/Services/AppIconLoader.cs"
click node_tracking "https://github.com/mirbyte/daylane/blob/main/Services/TrackingService.cs"
click node_input_hook "https://github.com/mirbyte/daylane/blob/main/Services/InputHook.cs"
click node_idle_monitor "https://github.com/mirbyte/daylane/blob/main/Services/IdleMonitor.cs"
click node_foreground "https://github.com/mirbyte/daylane/blob/main/Services/ForegroundTracker.cs"
click node_open_apps "https://github.com/mirbyte/daylane/blob/main/Services/OpenAppTracker.cs"
click node_input_event "https://github.com/mirbyte/daylane/blob/main/Models/InputEvent.cs"
click node_foreground_app "https://github.com/mirbyte/daylane/blob/main/Models/ForegroundApp.cs"
click node_activity_segment "https://github.com/mirbyte/daylane/blob/main/Models/ActivitySegment.cs"
click node_daily_store "https://github.com/mirbyte/daylane/blob/main/Services/DailyStatsStore.cs"
click node_day_snapshot "https://github.com/mirbyte/daylane/blob/main/Models/DaySnapshot.cs"
click node_range_snapshot "https://github.com/mirbyte/daylane/blob/main/Models/RangeSnapshot.cs"
click node_app_usage "https://github.com/mirbyte/daylane/blob/main/Models/AppUsageSummary.cs"
click node_open_summary "https://github.com/mirbyte/daylane/blob/main/Models/OpenAppSummary.cs"

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_startup_registration,node_user toneBlue
class node_tracking,node_input_hook,node_idle_monitor,node_foreground,node_open_apps,node_input_event,node_foreground_app toneAmber
class node_activity_segment,node_daily_store,node_database,node_day_snapshot,node_range_snapshot,node_app_usage,node_open_summary,node_windows toneMint
class node_view,node_viewmodel,node_timeline,node_icons toneRose
```

## Components

### App lifecycle

- [App startup](https://github.com/mirbyte/daylane/blob/main/App.axaml.cs): `App.axaml.cs`
- [Startup registration](https://github.com/mirbyte/daylane/blob/main/Services/StartupRegistration.cs): `Services/StartupRegistration.cs`

### Activity capture

- [Tracking coordinator](https://github.com/mirbyte/daylane/blob/main/Services/TrackingService.cs): `Services/TrackingService.cs`
- [Input capture](https://github.com/mirbyte/daylane/blob/main/Services/InputHook.cs): `Services/InputHook.cs`
- [Away detection](https://github.com/mirbyte/daylane/blob/main/Services/IdleMonitor.cs): `Services/IdleMonitor.cs`
- [Foreground tracking](https://github.com/mirbyte/daylane/blob/main/Services/ForegroundTracker.cs): `Services/ForegroundTracker.cs`
- [Open-app tracking](https://github.com/mirbyte/daylane/blob/main/Services/OpenAppTracker.cs): `Services/OpenAppTracker.cs`
- [Input event](https://github.com/mirbyte/daylane/blob/main/Models/InputEvent.cs): `Models/InputEvent.cs`
- [App identity](https://github.com/mirbyte/daylane/blob/main/Models/ForegroundApp.cs): `Models/ForegroundApp.cs`

### Local history

- [Activity segments](https://github.com/mirbyte/daylane/blob/main/Models/ActivitySegment.cs): `Models/ActivitySegment.cs`
- [History store](https://github.com/mirbyte/daylane/blob/main/Services/DailyStatsStore.cs): `Services/DailyStatsStore.cs`
- **Local SQLite data**
- [Day summary](https://github.com/mirbyte/daylane/blob/main/Models/DaySnapshot.cs): `Models/DaySnapshot.cs`
- [Range summary](https://github.com/mirbyte/daylane/blob/main/Models/RangeSnapshot.cs): `Models/RangeSnapshot.cs`
- [App usage summary](https://github.com/mirbyte/daylane/blob/main/Models/AppUsageSummary.cs): `Models/AppUsageSummary.cs`
- [Open-app summary](https://github.com/mirbyte/daylane/blob/main/Models/OpenAppSummary.cs): `Models/OpenAppSummary.cs`

### Insights and UI

- [Main window](https://github.com/mirbyte/daylane/blob/main/MainWindow.axaml.cs): `MainWindow.axaml.cs`
- [Screen state and insights](https://github.com/mirbyte/daylane/blob/main/ViewModels/MainWindowViewModel.cs): `ViewModels/MainWindowViewModel.cs`
- [Day timeline](https://github.com/mirbyte/daylane/blob/main/Controls/TimelineBar.cs): `Controls/TimelineBar.cs`
- [App icons and colors](https://github.com/mirbyte/daylane/blob/main/Services/AppIconLoader.cs): `Services/AppIconLoader.cs`

### Other components

- **User**
- **Windows input and app APIs**

## Connections

- User → Main window: uses (evidence: `README.md`)
- App startup → Tracking coordinator: starts (evidence: `App.axaml.cs`)
- App startup → Screen state and insights: creates (evidence: `App.axaml.cs`)
- App startup → Startup registration: refreshes (evidence: `App.axaml.cs`)
- Main window → Screen state and insights: binds (evidence: `MainWindow.axaml.cs`)
- Screen state and insights → Tracking coordinator: reads activity (evidence: `ViewModels/MainWindowViewModel.cs`)
- Screen state and insights → App icons and colors: loads icons (evidence: `ViewModels/MainWindowViewModel.cs`)
- Day timeline → Activity segments: renders (evidence: `Controls/TimelineBar.cs`)
- Day timeline → App icons and colors: loads icons (evidence: `Controls/TimelineBar.cs`)
- Tracking coordinator → Input capture: starts; receives events (evidence: `Services/TrackingService.cs`)
- Tracking coordinator → Foreground tracking: starts; handles changes (evidence: `Services/TrackingService.cs`)
- Tracking coordinator → Open-app tracking: starts; handles changes (evidence: `Services/TrackingService.cs`)
- Foreground tracking → Away detection: checks idleness (evidence: `Services/ForegroundTracker.cs`)
- Input capture → Input event: emits (evidence: `Services/InputHook.cs`)
- Tracking coordinator → Input event: counts (evidence: `Services/TrackingService.cs`)
- Foreground tracking → App identity: reports (evidence: `Services/ForegroundTracker.cs`)
- Open-app tracking → App identity: uses identity (evidence: `Services/OpenAppTracker.cs`)
- Tracking coordinator → History store: writes and queries (evidence: `Services/TrackingService.cs`)
- History store → Local SQLite data: reads and writes (evidence: `Services/DailyStatsStore.cs`)
- History store → Activity segments: stores and returns (evidence: `Services/DailyStatsStore.cs`)
- Tracking coordinator → Day summary: builds (evidence: `Services/TrackingService.cs`)
- Tracking coordinator → Range summary: builds (evidence: `Services/TrackingService.cs`)
- History store → App usage summary: aggregates (evidence: `Services/DailyStatsStore.cs`)
- History store → Open-app summary: aggregates (evidence: `Services/DailyStatsStore.cs`)
- Input capture → Windows input and app APIs: captures input (evidence: `Services/InputHook.cs`)
- Away detection → Windows input and app APIs: queries last input (evidence: `Services/IdleMonitor.cs`)
- Startup registration → Windows input and app APIs: registers startup
- Screen state and insights → Range summary: shows week/month insights (evidence: `README.md`)
- Screen state and insights → Open-app summary: shows open-app time (evidence: `README.md`)
