# galaxyannihilator/firedetectionsystem architecture

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

- Interactive diagram: https://gitdiagram.com/galaxyannihilator/firedetectionsystem
- Repository: https://github.com/galaxyannihilator/firedetectionsystem

## Overview

##### Project’s Purpose and Structure
- The project is a real-time fire detection system using YOLOv8, integrated with an IoT alert mechanism (via Telegram and an alarm system) and a Flask-based API for deployment.
- It is essentially a full-stack application focused on computer vision (detection) with embedded alerting and deployment services.
- The project contains several core areas: data management (datasets stored in raw, processed, and augmented directories as outlined in the README’s “data/” folder), data processing and training (notebooks for EDA, data processing, and training), an IoT module (telegram_api.py and alarm_system.py), model management (the “models” folder with best.pt weights), deployment (Flask API via app.py and predict.py), testing (unit tests, with integration and testing folders) and documentation.

##### File Structure & README
- Top-level directories like “src”, “models”, “deployment”, and “tests” hint at logical groupings for data processing, model management, API deployment, and quality assurance.
- The README clarifies the purpose behind each directory (e.g., “data/” for various image and video datasets, “src/” for all experimentation and training notebooks, and “deployment/” for serving the model).

a. Main Components to Include:
- Data Folder:
- Raw Data (from the “data/raw” directory)
- Annotated/Processed Data (from “data/processed”)
- Augmented Data (from “data/augmented”)
- Data Processing & Training Module:
- EDA Notebook (src/EDA.ipynb)
- Data Processing Notebook (src/data_processing.ipynb)
- Training Notebook (src/train_model.ipynb)
- IoT Module:
- Telegram API (src/iot/telegram_api.py)
- Alarm System (src/iot/alarm_system.py)
- Model Repository:
- Model Weights (models/best.pt)
- Deployment Service:
- Flask API Application (deployment/app.py)
- Prediction Service (deployment/predict.py)
- Testing Framework:
- Unit Tests (tests/unit)
- (If available, integration tests as mentioned in README for broader testing)
- Documentation:
- Reports and Presentations (as mentioned in the README under docs/)

b. Relationships and Interactions:
- Data flows from raw data through processing/augmentation modules to produce annotated datasets.
- The processed data is then fed into the training notebook to update or refine the model.
- Once training is completed, the model weights are saved in the Model Repository.
- The deployed Flask API loads these model weights via the predict service to run real-time detections.
- The IoT module listens for detection events and sends alerts through Telegram and triggers an alarm if necessary.
- Unit and integration tests cover both the data processing/training modules and the deployed services.
- Documentation provides insight into every stage of the project from data collection to model performance.

c. Highlighting Architectural Patterns:
- Separation of concerns: Each module (data processing, training, deployment, IoT, testing) is clearly separated.
- Modular design: The project is broken into micro-components which might interact via defined interfaces (e.g., the Flask API calls the predict service, while the IoT module acts upon detection results).
- Use of notebooks for exploration and model training, along with production-ready deployment code.

d. Including Technologies and Frameworks:
- Python 3.9 environment and PyTorch for deep learning, with emphasis on YOLOv8 for object detection.
- Flask framework for API deployment.
- Telegram API integration for IoT alerts.
- Docker (as indicated in the repository) for containerized deployment if needed.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Folder
    subgraph "Data Folder"
        DataRaw["Raw Data"]:::data
        DataAnnotated["Annotated Data"]:::data
        DataAugmented["Augmented Data"]:::data
    end

    %% Data Processing & Training Module
    subgraph "Data Processing & Training Module"
        EDA["EDA Notebook"]:::processing
        DataProcessing["Data Processing Notebook"]:::processing
        Training["Training Notebook"]:::processing
    end

    %% Model Repository
    subgraph "Model Repository"
        Model["Model Weights"]:::database
    end

    %% Deployment Service
    subgraph "Deployment Service"
        FlaskApp["Flask API App"]:::deployment
        Predict["Predict Service"]:::deployment
    end

    %% IoT Module
    subgraph "IoT Module"
        Telegram["Telegram API"]:::iot
        Alarm["Alarm System"]:::iot
    end

    %% Testing Framework
    subgraph "Testing Framework"
        UnitTests["Unit Tests"]:::test
        IntegrationTests["Integration Tests"]:::test
    end

    %% Documentation
    subgraph "Documentation"
        Reports["Reports"]:::doc
        Presentations["Presentations"]:::doc
    end

    %% Connections from Data Folder to Data Processing & Training Module
    DataRaw -->|"feeds"| EDA
    DataAnnotated -->|"feeds"| DataProcessing
    DataAugmented -->|"feeds"| Training

    %% Internal flow within Data Processing & Training Module
    EDA -->|"processes"| DataProcessing
    DataProcessing -->|"trains"| Training

    %% From Training to Model Repository
    Training -->|"saves"| Model

    %% From Model Repository to Deployment Service
    Model -->|"loads"| FlaskApp
    Model -->|"loads"| Predict
    FlaskApp -->|"uses"| Predict

    %% From Deployment Service to IoT Module
    Predict -->|"alerts"| Telegram
    Predict -->|"alerts"| Alarm

    %% Testing arrows
    UnitTests -->|"tests"| EDA
    IntegrationTests -->|"tests"| FlaskApp

    %% Documentation arrows
    Reports -->|"documents"| DataRaw
    Reports -->|"documents"| EDA
    Reports -->|"documents"| Model
    Presentations -->|"presents"| FlaskApp
    Presentations -->|"presents"| Telegram

    %% Click Events
    click EDA "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/src/EDA.ipynb"
    click DataProcessing "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/src/data_processing.ipynb"
    click Training "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/src/train_model.ipynb"
    click Telegram "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/src/iot/telegram_api.py"
    click Alarm "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/src/iot/alarm_system.py"
    click Model "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/models/best.pt"
    click FlaskApp "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/deployment/app.py"
    click Predict "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/deployment/predict.py"
    click UnitTests "https://github.com/galaxyannihilator/firedetectionsystem/tree/main/tests/unit"
    click Reports "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/README.md"
    click Presentations "https://github.com/galaxyannihilator/firedetectionsystem/blob/main/diagram.mmd"

    %% Styles
    classDef data fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef processing fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef iot fill:#a9dfbf,stroke:#1e8449,stroke-width:2px;
    classDef database fill:#f5cba7,stroke:#b9770e,stroke-width:2px;
    classDef deployment fill:#d2b4de,stroke:#6c3483,stroke-width:2px;
    classDef test fill:#f9c2c0,stroke:#c0392b,stroke-width:2px;
    classDef doc fill:#d5f5e3,stroke:#28b463,stroke-width:2px;
```
