# teodroro/tr-nder-parkering architecture

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

- Interactive diagram: https://gitdiagram.com/teodroro/tr-nder-parkering
- Repository: https://github.com/teodroro/tr-nder-parkering

## Overview

##### Project type and purpose
- From the README (“Prosjekt IELS2001”) and file names it’s clear this is an IoT-enabled parking‐space monitoring system.
- ESP32-based sensors publish parking data (occupied/free) over MQTT. A Raspberry Pi (or similar) runs a Python server that subscribes to these messages, stores them in a relational database, and serves a web interface for users to log in and view parking availability.

##### File structure
- Top-level code for the microcontroller:
- esp32_sender.ino – Arduino sketch for the ESP32 to read sensors and publish via MQTT.
- “ESP til RSPI” and “ESP_sensordata” directories likely contain helper scripts or data payload definitions.
- Messaging backbone:
- Mqtt – Presumably MQTT broker configuration or client utilities on the Pi.
- Backend/server:
- server.py – Main Python application, probably a Flask or FastAPI app that:
- Subscribes to the MQTT broker
- Processes and persists messages
- Exposes HTTP endpoints for the web UI
- schema.sql – Database schema (tables for users, sessions, sensor readings, parking spots).
- Frontend/web UI:
- html – Static assets, templates, CSS/JS.
- login – Pages or modules for user authentication.
- startside – The home/dashboard page.
- Parkeringsplasser oversikt – Parking overview pages or modules.
- Data‐oversikt – Possibly graphs or tables for historical data.

##### README for additional insights
- The README only conveys the course project name; architectural details must be inferred from code and file names.

##### Elements
- Green for IoT/devices,
- Blue for backend services,
- Orange for data stores,
- Yellow for user interfaces.

##### Final advice
- Every directory/function as a component or sub-component.
- Don’t over-complicate – stick to the five to seven major blocks and their interactions.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% IoT Layer
    subgraph "IoT Layer"
        ESP["ESP32 Sensor Node"]:::iot
        ESPHelper1["ESP Helper Scripts"]:::iot
        ESPHelper2["Sensor Data Definitions"]:::iot
    end

    %% Network
    WIFI["Wi-Fi Network"]:::iot

    %% Messaging Layer
    MQTT["MQTT Broker"]:::backend

    %% Application Layer
    Server["Python Server (server.py)"]:::backend

    %% Data Layer
    DB["SQL Database"]:::datastore

    %% Presentation Layer
    Browser["User's Web Browser"]:::ui
    subgraph "Web Frontend" 
        HTML["Static Assets (html/)"]:::ui
        Login["Login Module"]:::ui
        Startside["Dashboard (startside/)"]:::ui
        ParkOverview["Parking Overview (Parkeringsplasser oversikt/)"]:::ui
        DataOverview["Historical Data (Data-oversikt/)"]:::ui
    end

    %% Data Flows
    ESP -->|"sensor data via MQTT"| WIFI
    ESPHelper1 --> WIFI
    ESPHelper2 --> WIFI
    WIFI -->|"MQTT publish"| MQTT
    MQTT -->|subscribe| Server
    Server -->|publish/subscribe| MQTT
    Server -->|INSERT/SELECT| DB
    Browser -->|HTTP Request| Server
    Server -->|HTTP Response| Browser
    Server -->|serves| HTML
    HTML --> Login
    HTML --> Startside
    HTML --> ParkOverview
    HTML --> DataOverview

    %% Click Events
    click ESP "https://github.com/teodroro/tr-nder-parkering/blob/main/esp32_sender.ino"
    click ESPHelper1 "https://github.com/teodroro/tr-nder-parkering/tree/main/ESP til RSPI/"
    click ESPHelper2 "https://github.com/teodroro/tr-nder-parkering/tree/main/ESP_sensordata/"
    click MQTT "https://github.com/teodroro/tr-nder-parkering/tree/main/Mqtt/"
    click Server "https://github.com/teodroro/tr-nder-parkering/blob/main/server.py"
    click DB "https://github.com/teodroro/tr-nder-parkering/blob/main/schema.sql"
    click HTML "https://github.com/teodroro/tr-nder-parkering/tree/main/html/"
    click Login "https://github.com/teodroro/tr-nder-parkering/tree/main/login/"
    click Startside "https://github.com/teodroro/tr-nder-parkering/tree/main/startside/"
    click ParkOverview "https://github.com/teodroro/tr-nder-parkering/tree/main/Parkeringsplasser oversikt/"
    click DataOverview "https://github.com/teodroro/tr-nder-parkering/tree/main/Data-oversikt/"

    %% Styles
    classDef iot fill:#b2f5ea,stroke:#2c7a7b,color:#2c7a7b
    classDef backend fill:#bee3f8,stroke:#2b6cb0,color:#2b6cb0
    classDef datastore fill:#fed7d7,stroke:#c53030,color:#c53030
    classDef ui fill:#fefcbf,stroke:#d69e2e,color:#d69e2e
```
