# georgemuriithi/tomato-disease-detection architecture

> Architecture diagram of the GitHub repository georgemuriithi/tomato-disease-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/georgemuriithi/tomato-disease-detection
- Repository: https://github.com/georgemuriithi/tomato-disease-detection

## Overview

Tomato Disease Detection is an image-classification product with mobile and web clients, two API deployment paths, and a CNN model. Users provide a leaf image and receive a disease label and confidence. The local API preprocesses the uploaded image and calls TensorFlow Serving; the GCF path loads a model from Cloud Storage and predicts directly. The notebook represents model development. Client-to-API links and some deployment wiring are documented in the README; the GCF path is not shown connected to the sampled clients at source level.

Main entry points: [`mobile-app/App.js`](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/mobile-app/App.js) (Mobile App), [`apis/gcf/main.py`](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/apis/gcf/main.py) (Cloud Function), [`apis/local/main.py`](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/apis/local/main.py) (Local API), [`web-page/src/home.js`](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/web-page/src/home.js) (Web Upload)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User Clients"]
  node_mobile["Mobile App<br/>[App.js]"]
  node_permissions["Device Permissions<br/>[Permissions.js]"]
  node_web["Web Upload<br/>[home.js]"]
end

subgraph group_api["Prediction APIs"]
  node_localapi["Local API<br/>[main.py]"]
  node_gcf["Cloud Function<br/>[main.py]"]
end

subgraph group_inference["Model Inference"]
  node_serving["TensorFlow Serving"]
  node_cloudstorage[("Cloud Storage")]
end

subgraph group_model["Model Assets"]
  node_model["CNN Model"]
  node_modelconfigs["Serving Configs"]
  node_artifacts["Model Artifacts"]
end

node_farmer(("Farmer"))

node_farmer -->|"provides image"| node_mobile
node_farmer -->|"uploads image"| node_web
node_mobile -->|"checks access"| node_permissions
node_mobile -.->|"posts image"| node_localapi
node_web -.->|"posts image"| node_localapi
node_web -.->|"posts image"| node_gcf
node_mobile -.->|"posts image"| node_gcf
node_localapi -->|"sends image batch"| node_serving
node_serving -->|"returns predictions"| node_localapi
node_gcf -->|"downloads model"| node_cloudstorage
node_gcf -->|"loads model"| node_model
node_gcf -->|"classifies image"| node_gcf
node_localapi -->|"maps class confidence"| node_localapi
node_mobile -->|"shows result"| node_mobile
node_web -->|"shows result"| node_web
node_modelconfigs -.->|"configures versions"| node_serving
node_artifacts -.->|"uploaded model"| node_cloudstorage

click node_mobile "https://github.com/georgemuriithi/tomato-disease-detection/blob/main/mobile-app/App.js"
click node_permissions "https://github.com/georgemuriithi/tomato-disease-detection/blob/main/mobile-app/Permissions.js"
click node_web "https://github.com/georgemuriithi/tomato-disease-detection/blob/main/web-page/src/home.js"
click node_localapi "https://github.com/georgemuriithi/tomato-disease-detection/blob/main/apis/local/main.py"
click node_gcf "https://github.com/georgemuriithi/tomato-disease-detection/blob/main/apis/gcf/main.py"
click node_model "https://github.com/georgemuriithi/tomato-disease-detection/blob/main/Tomato-Disease-Detection-Model.ipynb"
click node_modelconfigs "https://github.com/georgemuriithi/tomato-disease-detection/tree/main/config-files"
click node_artifacts "https://github.com/georgemuriithi/tomato-disease-detection/tree/main/models"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_mobile,node_permissions,node_web toneBlue
class node_localapi,node_gcf toneAmber
class node_serving,node_cloudstorage toneMint
class node_model,node_modelconfigs,node_artifacts toneRose
class node_farmer toneIndigo
```

## Components

### User Clients

- [Mobile App](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/mobile-app/App.js): `mobile-app/App.js`
- [Device Permissions](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/mobile-app/Permissions.js): `mobile-app/Permissions.js`
- [Web Upload](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/web-page/src/home.js): `web-page/src/home.js`

### Prediction APIs

- [Local API](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/apis/local/main.py): `apis/local/main.py`
- [Cloud Function](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/apis/gcf/main.py): `apis/gcf/main.py`

### Model Inference

- **TensorFlow Serving**
- **Cloud Storage**

### Model Assets

- [CNN Model](https://github.com/georgemuriithi/tomato-disease-detection/blob/main/Tomato-Disease-Detection-Model.ipynb): `Tomato-Disease-Detection-Model.ipynb`
- [Serving Configs](https://github.com/georgemuriithi/tomato-disease-detection/tree/main/config-files): `config-files`
- [Model Artifacts](https://github.com/georgemuriithi/tomato-disease-detection/tree/main/models): `models`

### Other components

- **Farmer**

## Connections

- Farmer → Mobile App: provides image (evidence: `README.md`)
- Farmer → Web Upload: uploads image (evidence: `README.md`)
- Mobile App → Device Permissions: checks access (evidence: `mobile-app/App.js`)
- Mobile App → Local API: posts image (evidence: `README.md`)
- Web Upload → Local API: posts image (evidence: `README.md`)
- Web Upload → Cloud Function: posts image (evidence: `README.md`)
- Mobile App → Cloud Function: posts image (evidence: `README.md`)
- Local API → TensorFlow Serving: sends image batch (evidence: `apis/local/main.py`)
- TensorFlow Serving → Local API: returns predictions (evidence: `apis/local/main.py`)
- Cloud Function → Cloud Storage: downloads model (evidence: `apis/gcf/main.py`)
- Cloud Function → CNN Model: loads model (evidence: `apis/gcf/main.py`)
- Cloud Function → Cloud Function: classifies image (evidence: `apis/gcf/main.py`)
- Local API → Local API: maps class confidence (evidence: `apis/local/main.py`)
- Mobile App → Mobile App: shows result (evidence: `mobile-app/App.js`)
- Web Upload → Web Upload: shows result (evidence: `web-page/src/home.js`)
- Serving Configs → TensorFlow Serving: configures versions (evidence: `README.md`)
- Model Artifacts → Cloud Storage: uploaded model (evidence: `README.md`)
