# mksathish64-sk/fruit-classifier-cnn architecture

> Architecture diagram of the GitHub repository mksathish64-sk/fruit-classifier-cnn, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mksathish64-sk/fruit-classifier-cnn
- Repository: https://github.com/mksathish64-sk/fruit-classifier-cnn

## Overview

Fruit Vision classifies uploaded fruit images and presents the predicted class and class probabilities in a browser. Its main workflow is browser upload → FastAPI image preprocessing and CNN inference → probability response → browser results. A separate educational frontend simulator illustrates CNN stages; its visual calculations are not the trained model’s internal activations. The repository also includes a training script that saves the model artifact and a command-line prediction path. Runtime relationships are based on the excerpts and README; the dataset-loading module described by the training script is absent from the supplied tree.

Main entry points: [`frontend/script.js`](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js) (Stage simulation), [`server.py`](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py) (Predict endpoint), [`frontend/index.html`](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/index.html) (Upload and results UI), [`fruit_classifierV3.keras`](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/fruit_classifierV3.keras) (Trained model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["Upload and results UI<br/>[index.html]"]
  node_browser_flow["Upload interaction<br/>[script.js]"]
end

subgraph group_api["Prediction API"]
  node_api_endpoint["Predict endpoint<br/>[server.py]"]
  node_preprocess["Image preprocessing<br/>[server.py]"]
  node_inference["Class probabilities<br/>[server.py]"]
end

subgraph group_model["CNN model"]
  node_model_file[("Trained model")]
  node_training["CNN training<br/>[cnn_model.py]"]
  node_cli_prediction["CLI prediction<br/>[predict.py]"]
end

subgraph group_education["CNN visualization"]
  node_simulator["Stage simulation<br/>[script.js]"]
  node_convolution["Convolution demo<br/>[script.js]"]
  node_relu["ReLU demo<br/>[script.js]"]
  node_pooling["Pooling demo<br/>[script.js]"]
  node_flatten_dense["Flatten and dense<br/>[script.js]"]
  node_softmax_demo["Softmax display<br/>[script.js]"]
end

node_user(("Fruit user"))

node_user -->|"uploads image"| node_frontend
node_frontend -->|"handles interaction"| node_browser_flow
node_browser_flow -->|"posts image"| node_api_endpoint
node_api_endpoint -->|"processes image"| node_preprocess
node_api_endpoint -->|"runs prediction"| node_inference
node_inference -->|"loads model"| node_model_file
node_api_endpoint -->|"returns probabilities"| node_browser_flow
node_browser_flow -->|"displays result"| node_frontend
node_training -->|"saves model"| node_model_file
node_cli_prediction -->|"loads model"| node_model_file
node_user -->|"starts demo"| node_simulator
node_simulator -->|"animates stage"| node_convolution
node_simulator -->|"animates stage"| node_relu
node_simulator -->|"animates stage"| node_pooling
node_simulator -->|"animates stages"| node_flatten_dense
node_simulator -->|"shows probabilities"| node_softmax_demo
node_softmax_demo -->|"uses prediction"| node_browser_flow

click node_frontend "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/index.html"
click node_browser_flow "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"
click node_api_endpoint "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py"
click node_preprocess "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py"
click node_inference "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py"
click node_model_file "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/fruit_classifierV3.keras"
click node_training "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/scripts/model/cnn_model.py"
click node_cli_prediction "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/scripts/prediction/predict.py"
click node_simulator "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"
click node_convolution "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"
click node_relu "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"
click node_pooling "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"
click node_flatten_dense "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"
click node_softmax_demo "https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js"

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_frontend,node_browser_flow,node_user toneBlue
class node_api_endpoint,node_preprocess,node_inference toneAmber
class node_model_file,node_training,node_cli_prediction toneMint
class node_simulator,node_convolution,node_relu,node_pooling,node_flatten_dense,node_softmax_demo toneRose
```

## Components

### Web experience

- [Upload and results UI](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/index.html): `frontend/index.html`
- [Upload interaction](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`

### Prediction API

- [Predict endpoint](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py): `server.py`
- [Image preprocessing](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py): `server.py`
- [Class probabilities](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/server.py): `server.py`

### CNN model

- [Trained model](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/fruit_classifierV3.keras): `fruit_classifierV3.keras`
- [CNN training](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/scripts/model/cnn_model.py): `scripts/model/cnn_model.py`
- [CLI prediction](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/scripts/prediction/predict.py): `scripts/prediction/predict.py`

### CNN visualization

- [Stage simulation](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`
- [Convolution demo](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`
- [ReLU demo](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`
- [Pooling demo](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`
- [Flatten and dense](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`
- [Softmax display](https://github.com/mksathish64-sk/fruit-classifier-cnn/blob/main/frontend/script.js): `frontend/script.js`

### Other components

- **Fruit user**

## Connections

- Fruit user → Upload and results UI: uploads image (evidence: `README.md`)
- Upload and results UI → Upload interaction: handles interaction (evidence: `frontend/script.js`)
- Upload interaction → Predict endpoint: posts image (evidence: `README.md`)
- Predict endpoint → Image preprocessing: processes image (evidence: `server.py`)
- Predict endpoint → Class probabilities: runs prediction (evidence: `server.py`)
- Class probabilities → Trained model: loads model (evidence: `server.py`)
- Predict endpoint → Upload interaction: returns probabilities (evidence: `README.md`)
- Upload interaction → Upload and results UI: displays result (evidence: `README.md`)
- CNN training → Trained model: saves model (evidence: `scripts/model/cnn_model.py`)
- CLI prediction → Trained model: loads model (evidence: `scripts/prediction/predict.py`)
- Fruit user → Stage simulation: starts demo (evidence: `README.md`)
- Stage simulation → Convolution demo: animates stage (evidence: `frontend/script.js`)
- Stage simulation → ReLU demo: animates stage (evidence: `frontend/script.js`)
- Stage simulation → Pooling demo: animates stage (evidence: `frontend/script.js`)
- Stage simulation → Flatten and dense: animates stages (evidence: `README.md`)
- Stage simulation → Softmax display: shows probabilities (evidence: `README.md`)
- Softmax display → Upload interaction: uses prediction (evidence: `frontend/script.js`)
