# anuragsingh0123/cab_booking architecture

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

- Interactive diagram: https://gitdiagram.com/anuragsingh0123/cab_booking
- Repository: https://github.com/anuragsingh0123/cab_booking

## Overview

1. **Overall shape**
   - This repo is a two-tier cab booking system: an **Angular frontend** in `client/` and a **Node.js/Express backend** in `server/`.
   - The frontend handles user interaction and route-based screens; the backend exposes REST-style APIs, persists domain data in MongoDB-style models, and protects selected endpoints with auth middleware.

2. **Frontend application shell**
   - The Angular app is organized around the standard root bootstrap files: `main.ts`, `app.config.ts`, `app.routes.ts`, and `app.ts`.
   - `app.routes.ts` is the main navigation boundary, while `app.config.ts` likely wires global providers such as HTTP and routing concerns.
   - `app.html`/`app.css` provide the top-level shell, with shared UI components such as the navbar and popup message.

3. **Frontend feature modules / screens**
   - The UI is split into feature components for major user journeys: `home`, `login`, `user-signup`, `driver-signup`, `ride-request`, `checkout`, `vehicle-selection`, `ride-success`, `my-trips`, `profile`, `about`, `map`, `driver-dashboard`, and `not-found`.
   - This suggests the app is route-driven, with separate screens for passenger booking, driver onboarding, trip management, and fallback navigation.

4. **Frontend shared services**
   - Several Angular services encapsulate app logic and backend communication:
     - `auth-service` for login/session state
     - `auth-interceptor` for attaching auth headers to HTTP requests
     - `auth-guard` for restricting protected routes
     - `ride-service`, `driver-service`, `user-service`, `route-service`, `build-route-service`
     - `location-service` and `map-render-service` for geolocation and map display
     - `popup-service` for transient user feedback
   - These services are the main client-side boundary between UI components and the backend APIs.

5. **Frontend flow of data**
   - The typical flow is: user action in a component → service call → HTTP request through interceptor → backend API → response rendered back into the component.
   - The presence of `location-service`, `map-render-service`, and route-building services indicates the booking flow depends on location and route data before confirmation.

6. **Authentication and authorization**
   - The frontend has both `auth-guard` and `auth-interceptor`, which means protected screens and authenticated API calls are handled centrally.
   - On the server, `middleware/authMiddleware.js` provides the corresponding request-side protection.
   - Together, these create the boundary between anonymous flows like signup/login and authenticated flows like ride booking, profile, and driver dashboard access.

7. **Backend API structure**
   - The Express backend is organized by domain:
     - `authRoutes` / `authController`
     - `userRoutes` / `userController`
     - `driverRoutes` / `driverController`
     - `rideRoutes` / `rideController`
     - `reviewRoutes` / `reviewController`
   - `app.js` is the entry point that likely mounts routes, middleware, and database connectivity.

8. **Backend persistence layer**
   - Domain data is modeled under `server/models/`:
     - `user.js`
     - `driver.js`
     - `booking.js`
     - `review.js`
   - This indicates the core data model centers on accounts, driver profiles, trip bookings, and post-trip reviews.

9. **Database and environment**
   - `server/config/connectDB.js` centralizes database connection setup.
   - The presence of `server/.env` indicates environment-based configuration for runtime secrets and connection strings.
   - The repository layout strongly suggests a MongoDB-backed backend, though the exact driver is not shown in the tree.

10. **Domain boundaries**
   - Passenger-facing operations appear to live mostly in the frontend screens and ride/user APIs.
   - Driver-facing operations are separated into driver signup, driver dashboard, and driver-specific backend routes/controllers.
   - Reviews are isolated into their own model/controller/route set, which keeps post-trip feedback independent from booking lifecycle logic.

11. **Ride booking lifecycle**
   - The main business flow likely runs through: user selects vehicle/route → checkout/request ride → backend creates or updates a booking → ride success / trip history updates.
   - The `ride-request`, `vehicle-selection`, `checkout`, and `ride-success` screens show this as a staged interaction rather than a single form.

12. **Maps and location concerns**
   - `map`, `location-service`, `map-render-service`, `route-service`, and `build-route-service` define a distinct geospatial subsystem on the client.
   - This subsystem is responsible for showing pickup/drop-off context, rendering maps, and constructing route information used during booking and driver navigation.

