# err0r2811/plant-pal- architecture

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

- Interactive diagram: https://gitdiagram.com/err0r2811/plant-pal-
- Repository: https://github.com/err0r2811/plant-pal-

## Overview

##### Project type and purpose
- Plant-pal is a single‐script, machine-learning-powered web application built in Python using Streamlit for the UI.
- Its purpose is to let users upload plant images and receive immediate classification results.

##### File structure
- Top level:
- README.md – documentation
- labels.txt – plant class labels
- main.py – entry point that hosts the Streamlit app, loads the ML model, handles uploads, and returns predictions
- No separate frontend/back-end directories: the UI and logic live together in main.py.
- No external database; labels.txt is used as a lookup for model outputs.

##### README for additional insights
- Confirms tech stack: Python, Streamlit, machine learning framework (e.g., TensorFlow, PyTorch, or scikit-learn)
- No mention of Django or other back-end frameworks actually in use—assume a pure Streamlit deployment.

a. Main components
- Client (Web Browser) – the user interface surfacing Streamlit pages
- Streamlit App (main.py) – handles HTTP connections, renders pages, accepts file uploads
- ML Inference Module – loads a pre-trained model file from disk, processes images, returns predictions
- Labels File (labels.txt) – provides human-readable class names
b. Relationships and interactions
1. User accesses Streamlit UI via browser
2. Browser sends image upload to Streamlit server
3. Streamlit app forwards image data to the ML Inference Module
4. ML module loads image, runs through the model, outputs a class index
5. Streamlit app looks up the label in labels.txt
6. Streamlit app returns the label/result to the browser
c. Architectural patterns / design principles
- Monolithic single-process application
- Separation of concerns inside main.py: UI logic vs. inference logic vs. label lookup
- Future extensibility: you could factor out ML Inference into a microservice if scaling becomes necessary
d. Technologies and libraries
- Streamlit – HTTP server + interactive UI
- Python – orchestration and glue code
- Machine learning library (TensorFlow / PyTorch / scikit-learn) – model inference
- Labels file (flat file) or cloud storage for model artifacts

- Browser → Streamlit (upload request)
- Streamlit → ML Inference (inference call)
- ML Inference → Streamlit (prediction result)
- Streamlit → labels.txt lookup (class name resolution)
- Streamlit → Browser (display result)
- Another for compute/inference components
- A third for storage/data artifacts

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    Browser["Web Browser"]:::ui

    %% Application Layer
    subgraph "Streamlit Application"
        UI["Streamlit UI & Orchestration"]:::ui
        Inference["ML Inference Module<br/>(TensorFlow/PyTorch)"]:::compute
    end

    %% Data Layer
    Labels["Labels File<br/>(labels.txt)"]:::data
    Docs["Documentation<br/>(README.md)"]:::docs

    %% Data Flows
    Browser -->|"Upload image file"| UI
    UI -->|"Invoke inference(image data)"| Inference
    Inference -->|"Return prediction index"| UI
    UI -->|"Lookup class name"| Labels
    UI -->|"Display result(label)"| Browser

    %% Click Events
    click UI "https://github.com/err0r2811/plant-pal-/blob/main/main.py"
    click Inference "https://github.com/err0r2811/plant-pal-/blob/main/main.py"
    click Labels "https://github.com/err0r2811/plant-pal-/blob/main/labels.txt"
    click Docs "https://github.com/err0r2811/plant-pal-/blob/main/README.md"

    %% Styles
    classDef ui fill:#AEDFF7,stroke:#333,stroke-width:1px
    classDef compute fill:#C8E6C9,stroke:#333,stroke-width:1px
    classDef data fill:#FFF9C4,stroke:#333,stroke-width:1px
    classDef docs fill:#E0E0E0,stroke:#333,stroke-width:1px
```
