# nmanoj10/ecoserve architecture

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

- Interactive diagram: https://gitdiagram.com/nmanoj10/ecoserve
- Repository: https://github.com/nmanoj10/ecoserve

## Overview

Ecoserve’s checked-in application is a food-rescue and redistribution platform: donors post food, NGOs and volunteers coordinate rescue and delivery, and admins oversee operations. The frontend serves role-based dashboards and public pages; the Express backend owns API operations, persistence, realtime tracking, and scheduled jobs. The README describes an AI-service boundary, and the tree contains a classifier API, but sampled code does not establish backend-to-AI calls. Several domain routes and services were not sampled, so their internal links are omitted.

Main entry points: [`backend/src/server.ts`](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/server.ts) (HTTP API server), [`backend/src/controllers/volunteerController.ts`](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/volunteerController.ts) (Volunteer operations), [`backend/src/controllers/adminController.ts`](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/adminController.ts) (Admin operations), [`backend/src/config/prisma.ts`](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/config/prisma.ts) (PostgreSQL data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_frontend["Role-based web app<br/>[App.tsx]"]
  node_webapi["API client<br/>[client.ts]"]
  node_deliveryui["Live delivery tracking"]
  node_socketclient["Socket client<br/>[socket.ts]"]
end

subgraph group_api["Backend API"]
  node_backend["HTTP API server<br/>[server.ts]"]
  node_app["Express application<br/>[app.ts]"]
  node_routes["API routes<br/>[index.ts]"]
  node_donations["Donation workflow"]
  node_delivery["Delivery workflow"]
  node_admin["Admin operations<br/>[adminController.ts]"]
  node_volunteers["Volunteer operations"]
  node_database[("PostgreSQL data<br/>[prisma.ts]")]
  node_auth["Authentication<br/>[auth.ts]"]
end

subgraph group_operations["Rescue operations"]
  node_notifications["Notifications"]
  node_rescuejob["Rescue sweep<br/>[rescueJob.ts]"]
  node_expiryjob["Expiry job<br/>[expiryJob.ts]"]
  node_reminderjob["Reminder job<br/>[reminderJob.ts]"]
  node_analyticsjob["Analytics job<br/>[analyticsJob.ts]"]
  node_transit["Transit lookup<br/>[transitService.ts]"]
  node_recommendations["Volunteer recommendations"]
end

subgraph group_intelligence["AI classification"]
  node_aiapi["Food classifier API<br/>[main.py]"]
  node_prediction["Image prediction<br/>[predict.py]"]
end

node_users(("Donors, NGOs, volunteers"))
node_ai(("AI service"))
node_postgres[("Hosted PostgreSQL")]

node_users -->|"use dashboards"| node_frontend
node_frontend -.->|"request data"| node_webapi
node_frontend -->|"REST requests"| node_backend
node_backend -->|"creates server"| node_app
node_app -->|"mounts routes"| node_routes
node_routes -->|"routes admin calls"| node_admin
node_admin -->|"reads and writes"| node_database
node_volunteers -->|"reads and writes"| node_database
node_admin -->|"runs rescue"| node_rescuejob
node_admin -->|"notifies users"| node_notifications
node_volunteers -->|"finds nearby points"| node_transit
node_volunteers -->|"uses capacity estimates"| node_recommendations
node_volunteers -->|"notifies users"| node_notifications
node_backend -->|"starts job"| node_rescuejob
node_backend -->|"starts job"| node_expiryjob
node_backend -->|"starts job"| node_reminderjob
node_backend -->|"starts job"| node_analyticsjob
node_deliveryui -->|"sends GPS"| node_socketclient
node_deliveryui -.->|"streams tracking"| node_backend
node_backend -.->|"persists data"| node_database
node_postgres -.->|"stores records"| node_database
node_ai -->|"serves predictions"| node_aiapi
node_aiapi -->|"calls inference"| node_prediction
node_backend -.->|"internal HTTP"| node_aiapi

click node_frontend "https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/App.tsx"
click node_webapi "https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/api/client.ts"
click node_deliveryui "https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/hooks/useDeliveryTracking.ts"
click node_socketclient "https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/services/socket.ts"
click node_backend "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/server.ts"
click node_app "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/app.ts"
click node_routes "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/routes/index.ts"
click node_donations "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/donationController.ts"
click node_delivery "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/deliveryController.ts"
click node_admin "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/adminController.ts"
click node_volunteers "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/volunteerController.ts"
click node_database "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/config/prisma.ts"
click node_auth "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/middleware/auth.ts"
click node_notifications "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/services/notificationService.ts"
click node_rescuejob "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/rescueJob.ts"
click node_expiryjob "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/expiryJob.ts"
click node_reminderjob "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/reminderJob.ts"
click node_analyticsjob "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/analyticsJob.ts"
click node_transit "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/services/transitService.ts"
click node_recommendations "https://github.com/nmanoj10/ecoserve/blob/main/backend/src/services/recommendationService.ts"
click node_aiapi "https://github.com/nmanoj10/ecoserve/blob/main/ai-service/api/main.py"
click node_prediction "https://github.com/nmanoj10/ecoserve/blob/main/ai-service/src/predict.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_webapi,node_deliveryui,node_socketclient toneBlue
class node_backend,node_app,node_routes,node_donations,node_delivery,node_admin,node_volunteers,node_database,node_auth,node_postgres toneAmber
class node_notifications,node_rescuejob,node_expiryjob,node_reminderjob,node_analyticsjob,node_transit,node_recommendations toneMint
class node_aiapi,node_prediction toneRose
class node_users,node_ai toneIndigo
```

## Components

### Web application

- [Role-based web app](https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [API client](https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Live delivery tracking](https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/hooks/useDeliveryTracking.ts): `frontend/src/hooks/useDeliveryTracking.ts`
- [Socket client](https://github.com/nmanoj10/ecoserve/blob/main/frontend/src/services/socket.ts): `frontend/src/services/socket.ts`

### Backend API

- [HTTP API server](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/server.ts): `backend/src/server.ts`
- [Express application](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [API routes](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/routes/index.ts): `backend/src/routes/index.ts`
- [Donation workflow](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/donationController.ts): `backend/src/controllers/donationController.ts`
- [Delivery workflow](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/deliveryController.ts): `backend/src/controllers/deliveryController.ts`
- [Admin operations](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/adminController.ts): `backend/src/controllers/adminController.ts`
- [Volunteer operations](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/controllers/volunteerController.ts): `backend/src/controllers/volunteerController.ts`
- [PostgreSQL data](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/config/prisma.ts): `backend/src/config/prisma.ts`
- [Authentication](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`

### Rescue operations

- [Notifications](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/services/notificationService.ts): `backend/src/services/notificationService.ts`
- [Rescue sweep](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/rescueJob.ts): `backend/src/jobs/rescueJob.ts`
- [Expiry job](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/expiryJob.ts): `backend/src/jobs/expiryJob.ts`
- [Reminder job](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/reminderJob.ts): `backend/src/jobs/reminderJob.ts`
- [Analytics job](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/jobs/analyticsJob.ts): `backend/src/jobs/analyticsJob.ts`
- [Transit lookup](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/services/transitService.ts): `backend/src/services/transitService.ts`
- [Volunteer recommendations](https://github.com/nmanoj10/ecoserve/blob/main/backend/src/services/recommendationService.ts): `backend/src/services/recommendationService.ts`

### AI classification

- [Food classifier API](https://github.com/nmanoj10/ecoserve/blob/main/ai-service/api/main.py): `ai-service/api/main.py`
- [Image prediction](https://github.com/nmanoj10/ecoserve/blob/main/ai-service/src/predict.py): `ai-service/src/predict.py`

### Other components

- **Donors, NGOs, volunteers**
- **AI service**
- **Hosted PostgreSQL**

## Connections

- Donors, NGOs, volunteers → Role-based web app: use dashboards (evidence: `README.md`)
- Role-based web app → API client: request data
- Role-based web app → HTTP API server: REST requests (evidence: `README.md`)
- HTTP API server → Express application: creates server (evidence: `backend/src/server.ts`)
- Express application → API routes: mounts routes (evidence: `backend/src/app.ts`)
- API routes → Admin operations: routes admin calls
- Admin operations → PostgreSQL data: reads and writes (evidence: `backend/src/controllers/adminController.ts`)
- Volunteer operations → PostgreSQL data: reads and writes (evidence: `backend/src/controllers/volunteerController.ts`)
- Admin operations → Rescue sweep: runs rescue (evidence: `backend/src/controllers/adminController.ts`)
- Admin operations → Notifications: notifies users (evidence: `backend/src/controllers/adminController.ts`)
- Volunteer operations → Transit lookup: finds nearby points (evidence: `backend/src/controllers/volunteerController.ts`)
- Volunteer operations → Volunteer recommendations: uses capacity estimates (evidence: `backend/src/controllers/volunteerController.ts`)
- Volunteer operations → Notifications: notifies users (evidence: `backend/src/controllers/volunteerController.ts`)
- HTTP API server → Rescue sweep: starts job (evidence: `backend/src/server.ts`)
- HTTP API server → Expiry job: starts job (evidence: `backend/src/server.ts`)
- HTTP API server → Reminder job: starts job (evidence: `backend/src/server.ts`)
- HTTP API server → Analytics job: starts job (evidence: `backend/src/server.ts`)
- Live delivery tracking → Socket client: sends GPS (evidence: `frontend/src/hooks/useDeliveryTracking.ts`)
- Live delivery tracking → HTTP API server: streams tracking
- HTTP API server → PostgreSQL data: persists data (evidence: `backend/src/server.ts`)
- Hosted PostgreSQL → PostgreSQL data: stores records
- AI service → Food classifier API: serves predictions (evidence: `ai-service/api/main.py`)
- Food classifier API → Image prediction: calls inference (evidence: `ai-service/api/main.py`)
- HTTP API server → Food classifier API: internal HTTP (evidence: `README.md`)
