# harshithsai91/hunter-system architecture

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

- Interactive diagram: https://gitdiagram.com/harshithsai91/hunter-system
- Repository: https://github.com/harshithsai91/hunter-system

## Overview

Hunter System is a macOS productivity companion: the user works in focused sessions, the backend monitors activity and records sessions, then computes XP, ranks, and daily quest progress for the Electron UI. A separate main-process focus timer can award bonus XP. The graph follows the documented Electron bridge and local API architecture; several internal calls are supported by the source index or README rather than inspected implementation excerpts.

Main entry points: [`python/main.py`](https://github.com/harshithsai91/hunter-system/blob/main/python/main.py) (Local Flask API), [`src/preload/preload.js`](https://github.com/harshithsai91/hunter-system/blob/main/src/preload/preload.js) (Secure preload bridge), [`src/main/ipc.js`](https://github.com/harshithsai91/hunter-system/blob/main/src/main/ipc.js) (IPC handlers), [`src/main/main.js`](https://github.com/harshithsai91/hunter-system/blob/main/src/main/main.js) (App lifecycle)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Electron desktop"]
  node_electron["App lifecycle<br/>[main.js]"]
  node_pet_window["Pet window<br/>[window.js]"]
  node_ipc["IPC handlers<br/>[ipc.js]"]
  node_preload["Secure preload bridge<br/>[preload.js]"]
  node_http_client["HTTP client<br/>[http-client.js]"]
  node_python_bridge["Python process bridge<br/>[python-bridge.js]"]
end

subgraph group_experience["Progression experience"]
  node_pet_ui["Pet interface<br/>[pet.js]"]
  node_quests_ui["Quest interface<br/>[quests.js]"]
  node_settings_ui["Settings interface<br/>[settings.js]"]
  node_xp_ui["XP interface<br/>[xp.js]"]
  node_quest_tracker["Quest completion detector<br/>[quest-tracker.js]"]
  node_rank_tracker["Rank-up detector<br/>[rank-tracker.js]"]
  node_timer_tracker["Focus timer<br/>[timer-tracker.js]"]
end

subgraph group_backend["Python backend"]
  node_api["Local Flask API<br/>[main.py]"]
  node_monitor["Activity monitor<br/>[monitor.py]"]
  node_sessions["Session tracking<br/>[sessions.py]"]
  node_quests["Daily quest engine<br/>[quests.py]"]
  node_xp["XP calculation<br/>[xp.py]"]
  node_ranks["Rank definitions<br/>[ranks.py]"]
end

subgraph group_persistence["Local persistence"]
  node_database["SQLite access<br/>[db.py]"]
  node_sqlite[("Local SQLite database")]
end

node_user(("User"))
node_macos["macOS activity APIs"]

node_user -->|"uses"| node_pet_ui
node_macos -->|"provides activity"| node_monitor
node_electron -->|"creates"| node_pet_window
node_electron -->|"starts"| node_python_bridge
node_electron -->|"registers handlers"| node_ipc
node_electron -->|"configures"| node_quest_tracker
node_electron -->|"configures"| node_rank_tracker
node_pet_window -->|"loads"| node_preload
node_pet_window -->|"loads page"| node_pet_ui
node_user -.->|"invokes UI actions"| node_preload
node_preload -->|"bridges IPC"| node_ipc
node_pet_ui -->|"requests snapshots"| node_preload
node_quests_ui -->|"requests quests"| node_preload
node_settings_ui -.->|"requests settings"| node_preload
node_xp_ui -->|"requests progress"| node_preload
node_ipc -->|"fetches API data"| node_http_client
node_python_bridge -->|"spawns backend"| node_api
node_http_client -->|"calls local API"| node_api
node_api -->|"gets activity"| node_monitor
node_api -->|"records sessions"| node_sessions
node_api -->|"serves quest state"| node_quests
node_api -->|"builds progress"| node_xp
node_xp -->|"uses rank data"| node_ranks
node_api -->|"initializes storage"| node_database
node_database -->|"reads and writes"| node_sqlite
node_quests -->|"reads and updates quests"| node_sqlite
node_xp -->|"reads progress data"| node_sqlite
node_ipc -->|"detects completions"| node_quest_tracker
node_ipc -->|"detects rank changes"| node_rank_tracker
node_ipc -->|"handles timer actions"| node_timer_tracker
node_timer_tracker -->|"grants timer XP"| node_api

click node_electron "https://github.com/harshithsai91/hunter-system/blob/main/src/main/main.js"
click node_pet_window "https://github.com/harshithsai91/hunter-system/blob/main/src/main/window.js"
click node_ipc "https://github.com/harshithsai91/hunter-system/blob/main/src/main/ipc.js"
click node_preload "https://github.com/harshithsai91/hunter-system/blob/main/src/preload/preload.js"
click node_http_client "https://github.com/harshithsai91/hunter-system/blob/main/src/main/http-client.js"
click node_python_bridge "https://github.com/harshithsai91/hunter-system/blob/main/src/main/python-bridge.js"
click node_pet_ui "https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/pet.js"
click node_quests_ui "https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/quests.js"
click node_settings_ui "https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/settings.js"
click node_xp_ui "https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/xp.js"
click node_quest_tracker "https://github.com/harshithsai91/hunter-system/blob/main/src/main/quest-tracker.js"
click node_rank_tracker "https://github.com/harshithsai91/hunter-system/blob/main/src/main/rank-tracker.js"
click node_timer_tracker "https://github.com/harshithsai91/hunter-system/blob/main/src/main/timer-tracker.js"
click node_api "https://github.com/harshithsai91/hunter-system/blob/main/python/main.py"
click node_monitor "https://github.com/harshithsai91/hunter-system/blob/main/python/monitor.py"
click node_sessions "https://github.com/harshithsai91/hunter-system/blob/main/python/sessions.py"
click node_quests "https://github.com/harshithsai91/hunter-system/blob/main/python/quests.py"
click node_xp "https://github.com/harshithsai91/hunter-system/blob/main/python/xp.py"
click node_ranks "https://github.com/harshithsai91/hunter-system/blob/main/python/ranks.py"
click node_database "https://github.com/harshithsai91/hunter-system/blob/main/python/db.py"

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_electron,node_pet_window,node_ipc,node_preload,node_http_client,node_python_bridge,node_user toneBlue
class node_pet_ui,node_quests_ui,node_settings_ui,node_xp_ui,node_quest_tracker,node_rank_tracker,node_timer_tracker toneAmber
class node_api,node_monitor,node_sessions,node_quests,node_xp,node_ranks,node_macos toneMint
class node_database,node_sqlite toneRose
```

## Components

### Electron desktop

- [App lifecycle](https://github.com/harshithsai91/hunter-system/blob/main/src/main/main.js): `src/main/main.js`
- [Pet window](https://github.com/harshithsai91/hunter-system/blob/main/src/main/window.js): `src/main/window.js`
- [IPC handlers](https://github.com/harshithsai91/hunter-system/blob/main/src/main/ipc.js): `src/main/ipc.js`
- [Secure preload bridge](https://github.com/harshithsai91/hunter-system/blob/main/src/preload/preload.js): `src/preload/preload.js`
- [HTTP client](https://github.com/harshithsai91/hunter-system/blob/main/src/main/http-client.js): `src/main/http-client.js`
- [Python process bridge](https://github.com/harshithsai91/hunter-system/blob/main/src/main/python-bridge.js): `src/main/python-bridge.js`

### Progression experience

- [Pet interface](https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/pet.js): `src/renderer/pet.js`
- [Quest interface](https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/quests.js): `src/renderer/quests.js`
- [Settings interface](https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/settings.js): `src/renderer/settings.js`
- [XP interface](https://github.com/harshithsai91/hunter-system/blob/main/src/renderer/xp.js): `src/renderer/xp.js`
- [Quest completion detector](https://github.com/harshithsai91/hunter-system/blob/main/src/main/quest-tracker.js): `src/main/quest-tracker.js`
- [Rank-up detector](https://github.com/harshithsai91/hunter-system/blob/main/src/main/rank-tracker.js): `src/main/rank-tracker.js`
- [Focus timer](https://github.com/harshithsai91/hunter-system/blob/main/src/main/timer-tracker.js): `src/main/timer-tracker.js`

### Python backend

- [Local Flask API](https://github.com/harshithsai91/hunter-system/blob/main/python/main.py): `python/main.py`
- [Activity monitor](https://github.com/harshithsai91/hunter-system/blob/main/python/monitor.py): `python/monitor.py`
- [Session tracking](https://github.com/harshithsai91/hunter-system/blob/main/python/sessions.py): `python/sessions.py`
- [Daily quest engine](https://github.com/harshithsai91/hunter-system/blob/main/python/quests.py): `python/quests.py`
- [XP calculation](https://github.com/harshithsai91/hunter-system/blob/main/python/xp.py): `python/xp.py`
- [Rank definitions](https://github.com/harshithsai91/hunter-system/blob/main/python/ranks.py): `python/ranks.py`

### Local persistence

- [SQLite access](https://github.com/harshithsai91/hunter-system/blob/main/python/db.py): `python/db.py`
- **Local SQLite database**

### Other components

- **User**
- **macOS activity APIs**

## Connections

- User → Pet interface: uses (evidence: `README.md`)
- macOS activity APIs → Activity monitor: provides activity (evidence: `README.md`)
- App lifecycle → Pet window: creates (evidence: `src/main/main.js`)
- App lifecycle → Python process bridge: starts (evidence: `src/main/main.js`)
- App lifecycle → IPC handlers: registers handlers (evidence: `src/main/main.js`)
- App lifecycle → Quest completion detector: configures (evidence: `src/main/main.js`)
- App lifecycle → Rank-up detector: configures (evidence: `src/main/main.js`)
- Pet window → Secure preload bridge: loads (evidence: `src/main/window.js`)
- Pet window → Pet interface: loads page (evidence: `src/main/window.js`)
- User → Secure preload bridge: invokes UI actions
- Secure preload bridge → IPC handlers: bridges IPC (evidence: `README.md`)
- Pet interface → Secure preload bridge: requests snapshots
- Quest interface → Secure preload bridge: requests quests
- Settings interface → Secure preload bridge: requests settings
- XP interface → Secure preload bridge: requests progress
- IPC handlers → HTTP client: fetches API data (evidence: `src/main/ipc.js`)
- Python process bridge → Local Flask API: spawns backend (evidence: `src/main/python-bridge.js`)
- HTTP client → Local Flask API: calls local API (evidence: `README.md`)
- Local Flask API → Activity monitor: gets activity (evidence: `python/main.py`)
- Local Flask API → Session tracking: records sessions (evidence: `python/main.py`)
- Local Flask API → Daily quest engine: serves quest state (evidence: `README.md`)
- Local Flask API → XP calculation: builds progress (evidence: `python/main.py`)
- XP calculation → Rank definitions: uses rank data (evidence: `python/xp.py`)
- Local Flask API → SQLite access: initializes storage (evidence: `python/main.py`)
- SQLite access → Local SQLite database: reads and writes (evidence: `README.md`)
- Daily quest engine → Local SQLite database: reads and updates quests (evidence: `python/quests.py`)
- XP calculation → Local SQLite database: reads progress data (evidence: `python/xp.py`)
- IPC handlers → Quest completion detector: detects completions (evidence: `src/main/ipc.js`)
- IPC handlers → Rank-up detector: detects rank changes (evidence: `src/main/ipc.js`)
- IPC handlers → Focus timer: handles timer actions (evidence: `src/main/ipc.js`)
- Focus timer → Local Flask API: grants timer XP
