# mchiaramonte/weather architecture

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

- Interactive diagram: https://gitdiagram.com/mchiaramonte/weather
- Repository: https://github.com/mchiaramonte/weather

## Overview

##### Project type and purpose
- This is a small, embedded full-stack application running on a Raspberry Pi Zero W that fetches local weather data and renders it on a Pimoroni eInk display.
- The main use case is to pull the latest weather readings from your local weather station API and show “nice beach day” status on the eInk panel.
- The Pi is configured to auto-pull the latest code from its Git repository on each boot.

##### File structure
- Top-level files only:
- README.md – describes purpose, hardware, and update process
- weather.py – the single Python script that implements all logic
- No separate frontend/backend folders; it’s a self-contained Python application that runs on the Pi.

##### Extract key details from README
- Hardware components: Raspberry Pi Zero W, Pimoroni eInk (PIM408)
- Data source: local weather station API endpoint
- Auto-update: a startup hook (e.g., systemd service or cron @reboot) that does a git pull and then runs weather.py

##### Main components
a. Hardware layer
- Raspberry Pi Zero W
- Pimoroni eInk display
- Power supply
b. Software layer on Pi
- Startup manager (systemd/cron)
- Git pull updater
- weather.py script
– Weather-fetch module (HTTP client)
– Data parsing / business logic
– Display driver (Pimoroni eInk Python library)
c. External services
- Local weather station API (HTTP endpoint)
- Git repository hosting (e.g., GitHub)

##### Relationships & data flow
1. On boot: Startup manager triggers “git pull” from the remote repo → updates working directory
2. Startup manager or scheduler launches weather.py
3. weather.py HTTP GETs data from the local weather station API → receives JSON/XML
4. weather.py parses the payload → determines “nice day” or “not nice day”
5. weather.py calls Pimoroni eInk driver → renders updated image on the eInk display

##### Architectural patterns/design principles
- Single-responsibility: weather.py is logically split into three modules – updater, data-fetcher, display-renderer
- Decoupling hardware from business logic: use an abstraction layer for the display so you could replace the eInk with another output device
- Auto-update loop: simple CI capability via git pull on startup

##### Technologies & frameworks
- Python 3.x
- requests (or built-in urllib) for HTTP calls
- Pimoroni eInk Python library for display control
- systemd or cron for startup automation
- git for code distribution

##### Final pointers
- Pimoroni eInk library as a separate sub-module to show third-party dependency

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware" 
        PI["Raspberry Pi Zero W"]:::hw
        EINK["Pimoroni eInk Display"]:::hw
        POWER["Power Supply"]:::hw
    end

    %% Operating System / Startup
    subgraph "Operating System"
        STARTUP["Startup Manager (systemd/cron)"]:::sw
        DOC["Project Documentation"]:::doc
    end

    %% Application Process
    subgraph "Application (weather.py)"
        FETCH["Weather Fetch Module"]:::sw
        LOGIC["Business Logic Module"]:::sw
        DISPLAY_LIB["Pimoroni eInk Driver"]:::sw
    end

    %% External Services
    subgraph "External Services"
        API["Local Weather Station API"]:::ext
        GIT["GitHub Repository"]:::ext
    end

    %% Connections / Data Flow
    POWER --> PI
    PI --> STARTUP
    STARTUP -->|git pull| GIT
    STARTUP -->|launch weather.py| FETCH
    FETCH -->|HTTP GET /weather.json| API
    API -->|JSON/XML payload| FETCH
    FETCH -->|parsed data| LOGIC
    LOGIC -->|"nice day result"| DISPLAY_LIB
    DISPLAY_LIB -->|render image| EINK

    %% Click Events
    click DOC "https://github.com/mchiaramonte/weather/blob/master/README.md"
    click STARTUP "https://github.com/mchiaramonte/weather/blob/master/README.md"
    click FETCH "https://github.com/mchiaramonte/weather/blob/master/weather.py"
    click LOGIC "https://github.com/mchiaramonte/weather/blob/master/weather.py"
    click DISPLAY_LIB "https://github.com/mchiaramonte/weather/blob/master/weather.py"

    %% Styles
    classDef hw fill:#add8e6,stroke:#000
    classDef sw fill:#90ee90,stroke:#000
    classDef ext fill:#ffa500,stroke:#000
    classDef doc fill:#f0f0f0,stroke:#000
```
