# mbsaravanakumar2006-dotcom/attention_monitor architecture

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

- Interactive diagram: https://gitdiagram.com/mbsaravanakumar2006-dotcom/attention_monitor
- Repository: https://github.com/mbsaravanakumar2006-dotcom/attention_monitor

## Overview

This is a Flask-based classroom attention monitor. Its main workflow captures classroom video, identifies and tracks students, analyzes gaze and posture, classifies attention, and records behavior changes for dashboards and student reports. The graph preserves the documented analytics, alerts, student administration, and access control. Some subsystem links rely on the README or SOURCE INDEX; unsampled implementation details are not inferred beyond those references.

Main entry points: [`app/core/detector.py`](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/detector.py) (Attention detector), [`app/routes.py`](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/routes.py) (Web routes), [`app/models.py`](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/models.py) (Student and event models), [`app.py`](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app.py) (Application startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vision["Video analysis"]
  node_detector["Attention detector<br/>[detector.py]"]
  node_face["Face recognition"]
  node_tracker["Student tracker<br/>[tracker.py]"]
  node_posture["Posture analysis<br/>[posture.py]"]
  node_gaze["Gaze analysis<br/>[gaze.py]"]
  node_fusion["Behavior classification<br/>[fusion.py]"]
end

subgraph group_records["Attention records"]
  node_event_logger["Event logger<br/>[event_logger.py]"]
  node_models["Student and event models<br/>[models.py]"]
  node_database[("SQLite database<br/>[attention.db]")]
end

subgraph group_web["Web application"]
  node_bootstrap["Application startup<br/>[app.py]"]
  node_routes["Web routes<br/>[routes.py]"]
  node_realtime["Live alerts<br/>[events.py]"]
end

subgraph group_views["User interface"]
  node_dashboard["Classroom dashboard<br/>[dashboard.html]"]
  node_dashboard_js["Dashboard interactions<br/>[dashboard.js]"]
  node_reports["Student analytics<br/>[report.html]"]
  node_report_js["Report visualizations<br/>[report.js]"]
  node_student_views["Student management views"]
  node_login["Admin login view<br/>[login.html]"]
end

node_camera(("Classroom camera"))
node_admin(("Administrator"))

node_camera -.->|"provides frames"| node_detector
node_bootstrap -->|"starts pipeline"| node_detector
node_detector -->|"identifies students"| node_face
node_detector -->|"tracks students"| node_tracker
node_detector -->|"analyzes posture"| node_posture
node_detector -->|"analyzes gaze"| node_gaze
node_detector -->|"classifies behavior"| node_fusion
node_detector -->|"logs changes"| node_event_logger
node_event_logger -->|"records events"| node_models
node_bootstrap -->|"creates tables"| node_database
node_routes -->|"queries and updates"| node_models
node_routes -->|"streams frames"| node_detector
node_routes -->|"re-trains recognition"| node_detector
node_admin -.->|"uses secured routes"| node_routes
node_routes -->|"renders login"| node_login
node_routes -.->|"renders dashboard"| node_dashboard
node_routes -.->|"serves analytics"| node_reports
node_routes -->|"renders management"| node_student_views
node_dashboard -.->|"uses interactions"| node_dashboard_js
node_reports -.->|"uses visualizations"| node_report_js
node_detector -.->|"emits alerts"| node_realtime
node_models -.->|"persists records"| node_database

click node_bootstrap "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app.py"
click node_detector "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/detector.py"
click node_face "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/face_recognition.py"
click node_tracker "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/tracker.py"
click node_posture "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/posture.py"
click node_gaze "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/gaze.py"
click node_fusion "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/fusion.py"
click node_event_logger "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/event_logger.py"
click node_models "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/models.py"
click node_database "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/instance/attention.db"
click node_routes "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/routes.py"
click node_realtime "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/events.py"
click node_dashboard "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/dashboard.html"
click node_dashboard_js "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/static/js/dashboard.js"
click node_reports "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/report.html"
click node_report_js "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/static/js/report.js"
click node_student_views "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/manage_students.html"
click node_login "https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/login.html"

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_detector,node_face,node_tracker,node_posture,node_gaze,node_fusion toneBlue
class node_event_logger,node_models,node_database toneAmber
class node_bootstrap,node_routes,node_realtime toneMint
class node_dashboard,node_dashboard_js,node_reports,node_report_js,node_student_views,node_login toneRose
class node_camera,node_admin toneIndigo
```

## Components

### Video analysis

- [Attention detector](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/detector.py): `app/core/detector.py`
- [Face recognition](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/face_recognition.py): `app/core/face_recognition.py`
- [Student tracker](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/tracker.py): `app/core/tracker.py`
- [Posture analysis](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/posture.py): `app/core/posture.py`
- [Gaze analysis](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/gaze.py): `app/core/gaze.py`
- [Behavior classification](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/fusion.py): `app/core/fusion.py`

### Attention records

- [Event logger](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/core/event_logger.py): `app/core/event_logger.py`
- [Student and event models](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/models.py): `app/models.py`
- [SQLite database](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/instance/attention.db): `instance/attention.db`

### Web application

- [Application startup](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app.py): `app.py`
- [Web routes](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/routes.py): `app/routes.py`
- [Live alerts](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/events.py): `app/events.py`

### User interface

- [Classroom dashboard](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/dashboard.html): `app/templates/dashboard.html`
- [Dashboard interactions](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/static/js/dashboard.js): `app/static/js/dashboard.js`
- [Student analytics](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/report.html): `app/templates/report.html`
- [Report visualizations](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/static/js/report.js): `app/static/js/report.js`
- [Student management views](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/manage_students.html): `app/templates/manage_students.html`
- [Admin login view](https://github.com/mbsaravanakumar2006-dotcom/attention_monitor/blob/master/app/templates/login.html): `app/templates/login.html`

### Other components

- **Classroom camera**
- **Administrator**

## Connections

- Classroom camera → Attention detector: provides frames (evidence: `README.md`)
- Application startup → Attention detector: starts pipeline (evidence: `app.py`)
- Attention detector → Face recognition: identifies students (evidence: `app/core/detector.py`)
- Attention detector → Student tracker: tracks students (evidence: `app/core/detector.py`)
- Attention detector → Posture analysis: analyzes posture (evidence: `app/core/detector.py`)
- Attention detector → Gaze analysis: analyzes gaze (evidence: `app/core/detector.py`)
- Attention detector → Behavior classification: classifies behavior (evidence: `app/core/detector.py`)
- Attention detector → Event logger: logs changes (evidence: `app/core/detector.py`)
- Event logger → Student and event models: records events (evidence: `app/core/event_logger.py`)
- Application startup → SQLite database: creates tables (evidence: `app.py`)
- Web routes → Student and event models: queries and updates (evidence: `app/routes.py`)
- Web routes → Attention detector: streams frames (evidence: `app/routes.py`)
- Web routes → Attention detector: re-trains recognition (evidence: `app/routes.py`)
- Administrator → Web routes: uses secured routes (evidence: `README.md`)
- Web routes → Admin login view: renders login (evidence: `app/routes.py`)
- Web routes → Classroom dashboard: renders dashboard (evidence: `README.md`)
- Web routes → Student analytics: serves analytics (evidence: `README.md`)
- Web routes → Student management views: renders management (evidence: `app/routes.py`)
- Classroom dashboard → Dashboard interactions: uses interactions (evidence: `README.md`)
- Student analytics → Report visualizations: uses visualizations (evidence: `README.md`)
- Attention detector → Live alerts: emits alerts (evidence: `README.md`)
- Student and event models → SQLite database: persists records
