# dhyan2815/smokesignal-ai architecture

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

- Interactive diagram: https://gitdiagram.com/dhyan2815/smokesignal-ai
- Repository: https://github.com/dhyan2815/smokesignal-ai

## Overview

##### Main Components
a. Frontend Web UI (Streamlit)
- app.py
- assets/ (static images, UI assets)
b. Inference Engine & Business Logic
- utils/preprocess.py (image loading, resizing, normalization)
- utils/alerts.py (SMTP email alert logic)
- config.py (environment-based email credentials, threshold settings)
c. Model Artifact
- model/wildfire_detector_model.keras (pre-trained CNN)
d. External Services
- Gmail SMTP server (for sending email alerts)
e. (Optional) Training Pipeline
- notebooks/SmokeSignal-AI.ipynb
- data source: Kaggle Wildfire Dataset
- TensorFlow/Keras training components

##### Relationships and Data Flows
- User uploads satellite image via Streamlit UI → app.py
- app.py invokes preprocess module → outputs normalized tensor
- Inference Engine loads wildfire_detector_model.keras → outputs confidence score
- Decision Logic in app.py: if confidence ≥ threshold → call alerts module
- alerts.py reads credentials from config.py → connects to Gmail SMTP → sends formatted email
- UI displays result (confidence score, image, status) back to user

##### Architectural Patterns & Principles
- Separation of Concerns: UI layer vs. preprocessing vs. inference vs. alerting
- Config-as-Code: config.py reads environment variables—no secrets in code
- Modular Design: each utility (preprocess, alerts) lives in its own module
- Single-Process, Event-Driven Streamlit App: request → process → response

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Real-time Inference Path
    U["User & Browser"]:::external -->|"upload image"| UI["Streamlit App<br/>(app.py)"]:::frontend
    UI -->|"raw image"| PP["Preprocessing Module<br/>(utils/preprocess.py)"]:::core
    PP -->|"tensor"| IE["Inference Engine<br/>(Keras/TensorFlow)"]:::core
    IE -->|"loads model"| MA["Model Artifact<br/>(wildfire_detector_model.keras)"]:::storage
    IE -->|"confidence score"| UI
    IE -->|"score ≥ threshold"| AM["Alert Module<br/>(utils/alerts.py)"]:::core
    AM -.->|"reads env vars"| CFG["Configuration Module<br/>(config.py)"]:::doc
    AM -->|"email request"| SMTP["Gmail SMTP Server"]:::external

    %% Optional Offline Training Pipeline
    subgraph "Offline Training (Optional)"
        direction TB
        NB["Training Notebook<br/>(SmokeSignal-AI.ipynb)"]:::offline
        NB -->|"uses dataset"| DS["Kaggle Wildfire Dataset"]:::external
        NB -->|"train & export"| MA
    end

    %% Dependency Manifest
    RQ["requirements.txt"]:::doc

    %% Click Events
    click UI "https://github.com/dhyan2815/smokesignal-ai/blob/main/app.py"
    click Assets "https://github.com/dhyan2815/smokesignal-ai/tree/main/assets/"
    click PP "https://github.com/dhyan2815/smokesignal-ai/blob/main/utils/preprocess.py"
    click AM "https://github.com/dhyan2815/smokesignal-ai/blob/main/utils/alerts.py"
    click CFG "https://github.com/dhyan2815/smokesignal-ai/blob/main/config.py"
    click MA "https://github.com/dhyan2815/smokesignal-ai/blob/main/model/wildfire_detector_model.keras"
    click NB "https://github.com/dhyan2815/smokesignal-ai/blob/main/notebooks/SmokeSignal-AI.ipynb"
    click RQ "https://github.com/dhyan2815/smokesignal-ai/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0091EA,stroke-width:2px
    classDef core fill:#E0F7FA,stroke:#006064,stroke-width:2px
    classDef storage fill:#FFF8E1,stroke:#FFA000,stroke-width:2px
    classDef external fill:#FFE0B2,stroke:#E65100,stroke-width:2px
    classDef doc fill:#F3E5F5,stroke:#6A1B9A,stroke-width:2px,stroke-dasharray: 5 5
    classDef offline fill:#F1F8E9,stroke:#33691E,stroke-width:2px,stroke-dasharray: 5 5

    %% Asset Node
    Assets["Static Assets<br/>(assets/)"]:::frontend
    UI --> Assets
```