13. **Operational tooling**
   - The frontend uses Angular project tooling (`angular.json`, TypeScript configs, Prettier, editor settings, component specs).
   - The backend uses standard Node package metadata and lockfile, suggesting a conventional Express development/deployment model.

14. **Important diagram boundaries**
   - Draw a clear boundary between the Angular client and the Express API server.
   - Inside the server, separate routing, controller, middleware, model, and DB connection layers.
   - Inside the client, separate route-level screens from shared services and cross-cutting auth/map/popup infrastructure.

Main entry points: [`client/src/app/app.routes.ts`](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.routes.ts) (Routes), [`client/src/app/auth-service.ts`](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/auth-service.ts) (Auth core), [`server/routes/authRoutes.js`](https://github.com/anuragsingh0123/cab_booking/blob/main/server/routes/authRoutes.js) (Routes), [`client/src/app/app.ts`](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.ts) (App shell)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Angular client"]
  node_client_main["Bootstrap<br/>Angular entry<br/>[main.ts]"]
  node_client_shell["App shell<br/>Angular shell<br/>[app.ts]"]
  node_client_routes["Routes<br/>Angular router<br/>[app.routes.ts]"]
  node_client_config["Config<br/>Angular providers<br/>[app.config.ts]"]
  node_client_nav["Navbar<br/>shared UI<br/>[navbar.ts]"]
  node_client_popup["Popups<br/>shared UI<br/>[popup-message.ts]"]
  node_client_auth["Auth core<br/>security services<br/>[auth-service.ts]"]
  node_client_geo["Maps & route<br/>location services"]
  node_client_booking_services["Booking services<br/>domain services<br/>[ride-service.ts]"]
  node_client_home["Home<br/>screen<br/>[home.ts]"]
  node_client_login["Login<br/>screen<br/>[login.ts]"]
  node_client_signup["Sign up<br/>screen<br/>[user-signup.ts]"]
  node_client_booking_flow["Ride flow<br/>screen flow<br/>[ride-request.ts]"]
  node_client_trip_views["Trips & profile<br/>screen group<br/>[my-trips.ts]"]
  node_client_driver_dash["Driver dashboard<br/>screen"]
  node_client_map["Map<br/>screen<br/>[map.ts]"]
  node_client_about["About<br/>screen<br/>[about.ts]"]
  node_client_notfound["Not found<br/>fallback screen<br/>[not-found.ts]"]
end

subgraph group_server["Express server"]
  node_server_app["API app<br/>Express entry<br/>[app.js]"]
  node_server_db["DB connect<br/>database config<br/>[connectDB.js]"]
  node_server_authmw["Auth middleware<br/>Express middleware<br/>[authMiddleware.js]"]
  node_server_routes["Routes<br/>[authRoutes.js]"]
  node_server_ctrl["Controllers<br/>[authController.js]"]
  node_server_models[("Models<br/>[user.js]")]
end

node_client_main -->|"bootstraps"| node_client_shell
node_client_shell -->|"navigates"| node_client_routes
node_client_shell -->|"renders"| node_client_nav
node_client_shell -->|"renders"| node_client_popup
node_client_config -->|"provides"| node_client_auth
node_client_routes -->|"maps"| node_client_home
node_client_routes -->|"maps"| node_client_login
node_client_routes -->|"maps"| node_client_signup
node_client_routes -->|"maps"| node_client_booking_flow
node_client_routes -->|"maps"| node_client_trip_views
node_client_routes -->|"maps"| node_client_driver_dash
node_client_routes -->|"maps"| node_client_map
node_client_routes -->|"maps"| node_client_about
node_client_routes -->|"fallback"| node_client_notfound
node_client_booking_flow -->|"uses"| node_client_booking_services
node_client_booking_flow -->|"uses"| node_client_geo
node_client_map -->|"uses"| node_client_geo
node_client_auth -->|"protects"| node_client_login
node_client_auth -->|"protects"| node_client_trip_views
node_client_auth -->|"protects"| node_client_driver_dash
node_client_booking_services -->|"calls APIs"| node_server_routes
node_client_auth -->|"sends auth"| node_server_routes
node_server_app -->|"connects"| node_server_db
node_server_app -->|"uses"| node_server_authmw
node_server_app -->|"mounts"| node_server_routes
node_server_routes -->|"dispatches"| node_server_ctrl
node_server_ctrl -->|"persists"| node_server_models
node_server_authmw -->|"guards"| node_server_routes

click node_client_main "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/main.ts"
click node_client_shell "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.ts"
click node_client_routes "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.routes.ts"
click node_client_config "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.config.ts"
click node_client_nav "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/navbar/navbar.ts"
click node_client_popup "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/popup-message/popup-message.ts"
click node_client_auth "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/auth-service.ts"
click node_client_geo "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/location-service.ts"
click node_client_booking_services "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/ride-service.ts"
click node_client_home "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/home/home.ts"
click node_client_login "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/login/login.ts"
click node_client_signup "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/user-signup/user-signup.ts"
click node_client_booking_flow "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/ride-request/ride-request.ts"
click node_client_trip_views "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/my-trips/my-trips.ts"
click node_client_driver_dash "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/driver-dashboard/driver-dashboard.ts"
click node_client_map "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/map/map.ts"
click node_client_about "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/about/about.ts"
click node_client_notfound "https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/not-found/not-found.ts"
click node_server_app "https://github.com/anuragsingh0123/cab_booking/blob/main/server/app.js"
click node_server_db "https://github.com/anuragsingh0123/cab_booking/blob/main/server/config/connectDB.js"
click node_server_authmw "https://github.com/anuragsingh0123/cab_booking/blob/main/server/middleware/authMiddleware.js"
click node_server_routes "https://github.com/anuragsingh0123/cab_booking/blob/main/server/routes/authRoutes.js"
click node_server_ctrl "https://github.com/anuragsingh0123/cab_booking/blob/main/server/controllers/authController.js"
click node_server_models "https://github.com/anuragsingh0123/cab_booking/blob/main/server/models/user.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_client_main,node_client_shell,node_client_routes,node_client_config,node_client_nav,node_client_popup,node_client_auth,node_client_geo,node_client_booking_services,node_client_home,node_client_login,node_client_signup,node_client_booking_flow,node_client_trip_views,node_client_driver_dash,node_client_map,node_client_about,node_client_notfound toneBlue
class node_server_app,node_server_db,node_server_authmw,node_server_routes,node_server_ctrl,node_server_models toneAmber
```

## Components

### Angular client

Route-driven cab booking frontend with shared services and cross-cutting auth/map concerns.

- [Bootstrap](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/main.ts): Angular entry · Starts the Angular app from the root bootstrap file. · `client/src/main.ts`
- [App shell](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.ts): Angular shell · Root application component and top-level layout. · `client/src/app/app.ts`
- [Routes](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.routes.ts): Angular router · Primary navigation and screen boundaries for the client. · `client/src/app/app.routes.ts`
- [Config](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/app.config.ts): Angular providers · Global application providers and runtime wiring. · `client/src/app/app.config.ts`
- [Navbar](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/navbar/navbar.ts): shared UI · Shared navigation component used across screens. · `client/src/app/navbar/navbar.ts`
- [Popups](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/popup-message/popup-message.ts): shared UI · Transient user feedback component for messages and alerts. · `client/src/app/popup-message/popup-message.ts`
- [Auth core](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/auth-service.ts): security services · Authentication service, route guard, and HTTP interceptor for protected flows. · `client/src/app/auth-service.ts`
- [Maps & route](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/location-service.ts): location services · Location, map rendering, and route-building services for booking flows. · `client/src/app/location-service.ts`
- [Booking services](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/ride-service.ts): domain services · Ride and driver service layer used by booking and dashboard screens. · `client/src/app/ride-service.ts`
- [Home](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/home/home.ts): screen · Landing and entry screen for the app. · `client/src/app/home/home.ts`
- [Login](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/login/login.ts): screen · User sign-in screen. · `client/src/app/login/login.ts`
- [Sign up](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/user-signup/user-signup.ts): screen · Passenger and driver registration screens. · `client/src/app/user-signup/user-signup.ts`
- [Ride flow](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/ride-request/ride-request.ts): screen flow · Ride request, vehicle selection, checkout, and ride success journey. · `client/src/app/ride-request/ride-request.ts`
- [Trips & profile](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/my-trips/my-trips.ts): screen group · My trips and profile screens for authenticated users. · `client/src/app/my-trips/my-trips.ts`
- [Driver dashboard](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/driver-dashboard/driver-dashboard.ts): screen · Driver-facing operational dashboard. · `client/src/app/driver-dashboard/driver-dashboard.ts`
- [Map](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/map/map.ts): screen · Map screen for location-aware booking context. · `client/src/app/map/map.ts`
- [About](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/about/about.ts): screen · Informational page. · `client/src/app/about/about.ts`
- [Not found](https://github.com/anuragsingh0123/cab_booking/blob/main/client/src/app/not-found/not-found.ts): fallback screen · Fallback route for unknown navigation paths. · `client/src/app/not-found/not-found.ts`

### Express server

REST API backend with controllers, middleware, models, and database connection.

- [API app](https://github.com/anuragsingh0123/cab_booking/blob/main/server/app.js): Express entry · Server bootstrap that mounts middleware, routes, and database wiring. · `server/app.js`
- [DB connect](https://github.com/anuragsingh0123/cab_booking/blob/main/server/config/connectDB.js): database config · Central database connection setup. · `server/config/connectDB.js`
- [Auth middleware](https://github.com/anuragsingh0123/cab_booking/blob/main/server/middleware/authMiddleware.js): Express middleware · Server-side protection for authenticated endpoints. · `server/middleware/authMiddleware.js`
- [Routes](https://github.com/anuragsingh0123/cab_booking/blob/main/server/routes/authRoutes.js): Express routes · Domain route layer for auth, users, drivers, rides, and reviews. · `server/routes/authRoutes.js`
- [Controllers](https://github.com/anuragsingh0123/cab_booking/blob/main/server/controllers/authController.js): Express controllers · Request handlers for auth, user, driver, ride, and review domains. · `server/controllers/authController.js`
- [Models](https://github.com/anuragsingh0123/cab_booking/blob/main/server/models/user.js): data models · Persistent domain models for users, drivers, bookings, and reviews. · `server/models/user.js`

## Connections

- Bootstrap → App shell: bootstraps · Angular entry initializes the root app.
- App shell → Routes: navigates · Root shell is driven by route configuration.
- App shell → Navbar: renders · Shared navigation is part of the app shell.
- App shell → Popups: renders · Popup feedback is available globally.
- Config → Auth core: provides · Global providers enable auth-related HTTP and route behavior.
- Routes → Home: maps · Route table exposes the home screen.
- Routes → Login: maps · Route table exposes login.
- Routes → Sign up: maps · Route table exposes signup flows.
- Routes → Ride flow: maps · Route table exposes the ride booking journey.
- Routes → Trips & profile: maps · Route table exposes authenticated trip/profile views.
- Routes → Driver dashboard: maps · Route table exposes driver operations.
- Routes → Map: maps · Route table exposes map-centric screen.
- Routes → About: maps · Route table exposes about page.
- Routes → Not found: fallback · Unknown paths fall through to the not-found screen.
- Ride flow → Booking services: uses · Booking screens call domain services for ride and driver operations.
- Ride flow → Maps & route: uses · Booking journey depends on location and route construction.
- Map → Maps & route: uses · Map screen depends on geospatial services.
- Auth core → Login: protects · Guarded and intercepted auth flows center on login/session state.
- Auth core → Trips & profile: protects · Authenticated user views are gated by auth logic.
- Auth core → Driver dashboard: protects · Driver dashboard access is restricted.
- Booking services → Routes: calls APIs · Client domain services communicate with backend endpoints.
- Auth core → Routes: sends auth · Interceptor attaches credentials to API requests.
- API app → DB connect: connects · Server bootstraps database connectivity.
- API app → Auth middleware: uses · Server installs authentication middleware.
- API app → Routes: mounts · Server mounts domain route handlers.
- Routes → Controllers: dispatches · Routes forward requests to controllers.
- Controllers → Models: persists · Controllers operate on domain models.
- Auth middleware → Routes: guards · Middleware protects selected API routes.
