# arhadnane/movementdetection architecture

> Architecture diagram of the GitHub repository arhadnane/movementdetection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arhadnane/movementdetection
- Repository: https://github.com/arhadnane/movementdetection

## Overview

##### Project type and purpose
- This is a Windows-based, full-stack desktop application written in C# (.NET 8.0) with a clean Windows Forms GUI.
- Its purpose is real-time motion detection, on-the-fly video recording and event logging using OpenCvSharp.

##### File structure
- Top level:
- Source files: MainForm.cs, MotionDetector.cs, VideoRecorder.cs, MotionEventLogger.cs, AppConfig.cs, Program.cs
- Configuration: MovementDetection.csproj, config.json, .gitignore
- Output dirs: Recordings/, Logs/
- Scripts: demo.ps1, run.bat
- Patterns:
- UI layer (MainForm)
- Core services (motion detection, recording, logging, configuration)
- File-system persistence (video and log storage)
- Single process with modular components

##### README for additional insights
- The modules and their responsibilities (live feed, overlay, auto/manual recording, logging) are documented in “📋 Project Structure.”
- Dependencies: OpenCvSharp4, System.Text.Json
- Configuration-driven—config.json defines thresholds, camera settings, recording preferences

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% In-Process Modules
    subgraph "In-Process Modules"
        UI["UI Layer (MainForm)"]:::ui
        Program["App Entry (Program.cs)"]:::ui
        ConfigManager["Configuration Manager"]:::service
        Detector["Motion Detection Engine"]:::process
        Recorder["Video Recorder"]:::process
        Logger["Event Logger"]:::process
    end

    %% External Resources
    subgraph "External Resources"
        Camera["Camera Device"]:::io
        FileSystem["File System"]:::io
        subgraph "Storage"
            DirRecordings["Recordings/"]:::io
            DirLogs["Logs/"]:::io
        end
        ConfigFile["config.json"]:::io
        OpenCv["OpenCvSharp Native Libs"]:::io
        Csproj["MovementDetection.csproj"]:::io
        Sln["movement detection.sln"]:::io
    end

    %% Relationships
    Program -->|"launches"| UI
    Program -->|"loads config"| ConfigManager
    UI -->|"reads settings"| ConfigManager
    ConfigManager -->|"reads thresholds"| ConfigFile
    ConfigManager -->|"provides config"| Detector

    Detector <-->|"captures frames"| Camera
    Detector -->|"overlay & status"| UI
    Detector -->|"motion events"| Logger
    Detector -->|"control signals"| Recorder

    Recorder -->|"writes video files"| DirRecordings
    Logger -->|"appends log entries"| DirLogs

    Detector -->|"uses runtime libs"| OpenCv

    %% Click Events
    click UI "https://github.com/arhadnane/movementdetection/blob/master/MainForm.cs"
    click Program "https://github.com/arhadnane/movementdetection/blob/master/Program.cs"
    click ConfigManager "https://github.com/arhadnane/movementdetection/blob/master/AppConfig.cs"
    click ConfigFile "https://github.com/arhadnane/movementdetection/blob/master/config.json"
    click Detector "https://github.com/arhadnane/movementdetection/blob/master/MotionDetector.cs"
    click Recorder "https://github.com/arhadnane/movementdetection/blob/master/VideoRecorder.cs"
    click Logger "https://github.com/arhadnane/movementdetection/blob/master/MotionEventLogger.cs"
    click DirRecordings "https://github.com/arhadnane/movementdetection/tree/master/Recordings/"
    click DirLogs "https://github.com/arhadnane/movementdetection/tree/master/Logs/"
    click Csproj "https://github.com/arhadnane/movementdetection/blob/master/MovementDetection.csproj"
    click Sln "https://github.com/arhadnane/movementdetection/blob/master/movement detection.sln"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef service fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef process fill:#d4edda,stroke:#155724,stroke-width:1px
    classDef io fill:#fff3cd,stroke:#856404,stroke-width:1px
```
