# community-vercel/ustaadpro-server architecture

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

- Interactive diagram: https://gitdiagram.com/community-vercel/ustaadpro-server
- Repository: https://github.com/community-vercel/ustaadpro-server

## Overview

UstaadPro is an Express/PostgreSQL backend for a mobile home-services marketplace, with a parallel WhatsApp booking and administration surface. The main customer flow is signup or login, browse/search the service catalog, then check out and review orders; the service model also represents work-price options and pricing modes. Other documented domains include addresses, shop, providers, complaints, and admin management. The tree and excerpts establish server mounting and selected integrations; unsampled routes and controllers are represented at domain level, without asserting their internal call wiring.

Main entry points: [`server.js`](https://github.com/community-vercel/ustaadpro-server/blob/main/server.js) (Express Server), [`controllers/authController.js`](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/authController.js) (Auth Controller), [`routes/botRoutes.js`](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/botRoutes.js) (Bot Routes), [`models/Service.js`](https://github.com/community-vercel/ustaadpro-server/blob/main/models/Service.js) (Service Catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Marketplace API"]
  node_server["Express Server<br/>[server.js]"]
  node_db[("PostgreSQL<br/>[db.js]")]
end

subgraph group_catalog["Catalog And Commerce"]
  node_services_routes["Service Routes<br/>[services.js]"]
  node_service_controller["Service Controller"]
  node_service_model["Service Catalog<br/>[Service.js]"]
  node_orders_routes["Order Routes<br/>[orders.js]"]
  node_order_controller["Order Controller<br/>[orderController.js]"]
  node_orders[("Order Records<br/>[Order.js]")]
  node_reviews["Review API"]
  node_search["Search API"]
  node_commerce["Commerce Domains<br/>[shop.js]"]
end

subgraph group_identity["Identity And Messaging"]
  node_auth_routes["Auth Routes<br/>[auth.js]"]
  node_auth_controller["Auth Controller<br/>[authController.js]"]
  node_users[("User Records<br/>[User.js]")]
  node_otps[("OTP Records<br/>[AuthOtp.js]")]
  node_mailer["Email Sender<br/>[mailer.js]"]
  node_sms["SMS Sender<br/>[sms.js]"]
end

subgraph group_bot["WhatsApp Booking"]
  node_bot_routes["Bot Routes<br/>[botRoutes.js]"]
  node_bot_controller["Bot Controller<br/>[botController.js]"]
  node_bot_services["Bot Service Catalog<br/>[whatsappService.js]"]
  node_bot_bookings["Bot Booking API"]
  node_bot_service_routes["Bot Service Routes"]
  node_bot_service_controller["Bot Service Controller"]
end

subgraph group_admin["Operations"]
  node_operations["Admin API<br/>[adminController.js]"]
end

node_customer(("Mobile Client"))
node_email_service["Email Provider"]
node_sms_service["SMS Provider"]
node_firebase["Firebase Messaging"]

node_customer -->|"sends API requests"| node_server
node_server -->|"mounts auth API"| node_auth_routes
node_server -->|"mounts service API"| node_services_routes
node_server -->|"mounts order API"| node_orders_routes
node_server -->|"mounts bot API"| node_bot_routes
node_server -->|"mounts bot services"| node_bot_service_routes
node_auth_routes -->|"dispatches auth requests"| node_auth_controller
node_auth_controller -->|"reads and updates users"| node_users
node_auth_controller -->|"manages verification codes"| node_otps
node_auth_controller -->|"sends email codes"| node_mailer
node_auth_controller -->|"sends SMS codes"| node_sms
node_mailer -->|"delivers messages"| node_email_service
node_sms -->|"delivers messages"| node_sms_service
node_services_routes -->|"dispatches catalog requests"| node_service_controller
node_service_controller -->|"queries catalog"| node_service_model
node_service_model -->|"reads catalog and pricing"| node_db
node_orders_routes -->|"dispatches checkout requests"| node_order_controller
node_order_controller -->|"creates and lists orders"| node_orders
node_orders -->|"persists order data"| node_db
node_server -->|"mounts search API"| node_search
node_server -->|"mounts review API"| node_reviews
node_server -->|"mounts shop API"| node_commerce
node_server -->|"mounts admin API"| node_operations
node_operations -.->|"sends push notifications"| node_firebase
node_bot_routes -->|"dispatches bot controls"| node_bot_controller
node_bot_routes -->|"dispatches booking timeline"| node_bot_bookings
node_bot_service_routes -->|"dispatches service management"| node_bot_service_controller
node_bot_services -->|"loads bot catalog"| node_service_model
node_server -->|"checks database"| node_db

click node_server "https://github.com/community-vercel/ustaadpro-server/blob/main/server.js"
click node_auth_routes "https://github.com/community-vercel/ustaadpro-server/blob/main/routes/auth.js"
click node_auth_controller "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/authController.js"
click node_users "https://github.com/community-vercel/ustaadpro-server/blob/main/models/User.js"
click node_otps "https://github.com/community-vercel/ustaadpro-server/blob/main/models/AuthOtp.js"
click node_mailer "https://github.com/community-vercel/ustaadpro-server/blob/main/utils/mailer.js"
click node_sms "https://github.com/community-vercel/ustaadpro-server/blob/main/utils/sms.js"
click node_services_routes "https://github.com/community-vercel/ustaadpro-server/blob/main/routes/services.js"
click node_service_controller "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/serviceController.js"
click node_service_model "https://github.com/community-vercel/ustaadpro-server/blob/main/models/Service.js"
click node_orders_routes "https://github.com/community-vercel/ustaadpro-server/blob/main/routes/orders.js"
click node_order_controller "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/orderController.js"
click node_orders "https://github.com/community-vercel/ustaadpro-server/blob/main/models/Order.js"
click node_reviews "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/reviewController.js"
click node_search "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/searchController.js"
click node_commerce "https://github.com/community-vercel/ustaadpro-server/blob/main/routes/shop.js"
click node_operations "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/adminController.js"
click node_bot_routes "https://github.com/community-vercel/ustaadpro-server/blob/main/routes/botRoutes.js"
click node_bot_controller "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/botController.js"
click node_bot_services "https://github.com/community-vercel/ustaadpro-server/blob/main/services/whatsappService.js"
click node_bot_bookings "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/botbookingController.js"
click node_bot_service_routes "https://github.com/community-vercel/ustaadpro-server/blob/main/routes/botserviceRoutes.js"
click node_bot_service_controller "https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/botserviceController.js"
click node_db "https://github.com/community-vercel/ustaadpro-server/blob/main/config/db.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_server,node_db,node_customer toneBlue
class node_services_routes,node_service_controller,node_service_model,node_orders_routes,node_order_controller,node_orders,node_reviews,node_search,node_commerce toneAmber
class node_auth_routes,node_auth_controller,node_users,node_otps,node_mailer,node_sms toneMint
class node_bot_routes,node_bot_controller,node_bot_services,node_bot_bookings,node_bot_service_routes,node_bot_service_controller toneRose
class node_operations,node_email_service,node_sms_service,node_firebase toneIndigo
```

## Components

### Marketplace API

- [Express Server](https://github.com/community-vercel/ustaadpro-server/blob/main/server.js): `server.js`
- [PostgreSQL](https://github.com/community-vercel/ustaadpro-server/blob/main/config/db.js): `config/db.js`

### Catalog And Commerce

- [Service Routes](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/services.js): `routes/services.js`
- [Service Controller](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/serviceController.js): `controllers/serviceController.js`
- [Service Catalog](https://github.com/community-vercel/ustaadpro-server/blob/main/models/Service.js): `models/Service.js`
- [Order Routes](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/orders.js): `routes/orders.js`
- [Order Controller](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/orderController.js): `controllers/orderController.js`
- [Order Records](https://github.com/community-vercel/ustaadpro-server/blob/main/models/Order.js): `models/Order.js`
- [Review API](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/reviewController.js): `controllers/reviewController.js`
- [Search API](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/searchController.js): `controllers/searchController.js`
- [Commerce Domains](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/shop.js): `routes/shop.js`

### Identity And Messaging

- [Auth Routes](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/auth.js): `routes/auth.js`
- [Auth Controller](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/authController.js): `controllers/authController.js`
- [User Records](https://github.com/community-vercel/ustaadpro-server/blob/main/models/User.js): `models/User.js`
- [OTP Records](https://github.com/community-vercel/ustaadpro-server/blob/main/models/AuthOtp.js): `models/AuthOtp.js`
- [Email Sender](https://github.com/community-vercel/ustaadpro-server/blob/main/utils/mailer.js): `utils/mailer.js`
- [SMS Sender](https://github.com/community-vercel/ustaadpro-server/blob/main/utils/sms.js): `utils/sms.js`

### WhatsApp Booking

- [Bot Routes](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/botRoutes.js): `routes/botRoutes.js`
- [Bot Controller](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/botController.js): `controllers/botController.js`
- [Bot Service Catalog](https://github.com/community-vercel/ustaadpro-server/blob/main/services/whatsappService.js): `services/whatsappService.js`
- [Bot Booking API](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/botbookingController.js): `controllers/botbookingController.js`
- [Bot Service Routes](https://github.com/community-vercel/ustaadpro-server/blob/main/routes/botserviceRoutes.js): `routes/botserviceRoutes.js`
- [Bot Service Controller](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/botserviceController.js): `controllers/botserviceController.js`

### Operations

- [Admin API](https://github.com/community-vercel/ustaadpro-server/blob/main/controllers/adminController.js): `controllers/adminController.js`

### Other components

- **Mobile Client**
- **Email Provider**
- **SMS Provider**
- **Firebase Messaging**

## Connections

- Mobile Client → Express Server: sends API requests
- Express Server → Auth Routes: mounts auth API
- Express Server → Service Routes: mounts service API
- Express Server → Order Routes: mounts order API
- Express Server → Bot Routes: mounts bot API
- Express Server → Bot Service Routes: mounts bot services
- Auth Routes → Auth Controller: dispatches auth requests
- Auth Controller → User Records: reads and updates users
- Auth Controller → OTP Records: manages verification codes
- Auth Controller → Email Sender: sends email codes
- Auth Controller → SMS Sender: sends SMS codes
- Email Sender → Email Provider: delivers messages
- SMS Sender → SMS Provider: delivers messages
- Service Routes → Service Controller: dispatches catalog requests
- Service Controller → Service Catalog: queries catalog
- Service Catalog → PostgreSQL: reads catalog and pricing
- Order Routes → Order Controller: dispatches checkout requests
- Order Controller → Order Records: creates and lists orders
- Order Records → PostgreSQL: persists order data
- Express Server → Search API: mounts search API
- Express Server → Review API: mounts review API
- Express Server → Commerce Domains: mounts shop API
- Express Server → Admin API: mounts admin API
- Admin API → Firebase Messaging: sends push notifications
- Bot Routes → Bot Controller: dispatches bot controls
- Bot Routes → Bot Booking API: dispatches booking timeline
- Bot Service Routes → Bot Service Controller: dispatches service management
- Bot Service Catalog → Service Catalog: loads bot catalog
- Express Server → PostgreSQL: checks database
