# bhagyashreemohalkar/smartwasteai architecture

> Architecture diagram of the GitHub repository bhagyashreemohalkar/smartwasteai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bhagyashreemohalkar/smartwasteai
- Repository: https://github.com/bhagyashreemohalkar/smartwasteai

## Overview

SmartWasteAI is a browser-based waste classifier: users upload an image, receive a category and confidence, then see disposal guidance and session analytics. The frontend checks API health and sends the image to FastAPI; the backend stores the image, invokes inference, logs prediction metadata, and returns the result. The README documents these capabilities, but the model artifact and class-name file are not in the tree, so their paths are unavailable; deployment details are not mapped as runtime components.

Main entry points: [`frontend/script.js`](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js) (Client workflows), [`backend/main.py`](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/backend/main.py) (FastAPI routes), [`frontend/index.html`](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/index.html) (Upload and results UI), [`backend/inference.py`](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/backend/inference.py) (Image preprocessing and prediction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_frontend["Upload and results UI<br/>[index.html]"]
  node_client["Client workflows<br/>[script.js]"]
  node_guidance["Disposal guidance<br/>[script.js]"]
  node_session["History and analytics<br/>[script.js]"]
end

subgraph group_api["Inference API"]
  node_api["FastAPI routes<br/>[main.py]"]
end

subgraph group_ml["Classification"]
  node_inference["Image preprocessing and prediction<br/>[inference.py]"]
  node_model["MobileNetV2 model"]
  node_classes["Class-name mapping"]
end

subgraph group_cloud["Cloud records"]
  node_s3[("Amazon S3")]
  node_dynamo[("Amazon DynamoDB")]
end

node_user(("User"))
node_browserstore[("Browser local storage")]

node_user -->|"uploads image"| node_frontend
node_frontend -->|"drives workflow"| node_client
node_client -->|"reads and writes"| node_browserstore
node_client -->|"checks health"| node_api
node_client -->|"posts image"| node_api
node_api -->|"stores image"| node_s3
node_api -->|"requests prediction"| node_inference
node_api -->|"writes metadata"| node_dynamo
node_api -->|"returns prediction"| node_client
node_inference -->|"runs inference"| node_model
node_inference -->|"reads class names"| node_classes
node_client -->|"selects recommendation"| node_guidance
node_client -->|"updates session stats"| node_session
node_guidance -->|"renders advice"| node_frontend
node_session -->|"renders history"| node_frontend
node_client -->|"renders result"| node_frontend
node_user -->|"views analytics"| node_session

click node_frontend "https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/index.html"
click node_client "https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js"
click node_guidance "https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js"
click node_session "https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js"
click node_api "https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/backend/main.py"
click node_inference "https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/backend/inference.py"

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_client,node_guidance,node_session,node_user toneBlue
class node_api,node_browserstore toneAmber
class node_inference,node_model,node_classes toneMint
class node_s3,node_dynamo toneRose
```

## Components

### Web experience

- [Upload and results UI](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/index.html): `frontend/index.html`
- [Client workflows](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js): `frontend/script.js`
- [Disposal guidance](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js): `frontend/script.js`
- [History and analytics](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/frontend/script.js): `frontend/script.js`

### Inference API

- [FastAPI routes](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/backend/main.py): `backend/main.py`

### Classification

- [Image preprocessing and prediction](https://github.com/bhagyashreemohalkar/smartwasteai/blob/main/backend/inference.py): `backend/inference.py`
- **MobileNetV2 model**
- **Class-name mapping**

### Cloud records

- **Amazon S3**
- **Amazon DynamoDB**

### Other components

- **User**
- **Browser local storage**

## Connections

- User → Upload and results UI: uploads image
- Upload and results UI → Client workflows: drives workflow
- Client workflows → Browser local storage: reads and writes
- Client workflows → FastAPI routes: checks health
- Client workflows → FastAPI routes: posts image
- FastAPI routes → Amazon S3: stores image
- FastAPI routes → Image preprocessing and prediction: requests prediction
- FastAPI routes → Amazon DynamoDB: writes metadata
- FastAPI routes → Client workflows: returns prediction
- Image preprocessing and prediction → MobileNetV2 model: runs inference
- Image preprocessing and prediction → Class-name mapping: reads class names
- Client workflows → Disposal guidance: selects recommendation
- Client workflows → History and analytics: updates session stats
- Disposal guidance → Upload and results UI: renders advice
- History and analytics → Upload and results UI: renders history
- Client workflows → Upload and results UI: renders result
- User → History and analytics: views analytics
