# ecoconvert/ecoconvert-raspi architecture

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

- Interactive diagram: https://gitdiagram.com/ecoconvert/ecoconvert-raspi
- Repository: https://github.com/ecoconvert/ecoconvert-raspi

## Overview

##### Project type and purpose
- This is an edge-device Python application for real-time object detection/vision processing using TensorFlow Lite on a Raspberry Pi (or similar). It orchestrates camera capture, model inference, LED feedback, and logging, with helper scripts for testing and deployment.

##### File structure
- Top-level files and dirs:
- main.py – entry point orchestrating workflow
- logging_config.py – configures file‐based logging
- requirements.txt – Python deps
- test.sh / upd.sh – deployment & update scripts
- Models/ – two pre‐trained TFLite models + label maps + SavedModel dirs
- process/ – “business logic” subpackage
- blink.py – blink‐detection logic
- inserts.py – insertion or record logic
- modules/Camera.py – camera hardware interface
- modules/Led.py – LED hardware interface
- tester/webcam_tflite.py – standalone TFLite webcam tester
- logs/ – output logs

##### README
- Details on branch strategy (deployment vs. playground)
- Virtual‐env naming strictness (“env”)
- .env file for MODEL_PATH and LABEL_PATH
- Emphasis on activating env before install

##### Detail
- Configuration as an injected dependency (.env → main.py)
- Test.sh/upd.sh flows from version control to runtime

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Physical Hardware"
        direction TB
        Camera["Camera Sensor"]:::hardware
        LED["LED Actuator"]:::hardware
    end

    subgraph "Host Device (Raspberry Pi)"
        direction TB
        subgraph "Python venv (env)"
            direction TB
            Env[".env Config"]:::config
            Reqs["requirements.txt"]:::config
            Orchestrator["Orchestrator (main.py)"]:::orchestrator
            Interpreter["TFLite Interpreter"]:::inference
            subgraph "Business Logic"
                direction TB
                Blink["Blink Detection (blink.py)"]:::business
                Inserts["Insertion Logic (inserts.py)"]:::business
            end
            subgraph "Hardware Interfaces"
                direction TB
                CamMod["Camera Module (Camera.py)"]:::interface
                LedMod["LED Module (Led.py)"]:::interface
            end
            LoggerCfg["Logging Config (logging_config.py)"]:::logging
            Logs["Log Output (logs/)"]:::datastore
            subgraph "Models Storage"
                direction TB
                Model1["mobilenet_fpn_640"]:::datastore
                Model2["v2_mobilenetfpn_ssd_640"]:::datastore
            end
        end
    end

    subgraph "Deployment Tools"
        direction TB
        Git["Git Repo"]:::external
        Test["test.sh"]:::script
        Update["upd.sh"]:::script
        QA["Tester (webcam_tflite.py)"]:::script
        Doc["README.MD"]:::doc
    end

    Camera --> CamMod
    CamMod --> Orchestrator
    Env --> Orchestrator
    Reqs --> Orchestrator
    Orchestrator --> Interpreter
    Interpreter --> Blink
    Interpreter --> Inserts
    Blink --> LedMod
    Inserts --> LedMod
    LedMod --> LED

    Orchestrator --> LoggerCfg
    Blink --> LoggerCfg
    Inserts --> LoggerCfg
    CamMod --> LoggerCfg
    LedMod --> LoggerCfg
    LoggerCfg --> Logs

    Git --> Test
    Git --> Update
    Test -->|"setup env & run"| Orchestrator
    Update -->|"pull updates & run"| Orchestrator
    QA -->|"runs inference bypass HW"| Interpreter

    click Orchestrator "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/main.py"
    click LoggerCfg "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/logging_config.py"
    click Logs "https://github.com/ecoconvert/ecoconvert-raspi/tree/main/logs/"
    click Model1 "https://github.com/ecoconvert/ecoconvert-raspi/tree/main/Models/mobilenet_fpn_640/"
    click Model2 "https://github.com/ecoconvert/ecoconvert-raspi/tree/main/Models/v2_mobilenetfpn_ssd_640/"
    click Blink "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/process/blink.py"
    click Inserts "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/process/inserts.py"
    click CamMod "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/process/modules/Camera.py"
    click LedMod "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/process/modules/Led.py"
    click Reqs "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/requirements.txt"
    click Test "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/test.sh"
    click Update "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/upd.sh"
    click QA "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/tester/webcam_tflite.py"
    click Doc "https://github.com/ecoconvert/ecoconvert-raspi/blob/main/README.MD"

    classDef hardware fill:#CCCCCC,stroke:#333,stroke-width:1px
    classDef config fill:#DFF0D8,stroke:#333,stroke-width:1px
    classDef orchestrator fill:#D9EDF7,stroke:#31708F,stroke-width:1px
    classDef inference fill:#FCF8E3,stroke:#8A6D3B,stroke-width:1px
    classDef business fill:#F2D7D5,stroke:#A93226,stroke-width:1px
    classDef interface fill:#D6EAF8,stroke:#1A5276,stroke-width:1px
    classDef logging fill:#FCF3CF,stroke:#B9770E,stroke-width:1px
    classDef datastore fill:#F5B7B1,stroke:#943126,stroke-width:1px
    classDef script fill:#D5D8DC,stroke:#566573,stroke-width:1px
    classDef external fill:#FFFFFF,stroke:#333,stroke-width:1px
    classDef doc fill:#E8F8F5,stroke:#117864,stroke-width:1px
```
