# k1ethoang/surveillance-camera-system architecture

> Architecture diagram of the GitHub repository k1ethoang/surveillance-camera-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/k1ethoang/surveillance-camera-system
- Repository: https://github.com/k1ethoang/surveillance-camera-system

## Overview

##### Project type and purpose
- This “Surveillance-Camera-System” is a full-stack, web-based surveillance solution composed of two Django services (ai-system and traffic-mngt) plus a camera-stream-simulator.
- ai-system provides camera configuration, live streaming and AI-powered object detection (YOLO models).
- traffic-mngt is a companion service for traffic management workflows, consuming camera data or detection events.
- camera-stream-simulator spins up simulated RTSP/HLS streams from video files for end-to-end testing.

##### File structure
- Top-level directories:
- ai-system: Django project “ai_system” with app “ai_app”
- traffic-mngt: Django project “traffic_mngt” with app “main_app”
- camera-stream-simulator: Docker Compose config and sample videos
- weights: YOLO model files used by ai-system
- Patterns:
- Django MVC (Models in models.py, Views in views.py, Templates in ai-system/templates)
- Management commands in ai_app/management/commands handle background stream tasks
- camera_process module encapsulates registration, streaming and inference logic
- Config & deployment:
- .env.sample in each service
- requirements.txt for Python dependencies
- docker-compose.yml for simulator

##### README
- The README only supplies the project title.
- File names and directory structure reveal key components and workflows.

##### Elements
- Blue for Web UI/API
- Green for background/AI services
- Orange for external systems (cameras, DB)
- Rounded rectangles for services

##### Detailed guidance
- Finally, include the camera-stream-simulator environment (docker-compose) feeding streams to the processing worker.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User
    Browser["Web Browser"]:::external

    %% ai-system Service
    subgraph "ai-system Service"
        direction TB
        API["ai-system Web UI & REST API"]:::webui
        CONF["ai-system Django Config"]:::webui
        MGMT["ai-system Management Commands"]:::background
        CP["Camera-Process Worker"]:::background
        EP1["ai-system Entrypoint & Dependencies"]:::webui
    end

    %% traffic-mngt Service
    subgraph "traffic-mngt Service"
        direction TB
        TM_API["traffic-mngt Web UI & REST API"]:::webui
        TM_CONF["traffic-mngt Django Config"]:::webui
        TM_ENTRY["traffic-mngt Entrypoint & Dependencies"]:::webui
    end

    %% Storage and DB
    DB["Database"]:::db
    WEIGHTS["YOLO Model Weights Storage"]:::storage
    DETECTED["detected_video.mp4"]:::storage

    %% Simulator
    subgraph "Simulator Environment"
        direction TB
        SIM["camera-stream-simulator"]:::external
        STREAMS["RTSP/HLS Streams"]:::external
    end

    %% Connections
    Browser -->|HTTP| API
    API -->|ORM read/write| DB
    API -->|schedule tasks| MGMT
    MGMT -->|invoke| CP
    CP -->|pull frames| STREAMS
    CP -->|load weights| WEIGHTS
    CP -->|send detections| API
    CP -->|save video| DETECTED
    Browser -->|HTTP| TM_API
    TM_API -->|query| DB

    %% Click Events
    click API "https://github.com/k1ethoang/surveillance-camera-system/tree/master/ai-system/ai_app"
    click CONF "https://github.com/k1ethoang/surveillance-camera-system/tree/master/ai-system/ai_system"
    click MGMT "https://github.com/k1ethoang/surveillance-camera-system/blob/master/ai-system/ai_app/management/commands/handle_stream_camera.py"
    click CP "https://github.com/k1ethoang/surveillance-camera-system/tree/master/ai-system/camera_process"
    click WEIGHTS "https://github.com/k1ethoang/surveillance-camera-system/tree/master/ai-system/weights"
    click EP1 "https://github.com/k1ethoang/surveillance-camera-system/blob/master/ai-system/manage.py"
    click TM_API "https://github.com/k1ethoang/surveillance-camera-system/tree/master/traffic-mngt/main_app"
    click TM_CONF "https://github.com/k1ethoang/surveillance-camera-system/tree/master/traffic-mngt/traffic_mngt"
    click TM_ENTRY "https://github.com/k1ethoang/surveillance-camera-system/blob/master/traffic-mngt/manage.py"
    click SIM "https://github.com/k1ethoang/surveillance-camera-system/tree/master/camera-stream-simulator"

    %% Styles
    classDef webui fill:#8ab6d6,stroke:#333,stroke-width:1px
    classDef background fill:#a2d5c6,stroke:#333,stroke-width:1px
    classDef external fill:#f5b461,stroke:#333,stroke-width:1px
    classDef db fill:#cccccc,stroke:#333,stroke-width:1px
    classDef storage fill:#e3e4e5,stroke:#333,stroke-width:1px
```
