# homanmirgolbabaee/evogem architecture

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

- Interactive diagram: https://gitdiagram.com/homanmirgolbabaee/evogem
- Repository: https://github.com/homanmirgolbabaee/evogem

## Overview

##### Project type and purpose
- This is an IoT-enabled, full-stack Python application with a web-based UI (Streamlit) that integrates Google’s Gemini Pro Vision API for image/video analysis and pushes results to a NodeMCU ESP8266 microcontroller driving an OLED display.

##### File structure
- Top-level files:
- main.py – Streamlit application entrypoint and orchestration layer
- cam.py – Python module encapsulating image/video capture and API calls to Gemini Pro Vision
- requirements.txt – Python dependencies (e.g., streamlit, google-api-client)
- sketch_feb24a.ino & sketch_jan11b.ino – Arduino sketches for the NodeMCU/ESP8266 to receive data and render on an OLED
- README.md & LICENSE – documentation and license

##### README for additional insights
- Confirms:
- Streamlit UI guides user interaction
- Python code calls Gemini Pro Vision via secure secrets
- NodeMCU acts as an “edge” display device

##### Main architectural components
a. Frontend (User Interface)
– Streamlit running in a browser or local host
– Accepts user input (images/videos) and displays results returned by backend
b. Backend (Application Logic)
– main.py orchestrates workflow:
- Receives uploads/commands from Streamlit
- Delegates to cam.py for API communication
– cam.py handles:
- Packing images/videos
- Authenticating and calling Gemini Pro Vision
- Returning analysis results
c. External Service
– Google Gemini Pro Vision API (multi-modal model endpoint)
d. Edge Device (IoT)
– NodeMCU ESP8266 running Arduino sketch
– Connects via Wi-Fi (e.g., HTTP, WebSockets, or MQTT) to receive JSON or text commands
– Drives the OLED display to show results
e. Configuration & Secrets
– Streamlit’s secrets management (e.g., .streamlit/secrets.toml) to store API keys

##### Relationships & data flow
1) User uploads image/video via Streamlit UI
2) main.py calls cam.py → cam.py formats and sends request to Gemini Pro Vision → receives analysis
3) main.py updates Streamlit UI with results
4) main.py also sends the same result over network (HTTP request or MQTT publish) to NodeMCU
5) NodeMCU Arduino sketch parses incoming data and updates OLED display

##### Architectural patterns & design principles
- Layered architecture: UI layer → Application/service layer → Device layer
- Single responsibility: cam.py isolates API integration; main.py handles orchestration & UI glue
- Edge computing pattern: lightweight microcontroller for real-time display, heavy lifting offloaded to cloud
- Secure secret management for credentials

##### Final checklist
- [ ] Clear labels on all components: Streamlit UI, main.py, cam.py, Gemini Pro Vision, NodeMCU + OLED
- [ ] Optional: include versioned sketches if there are multiple hardware revisions

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend (Streamlit UI)"
        UI["Client Browser / Streamlit UI"]:::frontend
        MP["main.py"]:::backend
    end

    subgraph "Backend (Application Logic)"
        CP["cam.py"]:::backend
        GP["Google Gemini Pro Vision"]:::cloud
    end

    subgraph "Config & Secrets"
        REQ["requirements.txt"]:::config
        SEC[".streamlit/secrets.toml"]:::config
        RD["README.md"]:::config
        LIC["LICENSE"]:::config
    end

    subgraph "Edge Device (NodeMCU ESP8266 + OLED)"
        SKA["sketch_feb24a.ino"]:::edge
        SKB["sketch_jan11b.ino"]:::edge
        DEV["NodeMCU ESP8266"]:::edge
        OLED["OLED Display"]:::edge
    end

    UI -->|"upload image/video"| MP
    MP -->|"delegate to cam.py"| CP
    CP -->|"JSON + API Key auth"| GP
    GP -->|"analysis result"| CP
    CP -->|"return analysis"| MP
    MP -->|"update UI"| UI
    MP -->|"JSON over HTTP/MQTT"| DEV
    DEV -->|"render data"| OLED
    SEC -->|"provides API keys"| CP
    SEC -->|"provides API keys"| MP
    REQ -->|"defines dependencies"| MP
    REQ -->|"defines dependencies"| CP
    RD -->|"project docs"| UI
    LIC -->|"project license"| UI

    click MP "https://github.com/homanmirgolbabaee/evogem/blob/main/main.py"
    click CP "https://github.com/homanmirgolbabaee/evogem/blob/main/cam.py"
    click REQ "https://github.com/homanmirgolbabaee/evogem/blob/main/requirements.txt"
    click SKA "https://github.com/homanmirgolbabaee/evogem/blob/main/sketch_feb24a.ino"
    click SKB "https://github.com/homanmirgolbabaee/evogem/blob/main/sketch_jan11b.ino"
    click RD "https://github.com/homanmirgolbabaee/evogem/blob/main/README.md"
    click LIC "https://github.com/homanmirgolbabaee/evogem/tree/main/LICENSE"

    classDef frontend fill:#e0f7fa,stroke:#00838f,color:#006064
    classDef backend fill:#e8f5e9,stroke:#2e7d32,color:#1b5e20
    classDef cloud fill:#e3f2fd,stroke:#1976d2,color:#0d47a1
    classDef edge fill:#fff3e0,stroke:#ef6c00,color:#e65100
    classDef config fill:#fff8e1,stroke:#f9a825,color:#f57f17
```
