# arturbakunc880-lab/ihealth_monitoring_system architecture

> Architecture diagram of the GitHub repository arturbakunc880-lab/ihealth_monitoring_system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arturbakunc880-lab/ihealth_monitoring_system
- Repository: https://github.com/arturbakunc880-lab/ihealth_monitoring_system

## Overview

iHealth is a local desktop eye-health and screen-habit monitor. The main workflow captures webcam frames, detects face and eye signals, updates monitoring state and persists session measurements; the interface presents live status and historical analytics. The README also describes account, symptom-check-in, and eye-care contact/visit capabilities, represented at their available feature-directory level. Edges follow excerpts, source-index references, or documented behavior; unsampled internals are not inferred.

Main entry points: [`core/monitoring_session.py`](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/core/monitoring_session.py) (Monitoring session), [`core/camera_worker.py`](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/core/camera_worker.py) (Camera worker), [`camera_app.py`](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/camera_app.py) (App entry and wiring), [`ui/screens`](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/tree/main/ui/screens) (App screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Capture and monitoring"]
  node_worker["Camera worker<br/>[camera_worker.py]"]
  node_camera["Camera source<br/>[camera_manager.py]"]
  node_session["Monitoring session"]
  node_config["Monitoring configuration<br/>[config.py]"]
  node_distance["Distance estimation"]
  node_presence["Presence tracking"]
  node_breaks["Break reminders<br/>[break_reminder.py]"]
  node_stats_tracker["Session statistics<br/>[stats_tracker.py]"]
end

subgraph group_detection["Vision and metrics"]
  node_factory["Detector selection"]
  node_mediapipe["MediaPipe detection"]
  node_haar["Haar fallback<br/>[haar_detector.py]"]
  node_detection_types["Detection results<br/>[base.py]"]
  node_eye_metrics["Eye measurements<br/>[eye_metrics.py]"]
  node_blink["Blink analysis<br/>[blink_detector.py]"]
end

subgraph group_storage["Persistence and analytics"]
  node_db[("SQLite database")]
  node_aggregation["Statistics queries<br/>[statistics.py]"]
  node_migration["S4 history import<br/>[json_migration.py]"]
  node_export["CSV export<br/>[csv_exporter.py]"]
end

subgraph group_interface["Desktop interface"]
  node_app["App entry and wiring<br/>[camera_app.py]"]
  node_shell["App navigation<br/>[shell.py]"]
  node_screens["App screens"]
  node_components["Reusable UI components<br/>[components.py]"]
  node_theme["Theme system<br/>[theme.py]"]
  node_charts["Analytics charts<br/>[charts.py]"]
end

subgraph group_care["Wellness features"]
  node_accounts["Local accounts<br/>[accounts.py]"]
  node_care_records["Symptoms and visits"]
end

node_user(("User"))

node_user -->|"starts and uses"| node_app
node_app -->|"starts monitoring"| node_worker
node_app -->|"configures session"| node_session
node_app -->|"opens storage"| node_db
node_app -->|"supports profiles"| node_accounts
node_app -.->|"shows interface"| node_shell
node_worker -->|"reads frames"| node_camera
node_worker -->|"creates detector"| node_factory
node_worker -->|"updates monitoring"| node_session
node_worker -.->|"publishes live results"| node_screens
node_worker -->|"consumes detections"| node_detection_types
node_worker -->|"draws distance overlay"| node_distance
node_worker -->|"draws blink overlay"| node_blink
node_factory -->|"selects detector"| node_mediapipe
node_factory -->|"falls back to"| node_haar
node_mediapipe -->|"returns results"| node_detection_types
node_mediapipe -->|"uses measurements"| node_eye_metrics
node_mediapipe -->|"can fall back"| node_haar
node_session -->|"processes eye events"| node_blink
node_session -->|"updates estimates"| node_distance
node_session -->|"tracks attendance"| node_presence
node_session -->|"checks break timing"| node_breaks
node_session -->|"records session totals"| node_stats_tracker
node_session -->|"persists measurements"| node_db
node_session -->|"uses thresholds"| node_config
node_db -->|"serves stored records"| node_aggregation
node_app -->|"imports legacy history"| node_migration
node_migration -->|"writes imported data"| node_db
node_shell -->|"hosts pages"| node_screens
node_screens -->|"uses widgets"| node_components
node_components -->|"reads theme tokens"| node_theme
node_screens -->|"queries analytics"| node_aggregation
node_screens -->|"renders analytics"| node_charts
node_screens -->|"requests CSV export"| node_export
node_export -->|"reads session data"| node_db
node_user -->|"checks in and manages visits"| node_care_records

click node_app "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/camera_app.py"
click node_worker "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/core/camera_worker.py"
click node_camera "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/utils/camera_manager.py"
click node_session "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/core/monitoring_session.py"
click node_config "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/utils/config.py"
click node_factory "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/detector_factory.py"
click node_mediapipe "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/mediapipe_detector.py"
click node_haar "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/haar_detector.py"
click node_detection_types "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/base.py"
click node_eye_metrics "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/eye_metrics.py"
click node_blink "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/blink_detector.py"
click node_distance "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/distance_estimator.py"
click node_presence "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/presence_tracker.py"
click node_breaks "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/break_reminder.py"
click node_stats_tracker "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/stats_tracker.py"
click node_db "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/database/database_manager.py"
click node_aggregation "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/database/statistics.py"
click node_migration "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/database/json_migration.py"
click node_accounts "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/accounts.py"
click node_care_records "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/tree/main/features"
click node_shell "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/shell.py"
click node_screens "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/tree/main/ui/screens"
click node_components "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/components.py"
click node_theme "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/theme.py"
click node_charts "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/charts.py"
click node_export "https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/reports/csv_exporter.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_worker,node_camera,node_session,node_config,node_distance,node_presence,node_breaks,node_stats_tracker,node_user toneBlue
class node_factory,node_mediapipe,node_haar,node_detection_types,node_eye_metrics,node_blink toneAmber
class node_db,node_aggregation,node_migration,node_export toneMint
class node_app,node_shell,node_screens,node_components,node_theme,node_charts toneRose
class node_accounts,node_care_records toneIndigo
```

## Components

### Capture and monitoring

- [Camera worker](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/core/camera_worker.py): `core/camera_worker.py`
- [Camera source](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/utils/camera_manager.py): `utils/camera_manager.py`
- [Monitoring session](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/core/monitoring_session.py): `core/monitoring_session.py`
- [Monitoring configuration](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/utils/config.py): `utils/config.py`
- [Distance estimation](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/distance_estimator.py): `features/distance_estimator.py`
- [Presence tracking](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/presence_tracker.py): `features/presence_tracker.py`
- [Break reminders](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/break_reminder.py): `features/break_reminder.py`
- [Session statistics](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/stats_tracker.py): `features/stats_tracker.py`

### Vision and metrics

- [Detector selection](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/detector_factory.py): `detection/detector_factory.py`
- [MediaPipe detection](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/mediapipe_detector.py): `detection/mediapipe_detector.py`
- [Haar fallback](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/haar_detector.py): `detection/haar_detector.py`
- [Detection results](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/base.py): `detection/base.py`
- [Eye measurements](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/detection/eye_metrics.py): `detection/eye_metrics.py`
- [Blink analysis](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/blink_detector.py): `features/blink_detector.py`

### Persistence and analytics

- [SQLite database](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/database/database_manager.py): `database/database_manager.py`
- [Statistics queries](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/database/statistics.py): `database/statistics.py`
- [S4 history import](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/database/json_migration.py): `database/json_migration.py`
- [CSV export](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/reports/csv_exporter.py): `reports/csv_exporter.py`

### Desktop interface

- [App entry and wiring](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/camera_app.py): `camera_app.py`
- [App navigation](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/shell.py): `ui/shell.py`
- [App screens](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/tree/main/ui/screens): `ui/screens`
- [Reusable UI components](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/components.py): `ui/components.py`
- [Theme system](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/theme.py): `ui/theme.py`
- [Analytics charts](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/ui/charts.py): `ui/charts.py`

### Wellness features

- [Local accounts](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/blob/main/features/accounts.py): `features/accounts.py`
- [Symptoms and visits](https://github.com/arturbakunc880-lab/ihealth_monitoring_system/tree/main/features): `features`

### Other components

- **User**

## Connections

- User → App entry and wiring: starts and uses
- App entry and wiring → Camera worker: starts monitoring (evidence: `camera_app.py`)
- App entry and wiring → Monitoring session: configures session (evidence: `camera_app.py`)
- App entry and wiring → SQLite database: opens storage (evidence: `camera_app.py`)
- App entry and wiring → Local accounts: supports profiles (evidence: `camera_app.py`)
- App entry and wiring → App navigation: shows interface (evidence: `camera_app.py`)
- Camera worker → Camera source: reads frames (evidence: `core/camera_worker.py`)
- Camera worker → Detector selection: creates detector (evidence: `core/camera_worker.py`)
- Camera worker → Monitoring session: updates monitoring (evidence: `core/camera_worker.py`)
- Camera worker → App screens: publishes live results
- Camera worker → Detection results: consumes detections (evidence: `core/camera_worker.py`)
- Camera worker → Distance estimation: draws distance overlay (evidence: `core/camera_worker.py`)
- Camera worker → Blink analysis: draws blink overlay (evidence: `core/camera_worker.py`)
- Detector selection → MediaPipe detection: selects detector (evidence: `detection/detector_factory.py`)
- Detector selection → Haar fallback: falls back to (evidence: `detection/detector_factory.py`)
- MediaPipe detection → Detection results: returns results (evidence: `detection/mediapipe_detector.py`)
- MediaPipe detection → Eye measurements: uses measurements (evidence: `detection/mediapipe_detector.py`)
- MediaPipe detection → Haar fallback: can fall back (evidence: `detection/mediapipe_detector.py`)
- Monitoring session → Blink analysis: processes eye events (evidence: `core/monitoring_session.py`)
- Monitoring session → Distance estimation: updates estimates (evidence: `core/monitoring_session.py`)
- Monitoring session → Presence tracking: tracks attendance (evidence: `core/monitoring_session.py`)
- Monitoring session → Break reminders: checks break timing (evidence: `core/monitoring_session.py`)
- Monitoring session → Session statistics: records session totals (evidence: `core/monitoring_session.py`)
- Monitoring session → SQLite database: persists measurements (evidence: `core/monitoring_session.py`)
- Monitoring session → Monitoring configuration: uses thresholds (evidence: `core/monitoring_session.py`)
- SQLite database → Statistics queries: serves stored records (evidence: `database/statistics.py`)
- App entry and wiring → S4 history import: imports legacy history (evidence: `camera_app.py`)
- S4 history import → SQLite database: writes imported data (evidence: `database/json_migration.py`)
- App navigation → App screens: hosts pages (evidence: `ui/shell.py`)
- App screens → Reusable UI components: uses widgets (evidence: `ui/screens/base.py`)
- Reusable UI components → Theme system: reads theme tokens (evidence: `ui/components.py`)
- App screens → Statistics queries: queries analytics (evidence: `ui/screens/statistics.py`)
- App screens → Analytics charts: renders analytics (evidence: `ui/screens/statistics.py`)
- App screens → CSV export: requests CSV export (evidence: `ui/screens/reports.py`)
- CSV export → SQLite database: reads session data (evidence: `reports/csv_exporter.py`)
- User → Symptoms and visits: checks in and manages visits
