# krutthiikaaa/serve-final architecture

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

- Interactive diagram: https://gitdiagram.com/krutthiikaaa/serve-final
- Repository: https://github.com/krutthiikaaa/serve-final

## Overview

SERVE is a university night-canteen ordering platform: students select a canteen, browse its menu, receive a server-priced quote, place and pay for pickup orders, then track readiness; staff manage the order lifecycle and menu, while admins manage canteens and staff access. The three clients share an authenticated REST/realtime backend and PostgreSQL source of truth. Backend route-to-service edges follow shown route calls; additional client capabilities are README-documented, with some internal wiring unsampled.

Main entry points: [`backend/src/app.ts`](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/app.ts) (Express app), [`backend/src/services.ts`](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/services.ts) (Service wiring), [`backend/src/modules/orders/orders.service.ts`](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/orders/orders.service.ts) (Quotes and orders), [`backend/src/modules/payments/payments.service.ts`](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/payments/payments.service.ts) (Payment processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["User apps"]
  node_students["Student app"]
  node_staff["Staff dashboard<br/>[App.tsx]"]
  node_admin["Admin portal<br/>[App.tsx]"]
end

subgraph group_shared["Shared web layer"]
  node_webshared["Web shared"]
  node_contracts["API contracts<br/>[index.ts]"]
end

subgraph group_backend["Backend API"]
  node_entry["Express app<br/>[app.ts]"]
  node_auth["Identity and registration<br/>[auth.service.ts]"]
  node_canteens["Canteens and browsing"]
  node_services["Service wiring<br/>[services.ts]"]
  node_authn["Authentication middleware<br/>[auth.ts]"]
end

subgraph group_operations["Orders and operations"]
  node_orders["Quotes and orders<br/>[orders.service.ts]"]
  node_payments["Payment processing"]
  node_menu["Menu management<br/>[menu.service.ts]"]
  node_staffops["Staff operations<br/>[staff.service.ts]"]
  node_adminops["Admin management<br/>[admin.service.ts]"]
  node_requests["Access requests"]
  node_notifications["Notifications"]
  node_realtime["Realtime events<br/>[socket-server.ts]"]
end

subgraph group_data["Persistence and integrations"]
  node_dbclient["Prisma client<br/>[prisma.ts]"]
  node_database[("PostgreSQL")]
  node_firebase["Firebase Auth"]
  node_paymentprovider["Payment provider<br/>[provider.ts]"]
end

node_studentactor(("Student"))
node_staffactor(("Canteen staff"))
node_adminactor(("Administrator"))

node_studentactor -->|"orders and tracks"| node_students
node_staffactor -->|"manages orders"| node_staff
node_adminactor -->|"manages platform"| node_admin
node_students -.->|"uses shared services"| node_webshared
node_staff -->|"uses auth and realtime"| node_webshared
node_admin -->|"uses auth and realtime"| node_webshared
node_webshared -.->|"uses types"| node_contracts
node_students -.->|"REST and sockets"| node_entry
node_staff -->|"REST and sockets"| node_entry
node_admin -->|"REST and sockets"| node_entry
node_firebase -->|"proves identity"| node_authn
node_entry -->|"routes registration"| node_auth
node_entry -->|"routes browsing"| node_canteens
node_entry -->|"routes cart and orders"| node_orders
node_entry -->|"routes payments"| node_payments
node_entry -->|"routes staff actions"| node_staffops
node_entry -->|"routes admin actions"| node_adminops
node_entry -->|"routes notifications"| node_notifications
node_entry -->|"creates services"| node_services
node_services -.->|"provides order service"| node_orders
node_services -.->|"provides payment service"| node_payments
node_services -.->|"provides menu service"| node_menu
node_services -.->|"provides admin service"| node_adminops
node_services -.->|"provides request service"| node_requests
node_services -.->|"provides notification service"| node_notifications
node_auth -->|"creates access request"| node_requests
node_orders -.->|"reads and writes"| node_database
node_canteens -.->|"reads canteen data"| node_database
node_menu -.->|"reads and writes"| node_database
node_payments -.->|"dispatches payment"| node_paymentprovider
node_payments -.->|"records payment"| node_database
node_orders -.->|"publishes status"| node_realtime
node_notifications -.->|"persists notices"| node_database
node_entry -->|"authenticates routes"| node_authn
node_authn -.->|"verifies token"| node_firebase
node_dbclient -.->|"connects to"| node_database

click node_students "https://github.com/krutthiikaaa/serve-final/tree/main/apps/student"
click node_staff "https://github.com/krutthiikaaa/serve-final/blob/main/apps/staff/src/App.tsx"
click node_admin "https://github.com/krutthiikaaa/serve-final/blob/main/apps/admin/src/App.tsx"
click node_webshared "https://github.com/krutthiikaaa/serve-final/tree/main/packages/web-shared/src"
click node_contracts "https://github.com/krutthiikaaa/serve-final/blob/main/packages/contracts/src/index.ts"
click node_entry "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/app.ts"
click node_auth "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/auth/auth.service.ts"
click node_canteens "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/canteens/canteens.service.ts"
click node_orders "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/orders/orders.service.ts"
click node_payments "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/payments/payments.service.ts"
click node_menu "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/menu/menu.service.ts"
click node_staffops "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/staff/staff.service.ts"
click node_adminops "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/admin/admin.service.ts"
click node_requests "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/change-requests/change-requests.service.ts"
click node_notifications "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/notifications/notifications.service.ts"
click node_realtime "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/realtime/socket-server.ts"
click node_services "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/services.ts"
click node_authn "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/middleware/auth.ts"
click node_dbclient "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/lib/prisma.ts"
click node_paymentprovider "https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/payments/provider.ts"

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_students,node_staff,node_admin toneBlue
class node_webshared,node_contracts toneAmber
class node_entry,node_auth,node_canteens,node_services,node_authn toneMint
class node_orders,node_payments,node_menu,node_staffops,node_adminops,node_requests,node_notifications,node_realtime toneRose
class node_dbclient,node_database,node_firebase,node_paymentprovider,node_studentactor,node_staffactor,node_adminactor toneIndigo
```

## Components

### User apps

- [Student app](https://github.com/krutthiikaaa/serve-final/tree/main/apps/student): `apps/student`
- [Staff dashboard](https://github.com/krutthiikaaa/serve-final/blob/main/apps/staff/src/App.tsx): `apps/staff/src/App.tsx`
- [Admin portal](https://github.com/krutthiikaaa/serve-final/blob/main/apps/admin/src/App.tsx): `apps/admin/src/App.tsx`

### Shared web layer

- [Web shared](https://github.com/krutthiikaaa/serve-final/tree/main/packages/web-shared/src): `packages/web-shared/src`
- [API contracts](https://github.com/krutthiikaaa/serve-final/blob/main/packages/contracts/src/index.ts): `packages/contracts/src/index.ts`

### Backend API

- [Express app](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Identity and registration](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/auth/auth.service.ts): `backend/src/modules/auth/auth.service.ts`
- [Canteens and browsing](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/canteens/canteens.service.ts): `backend/src/modules/canteens/canteens.service.ts`
- [Service wiring](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/services.ts): `backend/src/services.ts`
- [Authentication middleware](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/middleware/auth.ts): `backend/src/middleware/auth.ts`

### Orders and operations

- [Quotes and orders](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/orders/orders.service.ts): `backend/src/modules/orders/orders.service.ts`
- [Payment processing](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/payments/payments.service.ts): `backend/src/modules/payments/payments.service.ts`
- [Menu management](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/menu/menu.service.ts): `backend/src/modules/menu/menu.service.ts`
- [Staff operations](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/staff/staff.service.ts): `backend/src/modules/staff/staff.service.ts`
- [Admin management](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/admin/admin.service.ts): `backend/src/modules/admin/admin.service.ts`
- [Access requests](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/change-requests/change-requests.service.ts): `backend/src/modules/change-requests/change-requests.service.ts`
- [Notifications](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/notifications/notifications.service.ts): `backend/src/modules/notifications/notifications.service.ts`
- [Realtime events](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/realtime/socket-server.ts): `backend/src/realtime/socket-server.ts`

### Persistence and integrations

- [Prisma client](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/lib/prisma.ts): `backend/src/lib/prisma.ts`
- **PostgreSQL**
- **Firebase Auth**
- [Payment provider](https://github.com/krutthiikaaa/serve-final/blob/main/backend/src/modules/payments/provider.ts): `backend/src/modules/payments/provider.ts`

### Other components

- **Student**
- **Canteen staff**
- **Administrator**

## Connections

- Student → Student app: orders and tracks (evidence: `README.md`)
- Canteen staff → Staff dashboard: manages orders (evidence: `README.md`)
- Administrator → Admin portal: manages platform (evidence: `README.md`)
- Student app → Web shared: uses shared services
- Staff dashboard → Web shared: uses auth and realtime (evidence: `apps/staff/src/App.tsx`)
- Admin portal → Web shared: uses auth and realtime (evidence: `apps/admin/src/App.tsx`)
- Web shared → API contracts: uses types
- Student app → Express app: REST and sockets (evidence: `README.md`)
- Staff dashboard → Express app: REST and sockets (evidence: `apps/staff/src/App.tsx`)
- Admin portal → Express app: REST and sockets (evidence: `apps/admin/src/App.tsx`)
- Firebase Auth → Authentication middleware: proves identity (evidence: `README.md`)
- Express app → Identity and registration: routes registration (evidence: `backend/src/app.ts`)
- Express app → Canteens and browsing: routes browsing (evidence: `backend/src/app.ts`)
- Express app → Quotes and orders: routes cart and orders (evidence: `backend/src/app.ts`)
- Express app → Payment processing: routes payments (evidence: `backend/src/app.ts`)
- Express app → Staff operations: routes staff actions (evidence: `backend/src/app.ts`)
- Express app → Admin management: routes admin actions (evidence: `backend/src/app.ts`)
- Express app → Notifications: routes notifications (evidence: `backend/src/app.ts`)
- Express app → Service wiring: creates services (evidence: `backend/src/app.ts`)
- Service wiring → Quotes and orders: provides order service
- Service wiring → Payment processing: provides payment service
- Service wiring → Menu management: provides menu service
- Service wiring → Admin management: provides admin service
- Service wiring → Access requests: provides request service
- Service wiring → Notifications: provides notification service
- Identity and registration → Access requests: creates access request (evidence: `backend/src/modules/auth/auth.service.ts`)
- Quotes and orders → PostgreSQL: reads and writes
- Canteens and browsing → PostgreSQL: reads canteen data
- Menu management → PostgreSQL: reads and writes
- Payment processing → Payment provider: dispatches payment
- Payment processing → PostgreSQL: records payment
- Quotes and orders → Realtime events: publishes status
- Notifications → PostgreSQL: persists notices
- Express app → Authentication middleware: authenticates routes
- Authentication middleware → Firebase Auth: verifies token
- Prisma client → PostgreSQL: connects to
