# rohan-shridhar/trashtrace architecture

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

- Interactive diagram: https://gitdiagram.com/rohan-shridhar/trashtrace
- Repository: https://github.com/rohan-shridhar/trashtrace

## Overview

TrashTrace is a QR-scan-based waste-shipment tracking application. Owners enter package, destination, and source GPS details; the backend geocodes the destination and registers a shipment, and the frontend presents its tracking QR code. A courier scans it, shares device location, and the backend records scan history, compares distance to the destination, updates delivery status, and may notify the owner. The dashboard aggregates owned shipments and notifications. Links among sampled modules are grounded in source excerpts or README documentation; unsampled internals are represented only where the README documents their capability.

Main entry points: [`backend/routes/trashRoutes.js`](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/routes/trashRoutes.js) (Shipment routes), [`frontend/src/pages/TrackShipment/TrackShipment.jsx`](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/TrackShipment/TrackShipment.jsx) (Shipment tracking), [`frontend/src/app/routes.jsx`](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/app/routes.jsx) (Page routing), [`frontend/src/pages/CreateShipment/CreateShipment.jsx`](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/CreateShipment/CreateShipment.jsx) (Create shipment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["React app<br/>[App.jsx]"]
  node_routes["Page routing<br/>[routes.jsx]"]
  node_dashboard["Owner dashboard<br/>[Dashboard.jsx]"]
  node_ownerid["Device owner token<br/>[owner.js]"]
  node_http["JSON API client<br/>[api.js]"]
end

subgraph group_shipment["Shipment lifecycle"]
  node_create["Create shipment<br/>[CreateShipment.jsx]"]
  node_qr["QR code card<br/>[QRCodeCard.jsx]"]
  node_tracking["Shipment tracking<br/>[TrackShipment.jsx]"]
  node_scanpage["QR scan page<br/>[ScanQR.jsx]"]
  node_geo["Browser geolocation<br/>[geolocation.js]"]
  node_historyview["Scan timeline"]
  node_progress["Delivery progress"]
end

subgraph group_api["API and services"]
  node_express["Express API<br/>[index.js]"]
  node_trashroutes["Shipment routes<br/>[trashRoutes.js]"]
  node_notifyroutes["Notification routes"]
  node_geocoder["Address geocoder<br/>[geocoder.js]"]
  node_distance["Distance calculator<br/>[distance.js]"]
end

subgraph group_persistence["Persistence"]
  node_dbconn["Mongo connection<br/>[db.js]"]
  node_trashmodel[("Shipment records<br/>[Trash.js]")]
  node_scanmodel[("Scan records<br/>[Scan.js]")]
  node_notificationmodel[("Notifications<br/>[Notification.js]")]
end

node_owner(("Owner"))
node_courier(("Courier"))
node_nominatim["Nominatim"]

node_owner -.->|"uses"| node_app
node_courier -.->|"opens QR link"| node_app
node_app -->|"renders"| node_routes
node_routes -->|"routes to"| node_create
node_routes -->|"routes to"| node_tracking
node_routes -->|"routes to"| node_scanpage
node_routes -->|"routes to"| node_dashboard
node_create -->|"gets GPS"| node_geo
node_create -->|"gets token"| node_ownerid
node_create -->|"submits shipment"| node_http
node_create -->|"renders QR"| node_qr
node_tracking -->|"requests tracking"| node_http
node_tracking -->|"gets scan GPS"| node_geo
node_tracking -->|"renders history"| node_historyview
node_tracking -->|"renders status"| node_progress
node_scanpage -.->|"links to tracking"| node_tracking
node_dashboard -->|"gets token"| node_ownerid
node_dashboard -->|"loads packages"| node_http
node_http -.->|"sends requests"| node_express
node_express -->|"connects"| node_dbconn
node_express -->|"mounts routes"| node_trashroutes
node_express -->|"mounts routes"| node_notifyroutes
node_trashroutes -->|"geocodes address"| node_geocoder
node_trashroutes -.->|"calculates distance"| node_distance
node_trashroutes -->|"reads and writes"| node_trashmodel
node_trashroutes -->|"records scans"| node_scanmodel
node_trashroutes -->|"creates alerts"| node_notificationmodel
node_notifyroutes -->|"reads and updates"| node_notificationmodel
node_geocoder -.->|"geocodes"| node_nominatim

click node_app "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/app/App.jsx"
click node_routes "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/app/routes.jsx"
click node_create "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/CreateShipment/CreateShipment.jsx"
click node_qr "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/components/qr/QRCodeCard.jsx"
click node_tracking "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/TrackShipment/TrackShipment.jsx"
click node_scanpage "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/ScanQR/ScanQR.jsx"
click node_geo "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/utils/geolocation.js"
click node_historyview "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/components/shipment/ShipmentTimeline.jsx"
click node_progress "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/components/shipment/ShipmentProgress.jsx"
click node_dashboard "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/Dashboard/Dashboard.jsx"
click node_ownerid "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/utils/owner.js"
click node_http "https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/utils/api.js"
click node_express "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/api/index.js"
click node_trashroutes "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/routes/trashRoutes.js"
click node_notifyroutes "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/routes/notificationRoutes.js"
click node_geocoder "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/utils/geocoder.js"
click node_distance "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/utils/distance.js"
click node_dbconn "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/config/db.js"
click node_trashmodel "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/models/Trash.js"
click node_scanmodel "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/models/Scan.js"
click node_notificationmodel "https://github.com/rohan-shridhar/trashtrace/blob/main/backend/models/Notification.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_app,node_routes,node_dashboard,node_ownerid,node_http toneBlue
class node_create,node_qr,node_tracking,node_scanpage,node_geo,node_historyview,node_progress toneAmber
class node_express,node_trashroutes,node_notifyroutes,node_geocoder,node_distance toneMint
class node_dbconn,node_trashmodel,node_scanmodel,node_notificationmodel toneRose
class node_owner,node_courier,node_nominatim toneIndigo
```

## Components

### Web experience

- [React app](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/app/App.jsx): `frontend/src/app/App.jsx`
- [Page routing](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/app/routes.jsx): `frontend/src/app/routes.jsx`
- [Owner dashboard](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/Dashboard/Dashboard.jsx): `frontend/src/pages/Dashboard/Dashboard.jsx`
- [Device owner token](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/utils/owner.js): `frontend/src/utils/owner.js`
- [JSON API client](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/utils/api.js): `frontend/src/utils/api.js`

### Shipment lifecycle

- [Create shipment](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/CreateShipment/CreateShipment.jsx): `frontend/src/pages/CreateShipment/CreateShipment.jsx`
- [QR code card](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/components/qr/QRCodeCard.jsx): `frontend/src/components/qr/QRCodeCard.jsx`
- [Shipment tracking](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/TrackShipment/TrackShipment.jsx): `frontend/src/pages/TrackShipment/TrackShipment.jsx`
- [QR scan page](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/pages/ScanQR/ScanQR.jsx): `frontend/src/pages/ScanQR/ScanQR.jsx`
- [Browser geolocation](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/utils/geolocation.js): `frontend/src/utils/geolocation.js`
- [Scan timeline](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/components/shipment/ShipmentTimeline.jsx): `frontend/src/components/shipment/ShipmentTimeline.jsx`
- [Delivery progress](https://github.com/rohan-shridhar/trashtrace/blob/main/frontend/src/components/shipment/ShipmentProgress.jsx): `frontend/src/components/shipment/ShipmentProgress.jsx`

### API and services

- [Express API](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/api/index.js): `backend/api/index.js`
- [Shipment routes](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/routes/trashRoutes.js): `backend/routes/trashRoutes.js`
- [Notification routes](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/routes/notificationRoutes.js): `backend/routes/notificationRoutes.js`
- [Address geocoder](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/utils/geocoder.js): `backend/utils/geocoder.js`
- [Distance calculator](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/utils/distance.js): `backend/utils/distance.js`

### Persistence

- [Mongo connection](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/config/db.js): `backend/config/db.js`
- [Shipment records](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/models/Trash.js): `backend/models/Trash.js`
- [Scan records](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/models/Scan.js): `backend/models/Scan.js`
- [Notifications](https://github.com/rohan-shridhar/trashtrace/blob/main/backend/models/Notification.js): `backend/models/Notification.js`

### Other components

- **Owner**
- **Courier**
- **Nominatim**

## Connections

- Owner → React app: uses (evidence: `README.md`)
- Courier → React app: opens QR link (evidence: `README.md`)
- React app → Page routing: renders (evidence: `frontend/src/app/App.jsx`)
- Page routing → Create shipment: routes to (evidence: `frontend/src/app/routes.jsx`)
- Page routing → Shipment tracking: routes to (evidence: `frontend/src/app/routes.jsx`)
- Page routing → QR scan page: routes to (evidence: `frontend/src/app/routes.jsx`)
- Page routing → Owner dashboard: routes to (evidence: `frontend/src/app/routes.jsx`)
- Create shipment → Browser geolocation: gets GPS (evidence: `frontend/src/pages/CreateShipment/CreateShipment.jsx`)
- Create shipment → Device owner token: gets token (evidence: `frontend/src/pages/CreateShipment/CreateShipment.jsx`)
- Create shipment → JSON API client: submits shipment (evidence: `frontend/src/pages/CreateShipment/CreateShipment.jsx`)
- Create shipment → QR code card: renders QR (evidence: `frontend/src/pages/CreateShipment/CreateShipment.jsx`)
- Shipment tracking → JSON API client: requests tracking (evidence: `frontend/src/pages/TrackShipment/TrackShipment.jsx`)
- Shipment tracking → Browser geolocation: gets scan GPS (evidence: `frontend/src/pages/TrackShipment/TrackShipment.jsx`)
- Shipment tracking → Scan timeline: renders history (evidence: `frontend/src/pages/TrackShipment/TrackShipment.jsx`)
- Shipment tracking → Delivery progress: renders status (evidence: `frontend/src/pages/TrackShipment/TrackShipment.jsx`)
- QR scan page → Shipment tracking: links to tracking (evidence: `README.md`)
- Owner dashboard → Device owner token: gets token (evidence: `frontend/src/pages/Dashboard/Dashboard.jsx`)
- Owner dashboard → JSON API client: loads packages (evidence: `frontend/src/pages/Dashboard/Dashboard.jsx`)
- JSON API client → Express API: sends requests (evidence: `README.md`)
- Express API → Mongo connection: connects (evidence: `backend/api/index.js`)
- Express API → Shipment routes: mounts routes (evidence: `backend/api/index.js`)
- Express API → Notification routes: mounts routes (evidence: `backend/api/index.js`)
- Shipment routes → Address geocoder: geocodes address (evidence: `backend/routes/trashRoutes.js`)
- Shipment routes → Distance calculator: calculates distance (evidence: `README.md`)
- Shipment routes → Shipment records: reads and writes (evidence: `backend/routes/trashRoutes.js`)
- Shipment routes → Scan records: records scans (evidence: `backend/routes/trashRoutes.js`)
- Shipment routes → Notifications: creates alerts (evidence: `backend/routes/trashRoutes.js`)
- Notification routes → Notifications: reads and updates (evidence: `backend/routes/notificationRoutes.js`)
- Address geocoder → Nominatim: geocodes (evidence: `README.md`)
