# sariitani/scotlia architecture

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

- Interactive diagram: https://gitdiagram.com/sariitani/scotlia
- Repository: https://github.com/sariitani/scotlia

## Overview

##### Project type and purpose
- This is an IoT-driven full-stack robotics/monitoring system (“Scotlia”) combining Arduino-based devices (drones and a site sensor) with a Python web server running on a Raspberry Pi.
- The Arduinos collect flight or environmental data; the Pi hosts a Flask application that ingests that data, stores it in flat files, and serves it via a simple web front-end (HTML + JavaScript heatmap).

##### File structure
- Top-level “Ghoush/” directory: three Arduino sketches
- drone/drone.ino and drone2/drone2.ino — quadcopter flight control code
- site/site.ino — stationary environmental sensor code
- “sari/” directory: Python application
- app.py — entry point that launches the Flask server
- python_server/
– static/ — sensor data files (firedat*, smokedat*, treedat*)
– templates/index.html — client UI
– utils.py — data-loading and processing utilities
– views.py — Flask route handlers
- README shows how to scp the Python app to a Pi and start it.

##### Main components & interactions
a. Arduino devices (Ghoush/drone, drone2, site)
– Collect telemetry or environmental data
– Communicate to Raspberry Pi (via USB serial, Wi-Fi or other link)
b. Raspberry Pi host
– Runs app.py → Flask server
– Serial / network listener that writes incoming sensor data into text files under python_server/static
– Flask “views” load those files using utils.py and render JSON or HTML
c. Web Client (browser)
– Loads index.html
– Issues HTTP GETs to server endpoints (e.g., “/data/firedat0”)
– Renders heatmaps or charts via JavaScript

##### Architectural patterns & design principles
- Microcontroller → Edge compute → Web UI pipeline
- MVC style within Flask:
- Model: flat-file “database” under static/
- View: index.html + JS
- Controller: views.py routes
- Separation of concerns:
- Device code (C++ in .ino files) is isolated from server logic
- Server logic is isolated from presentation (templates + static assets)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Devices
    Drone1["Drone1 Device<br>(drone.ino)"]:::hardware
    Drone2["Drone2 Device<br>(drone2.ino)"]:::hardware
    SiteSensor["SiteSensor Device<br>(site.ino)"]:::hardware

    %% Raspberry Pi
    subgraph "Raspberry Pi"
        direction TB
        AppPy["Flask App<br>(app.py)"]:::backend
        Views["Route Handlers<br>(views.py)"]:::backend
        Utils["Data Utilities<br>(utils.py)"]:::backend
        StaticDir["Flat-File Data Store<br>(static/*.txt)"]:::storage
    end

    %% Browser UI
    WebUI["Browser UI<br>(index.html + JS heatmap)"]:::client

    %% Connections
    Drone1 -->|"raw sensor telemetry"| AppPy
    Drone2 -->|"raw sensor telemetry"| AppPy
    SiteSensor -->|"raw sensor telemetry"| AppPy

    AppPy -->|"routes to"| Views
    Views -->|"uses"| Utils
    Utils -->|"reads/writes"| StaticDir

    WebUI -->|"HTTP GET/POST"| Views
    Views -->|"JSON / rendered HTML"| WebUI

    %% Click Events
    click Drone1 "https://github.com/sariitani/scotlia/blob/main/Ghoush/drone/drone.ino"
    click Drone2 "https://github.com/sariitani/scotlia/blob/main/Ghoush/drone2/drone2.ino"
    click SiteSensor "https://github.com/sariitani/scotlia/blob/main/Ghoush/site/site.ino"
    click AppPy "https://github.com/sariitani/scotlia/blob/main/sari/app.py"
    click Views "https://github.com/sariitani/scotlia/blob/main/sari/python_server/views.py"
    click Utils "https://github.com/sariitani/scotlia/blob/main/sari/python_server/utils.py"
    click WebUI "https://github.com/sariitani/scotlia/blob/main/sari/python_server/templates/index.html"
    click StaticDir "https://github.com/sariitani/scotlia/tree/main/sari/python_server/static"

    %% Styles
    classDef hardware fill:#a3f7b5,stroke:#2d572c,stroke-width:2px;
    classDef backend fill:#87cefa,stroke:#1f4f8b,stroke-width:2px;
    classDef client fill:#ffa500,stroke:#8b4500,stroke-width:2px;
    classDef storage fill:#d3d3d3,stroke:#696969,stroke-width:2px;
```
