# vachan2/mindops architecture

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

- Interactive diagram: https://gitdiagram.com/vachan2/mindops
- Repository: https://github.com/vachan2/mindops

## Overview

NeuroSync monitors developer focus and cognitive load through a live dashboard. A user starts a session; browser signals and webcam-derived eye metrics update session metrics, which are displayed and periodically analyzed into recommendations. The Python service also exposes a live video feed, logs session data, and can optionally push load indicators to an ESP32. The sampled excerpts establish the API and session wiring; some Python processing details and dashboard component wiring are documented or implied by names but not fully sampled.

Main entry points: [`keyboard_implementation/Focus-plus/app/dashboard/page.tsx`](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/dashboard/page.tsx) (Monitoring Dashboard), [`stream_server.py`](https://github.com/vachan2/mindops/blob/main/stream_server.py) (Eye Stream Server), [`keyboard_implementation/Focus-plus/hooks/useSessionTimer.ts`](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/hooks/useSessionTimer.ts) (Session Timer), [`keyboard_implementation/Focus-plus/services/ai.ts`](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/services/ai.ts) (AI Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Dashboard"]
  node_landing["Landing Page<br/>[page.tsx]"]
  node_dashboard["Monitoring Dashboard<br/>[page.tsx]"]
  node_webcam["Webcam Display<br/>[WebcamFeed.tsx]"]
  node_metrics_ui["Metric Cards<br/>[MetricCard.tsx]"]
  node_insight_ui["Insight Panel<br/>[AIInsightPanel.tsx]"]
  node_charts["Live Charts<br/>[LiveChart.tsx]"]
end

subgraph group_session["Session Metrics"]
  node_keyboard_tracker["Keyboard Tracker"]
  node_session_timer["Session Timer<br/>[useSessionTimer.ts]"]
  node_store["Session Store<br/>[sessionStore.ts]"]
end

subgraph group_vision["Vision Service"]
  node_python_server["Eye Stream Server<br/>[stream_server.py]"]
  node_eye_tracker["Eye Tracking<br/>[eye_tracking.py]"]
  node_blink_detection["Blink Detection<br/>[blink_detection.py]"]
  node_cognitive_load["Load Scoring<br/>[cognitive_load.py]"]
  node_logger["Session Logger<br/>[data_logger.py]"]
  node_eye_api["Eye Metrics API<br/>[route.ts]"]
  node_video_api["Video Feed API<br/>[route.ts]"]
end

subgraph group_insights["Insights"]
  node_analyze_route["Analysis API<br/>[route.ts]"]
  node_ai["AI Analysis<br/>[ai.ts]"]
  node_sarvam["Sarvam API"]
  node_mistral["Mistral API"]
  node_ollama["Ollama Model"]
end

node_user(("Developer"))
node_camera(("Webcam"))
node_esp32(("ESP32 LED Ring"))

node_user -->|"opens"| node_landing
node_landing -->|"launches"| node_dashboard
node_user -->|"controls session"| node_dashboard
node_dashboard -->|"starts polling"| node_session_timer
node_dashboard -->|"starts tracking"| node_keyboard_tracker
node_session_timer -->|"updates metrics"| node_store
node_keyboard_tracker -->|"writes typing signals"| node_store
node_dashboard -->|"reads session state"| node_store
node_dashboard -->|"renders metrics"| node_metrics_ui
node_dashboard -->|"renders history"| node_charts
node_dashboard -->|"shows video"| node_webcam
node_dashboard -->|"shows analysis"| node_insight_ui
node_session_timer -->|"polls metrics"| node_eye_api
node_eye_api -->|"fetches metrics"| node_python_server
node_python_server -->|"returns snapshot"| node_eye_api
node_session_timer -->|"posts metrics"| node_analyze_route
node_analyze_route -->|"analyzes metrics"| node_ai
node_ai -->|"tries first"| node_sarvam
node_ai -->|"falls back"| node_mistral
node_ai -.->|"uses if enabled"| node_ollama
node_ai -->|"returns insight"| node_analyze_route
node_analyze_route -->|"returns analysis"| node_session_timer
node_session_timer -->|"stores analysis"| node_store
node_webcam -->|"requests stream"| node_video_api
node_video_api -->|"proxies feed"| node_python_server
node_camera -->|"provides frames"| node_python_server
node_python_server -->|"tracks eyes"| node_eye_tracker
node_python_server -->|"detects blinks"| node_blink_detection
node_python_server -->|"scores load"| node_cognitive_load
node_python_server -->|"logs session"| node_logger
node_python_server -.->|"pushes load"| node_esp32

click node_landing "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/page.tsx"
click node_dashboard "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/dashboard/page.tsx"
click node_webcam "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/WebcamFeed.tsx"
click node_metrics_ui "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/MetricCard.tsx"
click node_insight_ui "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/AIInsightPanel.tsx"
click node_charts "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/LiveChart.tsx"
click node_keyboard_tracker "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/hooks/useKeyboardTracker.ts"
click node_session_timer "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/hooks/useSessionTimer.ts"
click node_store "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/store/sessionStore.ts"
click node_analyze_route "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/api/analyze/route.ts"
click node_ai "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/services/ai.ts"
click node_python_server "https://github.com/vachan2/mindops/blob/main/stream_server.py"
click node_eye_tracker "https://github.com/vachan2/mindops/blob/main/eye_tracking.py"
click node_blink_detection "https://github.com/vachan2/mindops/blob/main/blink_detection.py"
click node_cognitive_load "https://github.com/vachan2/mindops/blob/main/cognitive_load.py"
click node_logger "https://github.com/vachan2/mindops/blob/main/data_logger.py"
click node_eye_api "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/api/eye-metrics/route.ts"
click node_video_api "https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/api/video-feed/route.ts"

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_landing,node_dashboard,node_webcam,node_metrics_ui,node_insight_ui,node_charts toneBlue
class node_keyboard_tracker,node_session_timer,node_store toneAmber
class node_python_server,node_eye_tracker,node_blink_detection,node_cognitive_load,node_logger,node_eye_api,node_video_api toneMint
class node_analyze_route,node_ai,node_sarvam,node_mistral,node_ollama toneRose
class node_user,node_camera,node_esp32 toneIndigo
```

## Components

### Dashboard

- [Landing Page](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/page.tsx): `keyboard_implementation/Focus-plus/app/page.tsx`
- [Monitoring Dashboard](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/dashboard/page.tsx): `keyboard_implementation/Focus-plus/app/dashboard/page.tsx`
- [Webcam Display](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/WebcamFeed.tsx): `keyboard_implementation/Focus-plus/components/ui/WebcamFeed.tsx`
- [Metric Cards](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/MetricCard.tsx): `keyboard_implementation/Focus-plus/components/ui/MetricCard.tsx`
- [Insight Panel](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/AIInsightPanel.tsx): `keyboard_implementation/Focus-plus/components/ui/AIInsightPanel.tsx`
- [Live Charts](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/components/ui/LiveChart.tsx): `keyboard_implementation/Focus-plus/components/ui/LiveChart.tsx`

### Session Metrics

- [Keyboard Tracker](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/hooks/useKeyboardTracker.ts): `keyboard_implementation/Focus-plus/hooks/useKeyboardTracker.ts`
- [Session Timer](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/hooks/useSessionTimer.ts): `keyboard_implementation/Focus-plus/hooks/useSessionTimer.ts`
- [Session Store](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/store/sessionStore.ts): `keyboard_implementation/Focus-plus/store/sessionStore.ts`

### Vision Service

- [Eye Stream Server](https://github.com/vachan2/mindops/blob/main/stream_server.py): `stream_server.py`
- [Eye Tracking](https://github.com/vachan2/mindops/blob/main/eye_tracking.py): `eye_tracking.py`
- [Blink Detection](https://github.com/vachan2/mindops/blob/main/blink_detection.py): `blink_detection.py`
- [Load Scoring](https://github.com/vachan2/mindops/blob/main/cognitive_load.py): `cognitive_load.py`
- [Session Logger](https://github.com/vachan2/mindops/blob/main/data_logger.py): `data_logger.py`
- [Eye Metrics API](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/api/eye-metrics/route.ts): `keyboard_implementation/Focus-plus/app/api/eye-metrics/route.ts`
- [Video Feed API](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/api/video-feed/route.ts): `keyboard_implementation/Focus-plus/app/api/video-feed/route.ts`

### Insights

- [Analysis API](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/app/api/analyze/route.ts): `keyboard_implementation/Focus-plus/app/api/analyze/route.ts`
- [AI Analysis](https://github.com/vachan2/mindops/blob/main/keyboard_implementation/Focus-plus/services/ai.ts): `keyboard_implementation/Focus-plus/services/ai.ts`
- **Sarvam API**
- **Mistral API**
- **Ollama Model**

### Other components

- **Developer**
- **Webcam**
- **ESP32 LED Ring**

## Connections

- Developer → Landing Page: opens
- Landing Page → Monitoring Dashboard: launches
- Developer → Monitoring Dashboard: controls session
- Monitoring Dashboard → Session Timer: starts polling
- Monitoring Dashboard → Keyboard Tracker: starts tracking
- Session Timer → Session Store: updates metrics
- Keyboard Tracker → Session Store: writes typing signals
- Monitoring Dashboard → Session Store: reads session state
- Monitoring Dashboard → Metric Cards: renders metrics
- Monitoring Dashboard → Live Charts: renders history
- Monitoring Dashboard → Webcam Display: shows video
- Monitoring Dashboard → Insight Panel: shows analysis
- Session Timer → Eye Metrics API: polls metrics
- Eye Metrics API → Eye Stream Server: fetches metrics
- Eye Stream Server → Eye Metrics API: returns snapshot
- Session Timer → Analysis API: posts metrics
- Analysis API → AI Analysis: analyzes metrics
- AI Analysis → Sarvam API: tries first
- AI Analysis → Mistral API: falls back
- AI Analysis → Ollama Model: uses if enabled
- AI Analysis → Analysis API: returns insight
- Analysis API → Session Timer: returns analysis
- Session Timer → Session Store: stores analysis
- Webcam Display → Video Feed API: requests stream
- Video Feed API → Eye Stream Server: proxies feed
- Webcam → Eye Stream Server: provides frames
- Eye Stream Server → Eye Tracking: tracks eyes
- Eye Stream Server → Blink Detection: detects blinks
- Eye Stream Server → Load Scoring: scores load
- Eye Stream Server → Session Logger: logs session
- Eye Stream Server → ESP32 LED Ring: pushes load
