# tomotsugu-dev/hindsight architecture

> Architecture diagram of the GitHub repository tomotsugu-dev/hindsight, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tomotsugu-dev/hindsight
- Repository: https://github.com/tomotsugu-dev/hindsight

## Overview

Hindsight is a local-first desktop activity log and AI review tool. Its principal workflow records app/window activity in the background, persists it locally, and presents time-use summaries across day, week, and month views. Users can also search optional screenshot/OCR memory, request AI summaries or chat over their records, and optionally aggregate activity across devices through cloud sync. The tree and README establish these product areas; several backend integrations and command-to-UI links are unsampled, so those relationships are shown as unverified rather than asserted.

Main entry points: [`src/App.tsx`](https://github.com/tomotsugu-dev/hindsight/blob/main/src/App.tsx) (Desktop app), [`src-tauri/src/capture/service.rs`](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/capture/service.rs) (Activity capture), [`src/pages/AISettings/AISettingsPage.tsx`](https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/AISettings/AISettingsPage.tsx) (AI configuration), [`src-tauri/src/repo/activities.rs`](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/repo/activities.rs) (Activity records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and memory"]
  node_capture_service["Activity capture<br/>[service.rs]"]
  node_activity_repo["Activity records<br/>[activities.rs]"]
  node_main_db[("Local database<br/>[pool.rs]")]
  node_screen_memory[("Screen memory<br/>[mod.rs]")]
  node_ocr["OCR processing<br/>[ocr_worker.rs]"]
end

subgraph group_review["Activity review"]
  node_desktop["Desktop app<br/>[App.tsx]"]
  node_search["Screen search<br/>[SearchPage.tsx]"]
  node_time_views["Time summaries<br/>[TodayPage.tsx]"]
  node_history["History views<br/>[HistoryPage.tsx]"]
  node_categories["Categories<br/>[CategoriesPage.tsx]"]
end

subgraph group_ai["AI features"]
  node_summary["AI reports<br/>[summary.rs]"]
  node_chat["AI chat<br/>[engine.rs]"]
  node_ai_settings["AI configuration<br/>[AISettingsPage.tsx]"]
  node_ai_runtime["Model runtime<br/>[server.rs]"]
end

subgraph group_platform["Settings and sync"]
  node_frontend_api["Frontend API<br/>[hindsight.ts]"]
  node_settings["App settings<br/>[settings.rs]"]
  node_sync["Device sync<br/>[mod.rs]"]
end

node_user(("User"))
node_cloud["Cloud provider"]

node_user -->|"opens and reviews"| node_desktop
node_desktop -->|"routes to"| node_time_views
node_desktop -->|"routes to"| node_history
node_desktop -->|"routes to"| node_search
node_desktop -->|"routes to"| node_ai_settings
node_user -->|"uses automatic tracking"| node_capture_service
node_capture_service -->|"records activity"| node_activity_repo
node_activity_repo -.->|"persists records"| node_main_db
node_user -->|"reviews daily, weekly, monthly"| node_time_views
node_user -->|"customizes categories"| node_categories
node_user -->|"enables optional memory"| node_screen_memory
node_capture_service -->|"registers captured frames"| node_screen_memory
node_screen_memory -.->|"provides frames for OCR"| node_ocr
node_user -->|"searches screen text"| node_search
node_user -->|"requests activity report"| node_summary
node_user -->|"asks about records"| node_chat
node_chat -.->|"queries records"| node_activity_repo
node_ai_settings -->|"configures AI"| node_frontend_api
node_frontend_api -.->|"invokes backend commands"| node_ai_runtime
node_ai_settings -.->|"configures model runtime"| node_ai_runtime
node_user -->|"opts into device sync"| node_sync
node_sync -->|"syncs activity metadata"| node_cloud
node_settings -->|"stores preferences"| node_main_db

click node_desktop "https://github.com/tomotsugu-dev/hindsight/blob/main/src/App.tsx"
click node_frontend_api "https://github.com/tomotsugu-dev/hindsight/blob/main/src/api/hindsight.ts"
click node_capture_service "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/capture/service.rs"
click node_activity_repo "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/repo/activities.rs"
click node_main_db "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/storage/pool.rs"
click node_screen_memory "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/memory/mod.rs"
click node_ocr "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/ai/ocr_worker.rs"
click node_search "https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/Search/SearchPage.tsx"
click node_time_views "https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/Today/TodayPage.tsx"
click node_history "https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/History/HistoryPage.tsx"
click node_categories "https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/Categories/CategoriesPage.tsx"
click node_summary "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/ai/summary.rs"
click node_chat "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/chat/engine.rs"
click node_ai_settings "https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/AISettings/AISettingsPage.tsx"
click node_ai_runtime "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/ai/server.rs"
click node_settings "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/repo/settings.rs"
click node_sync "https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/sync/engine/mod.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_capture_service,node_activity_repo,node_main_db,node_screen_memory,node_ocr,node_user toneBlue
class node_desktop,node_search,node_time_views,node_history,node_categories toneAmber
class node_summary,node_chat,node_ai_settings,node_ai_runtime toneMint
class node_frontend_api,node_settings,node_sync toneRose
class node_cloud toneIndigo
```

## Components

### Capture and memory

- [Activity capture](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/capture/service.rs): `src-tauri/src/capture/service.rs`
- [Activity records](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/repo/activities.rs): `src-tauri/src/repo/activities.rs`
- [Local database](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/storage/pool.rs): `src-tauri/src/storage/pool.rs`
- [Screen memory](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/memory/mod.rs): `src-tauri/src/memory/mod.rs`
- [OCR processing](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/ai/ocr_worker.rs): `src-tauri/src/ai/ocr_worker.rs`

### Activity review

- [Desktop app](https://github.com/tomotsugu-dev/hindsight/blob/main/src/App.tsx): `src/App.tsx`
- [Screen search](https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/Search/SearchPage.tsx): `src/pages/Search/SearchPage.tsx`
- [Time summaries](https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/Today/TodayPage.tsx): `src/pages/Today/TodayPage.tsx`
- [History views](https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/History/HistoryPage.tsx): `src/pages/History/HistoryPage.tsx`
- [Categories](https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/Categories/CategoriesPage.tsx): `src/pages/Categories/CategoriesPage.tsx`

### AI features

- [AI reports](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/ai/summary.rs): `src-tauri/src/ai/summary.rs`
- [AI chat](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/chat/engine.rs): `src-tauri/src/chat/engine.rs`
- [AI configuration](https://github.com/tomotsugu-dev/hindsight/blob/main/src/pages/AISettings/AISettingsPage.tsx): `src/pages/AISettings/AISettingsPage.tsx`
- [Model runtime](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/ai/server.rs): `src-tauri/src/ai/server.rs`

### Settings and sync

- [Frontend API](https://github.com/tomotsugu-dev/hindsight/blob/main/src/api/hindsight.ts): `src/api/hindsight.ts`
- [App settings](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/repo/settings.rs): `src-tauri/src/repo/settings.rs`
- [Device sync](https://github.com/tomotsugu-dev/hindsight/blob/main/src-tauri/src/sync/engine/mod.rs): `src-tauri/src/sync/engine/mod.rs`

### Other components

- **User**
- **Cloud provider**

## Connections

- User → Desktop app: opens and reviews (evidence: `README.md`)
- Desktop app → Time summaries: routes to (evidence: `src/App.tsx`)
- Desktop app → History views: routes to (evidence: `src/App.tsx`)
- Desktop app → Screen search: routes to (evidence: `src/App.tsx`)
- Desktop app → AI configuration: routes to (evidence: `src/App.tsx`)
- User → Activity capture: uses automatic tracking (evidence: `README.md`)
- Activity capture → Activity records: records activity (evidence: `src-tauri/src/capture/service.rs`)
- Activity records → Local database: persists records
- User → Time summaries: reviews daily, weekly, monthly (evidence: `README.md`)
- User → Categories: customizes categories (evidence: `README.md`)
- User → Screen memory: enables optional memory (evidence: `README.md`)
- Activity capture → Screen memory: registers captured frames (evidence: `src-tauri/src/capture/service.rs`)
- Screen memory → OCR processing: provides frames for OCR
- User → Screen search: searches screen text (evidence: `README.md`)
- User → AI reports: requests activity report (evidence: `README.md`)
- User → AI chat: asks about records (evidence: `README.md`)
- AI chat → Activity records: queries records
- AI configuration → Frontend API: configures AI
- Frontend API → Model runtime: invokes backend commands
- AI configuration → Model runtime: configures model runtime
- User → Device sync: opts into device sync (evidence: `README.md`)
- Device sync → Cloud provider: syncs activity metadata (evidence: `README.md`)
- App settings → Local database: stores preferences (evidence: `src-tauri/src/repo/settings.rs`)
