How anuragsingh0123/cab_booking works
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: app.routes.ts Routes · auth-service.ts Auth core · authRoutes.js Routes · app.ts App shell
Components 24
Angular client
Route-driven cab booking frontend with shared services and cross-cutting auth/map concerns.
- Bootstrap · Starts the Angular app from the root bootstrap file.
client/src/main.ts - App shell · Root application component and top-level layout.
client/src/app/app.ts - Routes · Primary navigation and screen boundaries for the client.
client/src/app/app.routes.ts - Config · Global application providers and runtime wiring.
client/src/app/app.config.ts - Navbar · Shared navigation component used across screens.
client/src/app/navbar/navbar.ts - Popups · Transient user feedback component for messages and alerts.
client/src/app/popup-message/popup-message.ts - Auth core · Authentication service, route guard, and HTTP interceptor for protected flows.
client/src/app/auth-service.ts - Maps & route · Location, map rendering, and route-building services for booking flows.
client/src/app/location-service.ts - Booking services · Ride and driver service layer used by booking and dashboard screens.
client/src/app/ride-service.ts - Home · Landing and entry screen for the app.
client/src/app/home/home.ts - Login · User sign-in screen.
client/src/app/login/login.ts - Sign up · Passenger and driver registration screens.
client/src/app/user-signup/user-signup.ts - Ride flow · Ride request, vehicle selection, checkout, and ride success journey.
client/src/app/ride-request/ride-request.ts - Trips & profile · My trips and profile screens for authenticated users.
client/src/app/my-trips/my-trips.ts - Driver dashboard · Driver-facing operational dashboard.
client/src/app/driver-dashboard/driver-dashboard.ts - Map · Map screen for location-aware booking context.
client/src/app/map/map.ts - About · Informational page.
client/src/app/about/about.ts - Not found · 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 · Server bootstrap that mounts middleware, routes, and database wiring.
server/app.js - DB connect · Central database connection setup.
server/config/connectDB.js - Auth middleware · Server-side protection for authenticated endpoints.
server/middleware/authMiddleware.js - Routes · Domain route layer for auth, users, drivers, rides, and reviews.
server/routes/authRoutes.js - Controllers · Request handlers for auth, user, driver, ride, and review domains.
server/controllers/authController.js - Models · Persistent domain models for users, drivers, bookings, and reviews.
server/models/user.js
Connections 28
- 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.