# sonutelcoandai/visionguard-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sonutelcoandai/visionguard-ai
- Repository: https://github.com/sonutelcoandai/visionguard-ai

## Overview

VisionGuard-AI is a Flask-based camera-monitoring application. A camera feed is processed into person detections, identities and attributes; crowd analytics update shared state and alerts, while API endpoints expose video, current detections, alerts and analytics. Face-management endpoints maintain the known-face dataset. The graph preserves documented-by-code capabilities, but README content is absent and several services and analytics modules were not excerpted, so their internal relationships are omitted where the evidence does not establish them.

Main entry points: [`backend/app/camera/camera_processor.py`](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/camera/camera_processor.py) (Camera processor), [`backend/app/main.py`](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/main.py) (Application startup), [`backend/app/bootstrap/ai_bootstrap.py`](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/bootstrap/ai_bootstrap.py) (AI initialization), [`backend/app/api/events.py`](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/events.py) (Events API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime and API"]
  node_entry["Application startup<br/>[main.py]"]
  node_flask["Flask app factory<br/>[create_app.py]"]
  node_camera_api["Camera API<br/>[cameras.py]"]
  node_event_api["Events API<br/>[events.py]"]
  node_user_api["Users API<br/>[users.py]"]
  node_state["Shared runtime state<br/>[app_state.py]"]
  node_config["Application configuration<br/>[config.py]"]
end

subgraph group_vision["Camera and vision"]
  node_processor["Camera processor"]
  node_stream["Camera stream helpers<br/>[stream.py]"]
  node_bootstrap["AI initialization<br/>[ai_bootstrap.py]"]
  node_models["Model loader<br/>[model_manager.py]"]
  node_person["Person detector<br/>[person.py]"]
  node_age["Age analysis<br/>[age.py]"]
  node_gender["Gender analysis<br/>[gender.py]"]
end

subgraph group_insights["Analytics and alerts"]
  node_behavior["Behavior analysis<br/>[behavior.py]"]
  node_crowd["Crowd tracking and analysis<br/>[crowd.py]"]
  node_alert_service["Alert service<br/>[alert_service.py]"]
  node_event_service["Event aggregation<br/>[event_service.py]"]
  node_analytics_service["Analytics service"]
  node_logger["Detection log<br/>[logger.py]"]
end

subgraph group_identity["Identity management"]
  node_faces["Known-face manager<br/>[face.py]"]
  node_identity_rec["Identity recognizer<br/>[identity.py]"]
  node_face_service["Face dataset service<br/>[face_service.py]"]
end

node_operator(("Client"))

node_operator -->|"requests video"| node_camera_api
node_operator -->|"requests data"| node_event_api
node_operator -.->|"manages faces"| node_user_api
node_entry -->|"creates app"| node_flask
node_flask -->|"registers routes"| node_camera_api
node_flask -->|"registers routes"| node_event_api
node_flask -->|"registers routes"| node_user_api
node_entry -->|"supplies frame generator"| node_processor
node_camera_api -->|"streams frames"| node_processor
node_camera_api -->|"reads detections"| node_state
node_entry -->|"supplies detection data"| node_state
node_processor -->|"opens capture"| node_stream
node_processor -->|"uses AI container"| node_bootstrap
node_processor -->|"extracts persons"| node_person
node_processor -->|"predicts age"| node_age
node_processor -->|"predicts gender"| node_gender
node_processor -->|"uses analysis"| node_behavior
node_processor -->|"updates tracks and analytics"| node_crowd
node_processor -->|"records alerts"| node_alert_service
node_processor -->|"updates detections and counts"| node_state
node_bootstrap -->|"loads models"| node_models
node_bootstrap -->|"constructs detector"| node_person
node_bootstrap -->|"constructs analyzer"| node_age
node_bootstrap -->|"constructs analyzer"| node_gender
node_bootstrap -->|"loads known faces"| node_faces
node_bootstrap -->|"constructs recognizer"| node_identity_rec
node_bootstrap -->|"constructs tracker and analytics"| node_crowd
node_face_service -->|"reloads face data"| node_faces
node_entry -->|"wires upload handlers"| node_face_service
node_entry -->|"supplies event callbacks"| node_event_api
node_event_api -->|"reads detections"| node_state
node_event_api -->|"requests alerts"| node_event_service
node_event_api -->|"requests analytics"| node_analytics_service
node_event_service -->|"combines recent alerts"| node_alert_service
node_alert_service -->|"writes log row"| node_logger
node_entry -->|"adds startup alert"| node_alert_service
node_entry -->|"initializes log headers"| node_logger
node_entry -->|"ensures face dataset"| node_faces
node_models -->|"reads model paths"| node_config
node_faces -->|"reads face dataset settings"| node_config
node_face_service -->|"reads dataset paths"| node_config
node_processor -->|"uses camera and zone settings"| node_config

click node_entry "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/main.py"
click node_flask "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/create_app.py"
click node_camera_api "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/cameras.py"
click node_event_api "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/events.py"
click node_user_api "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/users.py"
click node_state "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/state/app_state.py"
click node_processor "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/camera/camera_processor.py"
click node_stream "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/camera/stream.py"
click node_bootstrap "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/bootstrap/ai_bootstrap.py"
click node_models "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/model_manager.py"
click node_person "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/detector/person.py"
click node_faces "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/recognition/face.py"
click node_identity_rec "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/recognition/identity.py"
click node_age "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/age.py"
click node_gender "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/gender.py"
click node_behavior "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/behavior.py"
click node_crowd "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/crowd.py"
click node_alert_service "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/alert_service.py"
click node_event_service "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/event_service.py"
click node_analytics_service "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/analytics_service.py"
click node_face_service "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/face_service.py"
click node_logger "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/core/logger.py"
click node_config "https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/core/config.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_entry,node_flask,node_camera_api,node_event_api,node_user_api,node_state,node_config,node_operator toneBlue
class node_processor,node_stream,node_bootstrap,node_models,node_person,node_age,node_gender toneAmber
class node_behavior,node_crowd,node_alert_service,node_event_service,node_analytics_service,node_logger toneMint
class node_faces,node_identity_rec,node_face_service toneRose
```

## Components

### Runtime and API

- [Application startup](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/main.py): `backend/app/main.py`
- [Flask app factory](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/create_app.py): `backend/app/create_app.py`
- [Camera API](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/cameras.py): `backend/app/api/cameras.py`
- [Events API](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/events.py): `backend/app/api/events.py`
- [Users API](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/api/users.py): `backend/app/api/users.py`
- [Shared runtime state](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/state/app_state.py): `backend/app/state/app_state.py`
- [Application configuration](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Camera and vision

- [Camera processor](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/camera/camera_processor.py): `backend/app/camera/camera_processor.py`
- [Camera stream helpers](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/camera/stream.py): `backend/app/camera/stream.py`
- [AI initialization](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/bootstrap/ai_bootstrap.py): `backend/app/bootstrap/ai_bootstrap.py`
- [Model loader](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/model_manager.py): `backend/app/ai_engine/model_manager.py`
- [Person detector](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/detector/person.py): `backend/app/ai_engine/detector/person.py`
- [Age analysis](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/age.py): `backend/app/ai_engine/analytics/age.py`
- [Gender analysis](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/gender.py): `backend/app/ai_engine/analytics/gender.py`

### Analytics and alerts

- [Behavior analysis](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/behavior.py): `backend/app/ai_engine/analytics/behavior.py`
- [Crowd tracking and analysis](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/analytics/crowd.py): `backend/app/ai_engine/analytics/crowd.py`
- [Alert service](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/alert_service.py): `backend/app/services/alert_service.py`
- [Event aggregation](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/event_service.py): `backend/app/services/event_service.py`
- [Analytics service](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/analytics_service.py): `backend/app/services/analytics_service.py`
- [Detection log](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/core/logger.py): `backend/app/core/logger.py`

### Identity management

- [Known-face manager](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/recognition/face.py): `backend/app/ai_engine/recognition/face.py`
- [Identity recognizer](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/ai_engine/recognition/identity.py): `backend/app/ai_engine/recognition/identity.py`
- [Face dataset service](https://github.com/sonutelcoandai/visionguard-ai/blob/main/backend/app/services/face_service.py): `backend/app/services/face_service.py`

### Other components

- **Client**

## Connections

- Client → Camera API: requests video (evidence: `backend/app/api/cameras.py`)
- Client → Events API: requests data (evidence: `backend/app/api/events.py`)
- Client → Users API: manages faces
- Application startup → Flask app factory: creates app (evidence: `backend/app/main.py`)
- Flask app factory → Camera API: registers routes (evidence: `backend/app/create_app.py`)
- Flask app factory → Events API: registers routes (evidence: `backend/app/create_app.py`)
- Flask app factory → Users API: registers routes (evidence: `backend/app/create_app.py`)
- Application startup → Camera processor: supplies frame generator (evidence: `backend/app/main.py`)
- Camera API → Camera processor: streams frames (evidence: `backend/app/main.py`)
- Camera API → Shared runtime state: reads detections (evidence: `backend/app/api/cameras.py`)
- Application startup → Shared runtime state: supplies detection data (evidence: `backend/app/main.py`)
- Camera processor → Camera stream helpers: opens capture (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → AI initialization: uses AI container (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Person detector: extracts persons (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Age analysis: predicts age (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Gender analysis: predicts gender (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Behavior analysis: uses analysis (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Crowd tracking and analysis: updates tracks and analytics (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Alert service: records alerts (evidence: `backend/app/camera/camera_processor.py`)
- Camera processor → Shared runtime state: updates detections and counts (evidence: `backend/app/camera/camera_processor.py`)
- AI initialization → Model loader: loads models (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- AI initialization → Person detector: constructs detector (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- AI initialization → Age analysis: constructs analyzer (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- AI initialization → Gender analysis: constructs analyzer (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- AI initialization → Known-face manager: loads known faces (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- AI initialization → Identity recognizer: constructs recognizer (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- AI initialization → Crowd tracking and analysis: constructs tracker and analytics (evidence: `backend/app/bootstrap/ai_bootstrap.py`)
- Face dataset service → Known-face manager: reloads face data (evidence: `backend/app/services/face_service.py`)
- Application startup → Face dataset service: wires upload handlers (evidence: `backend/app/main.py`)
- Application startup → Events API: supplies event callbacks (evidence: `backend/app/main.py`)
- Events API → Shared runtime state: reads detections (evidence: `backend/app/main.py`)
- Events API → Event aggregation: requests alerts (evidence: `backend/app/main.py`)
- Events API → Analytics service: requests analytics (evidence: `backend/app/main.py`)
- Event aggregation → Alert service: combines recent alerts (evidence: `backend/app/services/event_service.py`)
- Alert service → Detection log: writes log row (evidence: `backend/app/services/alert_service.py`)
- Application startup → Alert service: adds startup alert (evidence: `backend/app/main.py`)
- Application startup → Detection log: initializes log headers (evidence: `backend/app/main.py`)
- Application startup → Known-face manager: ensures face dataset (evidence: `backend/app/main.py`)
- Model loader → Application configuration: reads model paths (evidence: `backend/app/ai_engine/model_manager.py`)
- Known-face manager → Application configuration: reads face dataset settings (evidence: `backend/app/ai_engine/recognition/face.py`)
- Face dataset service → Application configuration: reads dataset paths (evidence: `backend/app/services/face_service.py`)
- Camera processor → Application configuration: uses camera and zone settings (evidence: `backend/app/camera/camera_processor.py`)
