# ai-lab-makerere/ibean architecture

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

- Interactive diagram: https://gitdiagram.com/ai-lab-makerere/ibean
- Repository: https://github.com/ai-lab-makerere/ibean

## Overview

##### Project type and purpose
- This is an open dataset repository (no application code).
- Purpose: collect, version, and serve field-taken leaf images of bean plants in three classes for ML model training and mobile inference.

##### Main components
a. Source Control & Metadata
– GitHub repo (“ibean”) holding README, LICENSE and pointers to data.
– Metadata store (could be in-repo CSV/JSON or huggingface dataset metadata).
b. Data Storage
– GCP Storage Buckets: train.zip, validation.zip, test.zip.
– Huggingface Dataset host.
c. Data Ingestion & Preprocessing
– ETL/Preprocessing step (e.g., a Jupyter notebook, Apache Beam, or local script).
d. Model Training Environment
– Compute (e.g., local GPU, cloud VM, or managed service).
– Framework (TensorFlow or PyTorch).
– Experiment tracking / model registry (e.g., MLflow, Weights & Biases).
e. Model Evaluation
– Validation & Test datasets.
– Reporting (confusion matrix, accuracy).
f. Model Deployment / Inference
– Model packaging (e.g., TensorFlow Lite or ONNX for mobile).
– Mobile app (Android/iOS) that loads the packaged model.
g. End User
– Farmer in the field using the mobile app.

##### Relationships and data flows
– “git clone” or metadata pointers trigger download from GCP buckets / Huggingface.
– Raw images ingested, annotated metadata read.
– Preprocessed tensors/images fed into training job.
– Trained model is versioned and stored.
– Selected model exported to mobile-friendly format.
– Packaged model bundled into app or fetched at runtime.
– User snaps a leaf image, inference runs on-device, prediction displayed.

##### Architectural patterns & principles
- Data-centric design: clear separation between raw data, preprocessing, and model artifacts.
- Versioning: track dataset versions (train/val/test splits) and model versions independently.
- Modularity: each stage (ingest, train, deploy) is a separate component/service.
- Edge inference: deploy a lightweight model on mobile devices for offline use.

##### Capturing essential details
- Don’t just show “Data” – explicitly name the buckets and splits.
- Hosting of the dataset on Huggingface as a parallel access point.
- That the mobile app operates offline, so the packaged model is embedded or cached.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Source Control & Metadata"
        GitHubRepo["GitHub Repo\nREADME, LICENSE"]:::metadata
    end

    subgraph "Data Storage"
        GCP[("GCP Storage\ntrain.zip, validation.zip, test.zip")]:::storage
        HF["Huggingface Dataset"]:::storage
    end

    subgraph "Compute & Training"
        Preproc["Preprocessing\n(Jupyter Notebook / Apache Beam)"]:::compute
        Training["Model Training\n(TensorFlow / PyTorch)"]:::compute
        Registry["Model Registry\n(MLflow / Weights & Biases)"]:::compute
    end

    subgraph "Model Deployment"
        Packaging["Model Packaging\n(.tflite / .onnx)"]:::deploy
        MobileApp["Mobile App\n(Android / iOS)"]:::deploy
    end

    EndUser["End User\nFarmer in the field"]:::user

    GitHubRepo -->|"git clone / metadata pointers\nHTTPS"| GCP
    GitHubRepo -->|"git clone / metadata pointers\nHTTPS"| HF

    GCP -->|"download train.zip etc\nHTTPS"| Preproc
    HF -->|"huggingface API\nHTTPS"| Preproc

    Preproc -->|"preprocessed data\nS3 API"| Training
    Training -->|"trained model\nMLflow API"| Registry
    Registry -->|"export model\nREST"| Packaging
    Packaging -->|"bundle model\nembedded"| MobileApp
    MobileApp -->|"inference\non-device"| EndUser

    click GitHubRepo "https://github.com/ai-lab-makerere/ibean/blob/master//README.md"
    click GitHubRepo "https://github.com/ai-lab-makerere/ibean/tree/master//LICENSE"

    classDef metadata fill:#cccccc,stroke:#333,stroke-width:1px;
    classDef storage fill:#a2cffe,stroke:#0366d6,stroke-width:1px;
    classDef compute fill:#b5e7a0,stroke:#2d6a4f,stroke-width:1px;
    classDef deploy fill:#ffcc80,stroke:#ff6f00,stroke-width:1px;
    classDef user fill:#e0bbE4,stroke:#6a1b9a,stroke-width:1px;
```
