# bridge360ph/bazoora architecture

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

- Interactive diagram: https://gitdiagram.com/bridge360ph/bazoora
- Repository: https://github.com/bridge360ph/bazoora

## Overview

Bazoora is a digital waste-management platform for community residents, drivers, Eco-Aides, and administrators. Its web PWA presents role-specific workflows; the Fastify API authenticates users and coordinates hauling requests, routes and assignments, fleet, notifications, settings, and analytics against shared contracts and persistent data. The clearest sampled end-to-end path is route management: an admin page fetches through a hook and API service, then the API route delegates domain work to its service and database. Other major capabilities are represented from the README and source tree; unsampled internals are not inferred.

Main entry points: [`apps/web/src/App.tsx`](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/App.tsx) (Role-based PWA), [`apps/api/src/server.ts`](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/server.ts) (Fastify server), [`packages/db/src/prismaClient.ts`](https://github.com/bridge360ph/bazoora/blob/development/packages/db/src/prismaClient.ts) (Application database), [`apps/web/src/features/route-management/routeService.ts`](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/routeService.ts) (Route API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Role-based PWA<br/>[App.tsx]"]
  node_authui["Sign-in and session<br/>[LoginPage.tsx]"]
  node_routeui["Route management"]
  node_routehook["Route data hook<br/>[useRoutes.ts]"]
  node_routeserviceui["Route API client<br/>[routeService.ts]"]
  node_haulingui["Hauling requests"]
  node_fleetui["Fleet management"]
  node_ecoaiui["Eco-Aide management"]
  node_driverui["Driver operations<br/>[DriverRoute.tsx]"]
  node_residentui["Truck tracking<br/>[TrackTruckPage.tsx]"]
  node_analyticsui["Analytics"]
  node_notificationsui["Notifications"]
  node_settingsui["Profile and settings<br/>[SettingsPage.tsx]"]
end

subgraph group_api["API and domain"]
  node_server["Fastify server<br/>[server.ts]"]
  node_authroutes["Authentication routes<br/>[authRoutes.ts]"]
  node_authguard["JWT and role guards<br/>[auth.ts]"]
  node_routeapi["Route endpoints"]
  node_routesvc["Route domain service"]
  node_assignmentapi["Route assignment"]
  node_assignmentsvc["Assignment service"]
  node_haulingapi["Hauling requests API"]
  node_fleetapi["Fleet endpoints"]
  node_ecoapi["Eco-Aide endpoints<br/>[ecoAides.ts]"]
  node_analyticsapi["Analytics endpoints<br/>[analyticsRoutes.ts]"]
  node_notificationsapi["Notification endpoints"]
  node_settingsapi["Settings endpoints<br/>[settingsRoutes.ts]"]
  node_socket["Live event channel<br/>[socket.ts]"]
end

subgraph group_shared["Shared contracts"]
  node_contracts["Shared API contracts<br/>[route.ts]"]
end

subgraph group_data["Persistence"]
  node_database[("Application database<br/>[prismaClient.ts]")]
end

node_admin(("Administrators"))
node_residents(("Residents"))
node_operators(("Drivers and Eco-Aides"))

node_admin -->|"uses"| node_webapp
node_residents -->|"uses"| node_webapp
node_operators -->|"uses"| node_webapp
node_webapp -->|"routes to"| node_authui
node_webapp -->|"routes to"| node_routeui
node_webapp -->|"routes to"| node_haulingui
node_webapp -->|"routes to"| node_fleetui
node_webapp -->|"routes to"| node_ecoaiui
node_webapp -->|"routes to"| node_driverui
node_webapp -->|"routes to"| node_residentui
node_webapp -->|"routes to"| node_analyticsui
node_webapp -->|"routes to"| node_notificationsui
node_webapp -->|"routes to"| node_settingsui
node_routeui -->|"loads through"| node_routehook
node_routehook -->|"fetches via"| node_routeserviceui
node_routeserviceui -->|"requests routes"| node_routeapi
node_server -->|"registers"| node_authroutes
node_server -->|"registers"| node_routeapi
node_server -->|"registers"| node_assignmentapi
node_server -->|"registers"| node_haulingapi
node_server -->|"registers"| node_fleetapi
node_server -->|"registers"| node_ecoapi
node_server -->|"registers"| node_analyticsapi
node_server -->|"registers"| node_notificationsapi
node_server -->|"registers"| node_settingsapi
node_routeapi -->|"delegates to"| node_routesvc
node_assignmentapi -->|"delegates to"| node_assignmentsvc
node_routesvc -->|"reads and writes"| node_database
node_assignmentsvc -->|"reads and writes"| node_database
node_authroutes -->|"stores sessions"| node_database
node_authroutes -->|"uses guard"| node_authguard
node_settingsapi -->|"reads and writes"| node_database
node_notificationsapi -->|"reads and writes"| node_database
node_notificationsapi -->|"emits events"| node_socket
node_fleetapi -->|"reads and writes"| node_database
node_routesvc -->|"uses types"| node_contracts
node_routeserviceui -->|"uses types"| node_contracts

click node_webapp "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/App.tsx"
click node_authui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/auth/components/LoginPage.tsx"
click node_routeui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/AdminRouteManagementPage.tsx"
click node_routehook "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/hooks/useRoutes.ts"
click node_routeserviceui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/routeService.ts"
click node_haulingui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/hauling-requests/AdminHaulingRequestManagementPage.tsx"
click node_fleetui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/fleet-management/AdminFleetManagementPage.tsx"
click node_ecoaiui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/eco-aides/components/EcoAideManagementPage.tsx"
click node_driverui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/driver/components/DriverRoute.tsx"
click node_residentui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/residents/components/TrackTruckPage.tsx"
click node_analyticsui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/analytics/AdminAnalyticsPage.tsx"
click node_notificationsui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/notifications/components/NotificationsPage.tsx"
click node_settingsui "https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/settings/components/SettingsPage.tsx"
click node_server "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/server.ts"
click node_authroutes "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/authRoutes.ts"
click node_authguard "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/lib/auth.ts"
click node_routeapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/routeManagementRoutes.ts"
click node_routesvc "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/services/routeManagementService.ts"
click node_assignmentapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/routeAssignmentRoutes.ts"
click node_assignmentsvc "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/services/routeAssignmentService.ts"
click node_haulingapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/haulingRequestRoutes.ts"
click node_fleetapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/adminFleetRoutes.ts"
click node_ecoapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/ecoAides.ts"
click node_analyticsapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/analyticsRoutes.ts"
click node_notificationsapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/notificationRoutes.ts"
click node_settingsapi "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/settingsRoutes.ts"
click node_socket "https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/plugins/socket.ts"
click node_contracts "https://github.com/bridge360ph/bazoora/blob/development/packages/shared/src/route.ts"
click node_database "https://github.com/bridge360ph/bazoora/blob/development/packages/db/src/prismaClient.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_webapp,node_authui,node_routeui,node_routehook,node_routeserviceui,node_haulingui,node_fleetui,node_ecoaiui,node_driverui,node_residentui,node_analyticsui,node_notificationsui,node_settingsui toneBlue
class node_server,node_authroutes,node_authguard,node_routeapi,node_routesvc,node_assignmentapi,node_assignmentsvc,node_haulingapi,node_fleetapi,node_ecoapi,node_analyticsapi,node_notificationsapi,node_settingsapi,node_socket toneAmber
class node_contracts toneMint
class node_database toneRose
class node_admin,node_residents,node_operators toneIndigo
```

## Components

### Web application

- [Role-based PWA](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/App.tsx): `apps/web/src/App.tsx`
- [Sign-in and session](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/auth/components/LoginPage.tsx): `apps/web/src/features/auth/components/LoginPage.tsx`
- [Route management](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/AdminRouteManagementPage.tsx): `apps/web/src/features/route-management/AdminRouteManagementPage.tsx`
- [Route data hook](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/hooks/useRoutes.ts): `apps/web/src/features/route-management/hooks/useRoutes.ts`
- [Route API client](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/route-management/routeService.ts): `apps/web/src/features/route-management/routeService.ts`
- [Hauling requests](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/hauling-requests/AdminHaulingRequestManagementPage.tsx): `apps/web/src/features/hauling-requests/AdminHaulingRequestManagementPage.tsx`
- [Fleet management](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/fleet-management/AdminFleetManagementPage.tsx): `apps/web/src/features/fleet-management/AdminFleetManagementPage.tsx`
- [Eco-Aide management](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/eco-aides/components/EcoAideManagementPage.tsx): `apps/web/src/features/eco-aides/components/EcoAideManagementPage.tsx`
- [Driver operations](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/driver/components/DriverRoute.tsx): `apps/web/src/features/driver/components/DriverRoute.tsx`
- [Truck tracking](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/residents/components/TrackTruckPage.tsx): `apps/web/src/features/residents/components/TrackTruckPage.tsx`
- [Analytics](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/analytics/AdminAnalyticsPage.tsx): `apps/web/src/features/analytics/AdminAnalyticsPage.tsx`
- [Notifications](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/notifications/components/NotificationsPage.tsx): `apps/web/src/features/notifications/components/NotificationsPage.tsx`
- [Profile and settings](https://github.com/bridge360ph/bazoora/blob/development/apps/web/src/features/settings/components/SettingsPage.tsx): `apps/web/src/features/settings/components/SettingsPage.tsx`

### API and domain

- [Fastify server](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/server.ts): `apps/api/src/server.ts`
- [Authentication routes](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/authRoutes.ts): `apps/api/src/routes/authRoutes.ts`
- [JWT and role guards](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/lib/auth.ts): `apps/api/src/lib/auth.ts`
- [Route endpoints](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/routeManagementRoutes.ts): `apps/api/src/routes/routeManagementRoutes.ts`
- [Route domain service](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/services/routeManagementService.ts): `apps/api/src/services/routeManagementService.ts`
- [Route assignment](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/routeAssignmentRoutes.ts): `apps/api/src/routes/routeAssignmentRoutes.ts`
- [Assignment service](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/services/routeAssignmentService.ts): `apps/api/src/services/routeAssignmentService.ts`
- [Hauling requests API](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/haulingRequestRoutes.ts): `apps/api/src/routes/haulingRequestRoutes.ts`
- [Fleet endpoints](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/adminFleetRoutes.ts): `apps/api/src/routes/adminFleetRoutes.ts`
- [Eco-Aide endpoints](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/ecoAides.ts): `apps/api/src/routes/ecoAides.ts`
- [Analytics endpoints](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/analyticsRoutes.ts): `apps/api/src/routes/analyticsRoutes.ts`
- [Notification endpoints](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/notificationRoutes.ts): `apps/api/src/routes/notificationRoutes.ts`
- [Settings endpoints](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/routes/settingsRoutes.ts): `apps/api/src/routes/settingsRoutes.ts`
- [Live event channel](https://github.com/bridge360ph/bazoora/blob/development/apps/api/src/plugins/socket.ts): `apps/api/src/plugins/socket.ts`

### Shared contracts

- [Shared API contracts](https://github.com/bridge360ph/bazoora/blob/development/packages/shared/src/route.ts): `packages/shared/src/route.ts`

### Persistence

- [Application database](https://github.com/bridge360ph/bazoora/blob/development/packages/db/src/prismaClient.ts): `packages/db/src/prismaClient.ts`

### Other components

- **Administrators**
- **Residents**
- **Drivers and Eco-Aides**

## Connections

- Administrators → Role-based PWA: uses (evidence: `README.md`)
- Residents → Role-based PWA: uses (evidence: `README.md`)
- Drivers and Eco-Aides → Role-based PWA: uses (evidence: `README.md`)
- Role-based PWA → Sign-in and session: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Route management: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Hauling requests: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Fleet management: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Eco-Aide management: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Driver operations: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Truck tracking: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Analytics: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Notifications: routes to (evidence: `apps/web/src/App.tsx`)
- Role-based PWA → Profile and settings: routes to (evidence: `apps/web/src/App.tsx`)
- Route management → Route data hook: loads through (evidence: `apps/web/src/features/route-management/hooks/useRoutes.ts`)
- Route data hook → Route API client: fetches via (evidence: `apps/web/src/features/route-management/hooks/useRoutes.ts`)
- Route API client → Route endpoints: requests routes (evidence: `apps/web/src/features/route-management/routeService.ts`)
- Fastify server → Authentication routes: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Route endpoints: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Route assignment: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Hauling requests API: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Fleet endpoints: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Eco-Aide endpoints: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Analytics endpoints: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Notification endpoints: registers (evidence: `apps/api/src/server.ts`)
- Fastify server → Settings endpoints: registers (evidence: `apps/api/src/server.ts`)
- Route endpoints → Route domain service: delegates to (evidence: `apps/api/src/routes/routeManagementRoutes.ts`)
- Route assignment → Assignment service: delegates to (evidence: `apps/api/src/routes/routeAssignmentRoutes.ts`)
- Route domain service → Application database: reads and writes (evidence: `apps/api/src/services/routeManagementService.ts`)
- Assignment service → Application database: reads and writes (evidence: `apps/api/src/services/routeAssignmentService.ts`)
- Authentication routes → Application database: stores sessions (evidence: `apps/api/src/routes/authRoutes.ts`)
- Authentication routes → JWT and role guards: uses guard (evidence: `apps/api/src/routes/authRoutes.ts`)
- Settings endpoints → Application database: reads and writes (evidence: `apps/api/src/routes/settingsRoutes.ts`)
- Notification endpoints → Application database: reads and writes (evidence: `apps/api/src/routes/notificationRoutes.ts`)
- Notification endpoints → Live event channel: emits events (evidence: `apps/api/src/routes/notificationRoutes.ts`)
- Fleet endpoints → Application database: reads and writes (evidence: `apps/api/src/routes/adminFleetRoutes.ts`)
- Route domain service → Shared API contracts: uses types (evidence: `apps/api/src/services/routeManagementService.ts`)
- Route API client → Shared API contracts: uses types (evidence: `apps/web/src/features/route-management/routeService.ts`)
