# peera-exe/wifi-human-detection architecture

> Architecture diagram of the GitHub repository peera-exe/wifi-human-detection, 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/peera-exe/wifi-human-detection
- Repository: https://github.com/peera-exe/wifi-human-detection

## Overview

This Flask Wi-Fi sensing demo serves role-based user and admin dashboards. The main workflow polls simulated room-sensing state, displays occupancy and movement, and records detection history; administrators can also configure scenarios, thresholds, calibration, and dataset recording. Login events and detection records are stored in SQLite. The sensing source is a simulator rather than a demonstrated hardware integration; the UI mentions LINE alerts, but no alert service is evidenced. Relationships reflect the sampled app and JavaScript excerpts.

Main entry points: [`server/app.py`](https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py) (Status and controls API), [`static/js/admin.js`](https://github.com/peera-exe/wifi-human-detection/blob/main/static/js/admin.js) (Admin panel client), [`templates/login.html`](https://github.com/peera-exe/wifi-human-detection/blob/main/templates/login.html) (Login page), [`server/database.py`](https://github.com/peera-exe/wifi-human-detection/blob/main/server/database.py) (SQLite records)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_login_page["Login page<br/>[login.html]"]
  node_user_dashboard["User dashboard"]
  node_user_client["User dashboard client<br/>[user.js]"]
  node_admin_dashboard["Admin panel<br/>[admin_panel.html]"]
  node_admin_client["Admin panel client<br/>[admin.js]"]
end

subgraph group_server["Application server"]
  node_flask_app["Flask routes<br/>[app.py]"]
  node_auth["Login and sessions<br/>[app.py]"]
  node_status_api["Status and controls API<br/>[app.py]"]
  node_history_api["History API<br/>[app.py]"]
end

subgraph group_sensing["Sensing simulation"]
  node_sensing_engine["Scenario sensing simulator<br/>[data_source.py]"]
  node_dataset_capture["Dataset capture<br/>[data_source.py]"]
end

subgraph group_storage["Persistence"]
  node_sqlite_store[("SQLite records<br/>[database.py]")]
end

node_user_actor(("User"))
node_admin_actor(("Admin"))

node_user_actor -->|"opens"| node_login_page
node_admin_actor -->|"opens"| node_login_page
node_login_page -->|"submits login"| node_auth
node_auth -->|"routes to dashboards"| node_flask_app
node_flask_app -->|"renders"| node_login_page
node_flask_app -->|"renders"| node_user_dashboard
node_flask_app -->|"renders"| node_admin_dashboard
node_user_actor -->|"uses"| node_user_dashboard
node_admin_actor -->|"uses"| node_admin_dashboard
node_user_client -->|"polls status"| node_status_api
node_user_client -->|"sets security"| node_status_api
node_user_client -->|"loads and clears"| node_history_api
node_admin_client -->|"polls status"| node_status_api
node_admin_client -->|"sets controls"| node_status_api
node_admin_client -->|"loads and clears"| node_history_api
node_admin_client -->|"loads login logs"| node_auth
node_status_api -->|"reads state"| node_sensing_engine
node_status_api -->|"sets scenario and controls"| node_sensing_engine
node_status_api -->|"writes detection logs"| node_sqlite_store
node_history_api -->|"reads and clears history"| node_sqlite_store
node_auth -->|"records and reads login logs"| node_sqlite_store
node_sensing_engine -->|"captures frames when recording"| node_dataset_capture
node_dataset_capture -->|"saves frames"| node_sqlite_store

click node_login_page "https://github.com/peera-exe/wifi-human-detection/blob/main/templates/login.html"
click node_user_dashboard "https://github.com/peera-exe/wifi-human-detection/blob/main/templates/user_dashboard.html"
click node_user_client "https://github.com/peera-exe/wifi-human-detection/blob/main/static/js/user.js"
click node_admin_dashboard "https://github.com/peera-exe/wifi-human-detection/blob/main/templates/admin_panel.html"
click node_admin_client "https://github.com/peera-exe/wifi-human-detection/blob/main/static/js/admin.js"
click node_flask_app "https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py"
click node_auth "https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py"
click node_status_api "https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py"
click node_history_api "https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py"
click node_sensing_engine "https://github.com/peera-exe/wifi-human-detection/blob/main/server/data_source.py"
click node_dataset_capture "https://github.com/peera-exe/wifi-human-detection/blob/main/server/data_source.py"
click node_sqlite_store "https://github.com/peera-exe/wifi-human-detection/blob/main/server/database.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_login_page,node_user_dashboard,node_user_client,node_admin_dashboard,node_admin_client,node_user_actor toneBlue
class node_flask_app,node_auth,node_status_api,node_history_api toneAmber
class node_sensing_engine,node_dataset_capture toneMint
class node_sqlite_store toneRose
class node_admin_actor toneIndigo
```

## Components

### Web interface

- [Login page](https://github.com/peera-exe/wifi-human-detection/blob/main/templates/login.html): `templates/login.html`
- [User dashboard](https://github.com/peera-exe/wifi-human-detection/blob/main/templates/user_dashboard.html): `templates/user_dashboard.html`
- [User dashboard client](https://github.com/peera-exe/wifi-human-detection/blob/main/static/js/user.js): `static/js/user.js`
- [Admin panel](https://github.com/peera-exe/wifi-human-detection/blob/main/templates/admin_panel.html): `templates/admin_panel.html`
- [Admin panel client](https://github.com/peera-exe/wifi-human-detection/blob/main/static/js/admin.js): `static/js/admin.js`

### Application server

- [Flask routes](https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py): `server/app.py`
- [Login and sessions](https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py): `server/app.py`
- [Status and controls API](https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py): `server/app.py`
- [History API](https://github.com/peera-exe/wifi-human-detection/blob/main/server/app.py): `server/app.py`

### Sensing simulation

- [Scenario sensing simulator](https://github.com/peera-exe/wifi-human-detection/blob/main/server/data_source.py): `server/data_source.py`
- [Dataset capture](https://github.com/peera-exe/wifi-human-detection/blob/main/server/data_source.py): `server/data_source.py`

### Persistence

- [SQLite records](https://github.com/peera-exe/wifi-human-detection/blob/main/server/database.py): `server/database.py`

### Other components

- **User**
- **Admin**

## Connections

- User → Login page: opens
- Admin → Login page: opens
- Login page → Login and sessions: submits login
- Login and sessions → Flask routes: routes to dashboards (evidence: `server/app.py`)
- Flask routes → Login page: renders (evidence: `server/app.py`)
- Flask routes → User dashboard: renders (evidence: `server/app.py`)
- Flask routes → Admin panel: renders (evidence: `server/app.py`)
- User → User dashboard: uses
- Admin → Admin panel: uses
- User dashboard client → Status and controls API: polls status (evidence: `static/js/user.js`)
- User dashboard client → Status and controls API: sets security (evidence: `static/js/user.js`)
- User dashboard client → History API: loads and clears (evidence: `static/js/user.js`)
- Admin panel client → Status and controls API: polls status (evidence: `static/js/admin.js`)
- Admin panel client → Status and controls API: sets controls (evidence: `static/js/admin.js`)
- Admin panel client → History API: loads and clears (evidence: `static/js/admin.js`)
- Admin panel client → Login and sessions: loads login logs (evidence: `static/js/admin.js`)
- Status and controls API → Scenario sensing simulator: reads state (evidence: `server/app.py`)
- Status and controls API → Scenario sensing simulator: sets scenario and controls (evidence: `server/app.py`)
- Status and controls API → SQLite records: writes detection logs (evidence: `server/app.py`)
- History API → SQLite records: reads and clears history (evidence: `server/app.py`)
- Login and sessions → SQLite records: records and reads login logs (evidence: `server/app.py`)
- Scenario sensing simulator → Dataset capture: captures frames when recording (evidence: `server/data_source.py`)
- Dataset capture → SQLite records: saves frames (evidence: `server/data_source.py`)
