# bodhisattva-duduka/smartbin-codestromeco-hackathon architecture

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

- Interactive diagram: https://gitdiagram.com/bodhisattva-duduka/smartbin-codestromeco-hackathon
- Repository: https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon

## Overview

SmartBin lets a user upload or capture a waste image, get an AI identification and disposal/recycling guidance, and review recent scans. The browser prepares the image and calls the Express API; the classify route calls Gemini and records results for server history. The UI also supports local saved history and, per the README, points and reset controls. A separate question-answer API is documented by its route. Some README-described capabilities are not visible in the sampled frontend excerpt, so their wiring is not inferred.

Main entry points: [`public/script.js`](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/script.js) (Upload, scan, rewards), [`server.js`](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/server.js) (Express server), [`routes/classify.js`](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/classify.js) (Image classification), [`routes/ask.js`](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/ask.js) (Question API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_browser["SmartBin UI<br/>[index.html]"]
  node_frontend["Upload, scan, rewards<br/>[script.js]"]
end

subgraph group_api["Application API"]
  node_server["Express server<br/>[server.js]"]
  node_classify["Image classification<br/>[classify.js]"]
  node_ask["Question API<br/>[ask.js]"]
end

subgraph group_ai["AI services"]
  node_gemini{{"Gemini vision"}}
  node_gemini_text{{"Gemini text"}}
end

subgraph group_history["Scan history"]
  node_server_history[("Server scan history<br/>[classify.js]")]
  node_local_history[("Browser scan history<br/>[script.js]")]
end

node_user(("User"))
node_camera["Device camera"]
node_storage[("Browser localStorage")]

node_user -->|"uses"| node_browser
node_browser -->|"runs"| node_frontend
node_frontend -->|"captures from"| node_camera
node_frontend -->|"requests"| node_server
node_server -->|"dispatches"| node_classify
node_classify -->|"sends image prompt"| node_gemini
node_gemini -->|"returns guidance"| node_classify
node_classify -->|"reads and writes"| node_server_history
node_server -->|"dispatches"| node_ask
node_ask -->|"sends question"| node_gemini_text
node_gemini_text -->|"returns answer"| node_ask
node_frontend -->|"renders and saves"| node_local_history
node_local_history -->|"reads and writes"| node_storage
node_frontend -->|"fetches history"| node_server

click node_browser "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/index.html"
click node_frontend "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/script.js"
click node_server "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/server.js"
click node_classify "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/classify.js"
click node_ask "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/ask.js"
click node_server_history "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/classify.js"
click node_local_history "https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/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_browser,node_frontend,node_user toneBlue
class node_server,node_classify,node_ask,node_storage toneAmber
class node_gemini,node_gemini_text toneMint
class node_server_history,node_local_history toneRose
class node_camera toneIndigo
```

## Components

### Browser experience

- [SmartBin UI](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/index.html): `public/index.html`
- [Upload, scan, rewards](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/script.js): `public/script.js`

### Application API

- [Express server](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/server.js): `server.js`
- [Image classification](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/classify.js): `routes/classify.js`
- [Question API](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/ask.js): `routes/ask.js`

### AI services

- **Gemini vision**
- **Gemini text**

### Scan history

- [Server scan history](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/routes/classify.js): `routes/classify.js`
- [Browser scan history](https://github.com/bodhisattva-duduka/smartbin-codestromeco-hackathon/blob/main/public/script.js): `public/script.js`

### Other components

- **User**
- **Device camera**
- **Browser localStorage**

## Connections

- User → SmartBin UI: uses
- SmartBin UI → Upload, scan, rewards: runs
- Upload, scan, rewards → Device camera: captures from
- Upload, scan, rewards → Express server: requests
- Express server → Image classification: dispatches
- Image classification → Gemini vision: sends image prompt
- Gemini vision → Image classification: returns guidance
- Image classification → Server scan history: reads and writes
- Express server → Question API: dispatches
- Question API → Gemini text: sends question
- Gemini text → Question API: returns answer
- Upload, scan, rewards → Browser scan history: renders and saves
- Browser scan history → Browser localStorage: reads and writes
- Upload, scan, rewards → Express server: fetches history
