How aelassas/bookcars works
Purpose and Topology
BookCars is a multi-channel car-rental platform: customer web app, supplier/admin console, and native mobile client backed by one API. It supports single- and multi-supplier operations, fleet/location management, availability search, bookings, and Stripe/PayPal checkout. The deployable units are frontend/, admin/, backend/, and mobile/; shared TypeScript packages live in packages/.
Entrypoints and Runtime Boundaries
• The Node/TypeScript API boots from backend/src/index.ts, with Express application composition in backend/src/app.ts.
• Customer and admin web clients are Vite React SPAs entered through frontend/src/main.tsx / frontend/src/App.tsx and admin/src/main.tsx / admin/src/App.tsx.
• The mobile client is Expo/React Native file-routed, rooted at mobile/app/_layout.tsx, with screens under mobile/app/(screens)/.
• API access is isolated in per-client service layers, e.g. frontend/src/services/axiosInstance.ts, admin/src/services/axiosInstance.ts, and mobile/services/axiosInstance.ts.
API Domain Pipeline
The backend follows a route → controller → persistence/integration structure. Feature route modules such as backend/src/routes/bookingRoutes.ts, backend/src/routes/carRoutes.ts, and backend/src/routes/userRoutes.ts expose endpoints; their controllers execute domain operations. Route behavior is parameterized by matching route configuration modules, e.g. backend/src/config/bookingRoutes.config.ts. Security and protocol boundaries are centralized in backend/src/middlewares/authJwt.ts, backend/src/middlewares/cors.ts, and backend/src/middlewares/allowedMethods.ts.
Core Rental Data Model
Mongo-style domain models define the system of record for users, suppliers, fleets, geography, and rentals: backend/src/models/User.ts, backend/src/models/Supplier.ts, backend/src/models/Car.ts, backend/src/models/Booking.ts, backend/src/models/Location.ts, and backend/src/models/DateBasedPrice.ts. Booking and car controllers are the primary boundary for availability and pricing workflows: backend/src/controllers/bookingController.ts and backend/src/controllers/carController.ts. Database lifecycle/setup and operational scripts are located in backend/src/setup/setup.ts, backend/src/setup/reset.ts, and backend/scripts/price.ts.
Customer Journey and Payments
Customer clients search locations/cars, filter availability, select a vehicle, create a booking, then complete checkout. In web, this flow centers on frontend/src/pages/Search.tsx, frontend/src/pages/Booking.tsx, and frontend/src/pages/Checkout.tsx; mobile parallels it in mobile/app/(screens)/cars.tsx, mobile/app/(screens)/booking.tsx, and mobile/app/(screens)/checkout.tsx. Payment providers are adapterized at backend/src/payment/stripe.ts and backend/src/payment/paypal.ts, exposed through backend/src/routes/stripeRoutes.ts and backend/src/routes/paypalRoutes.ts; clients call dedicated payment services such as frontend/src/services/StripeService.ts and frontend/src/services/PayPalService.ts.
Operations, Identity, and Notifications
The admin SPA manages suppliers, fleet, bookings, users, pricing, and scheduling via pages such as admin/src/pages/Bookings.tsx, admin/src/pages/Cars.tsx, and admin/src/pages/Scheduler.tsx. The scheduler is a substantial embedded subsystem rooted at admin/src/components/scheduler/SchedulerComponent.tsx, with separate state and positioning providers. Authentication/user state is held at client boundaries (admin/src/context/UserContext.tsx, frontend/src/context/UserContext.tsx, mobile/context/AuthContext.tsx) and enforced server-side by JWT middleware. Notifications are modeled and routed through backend/src/models/Notification.ts, backend/src/controllers/notificationController.ts, and backend/src/routes/notificationRoutes.ts.
Infrastructure and External Services
Docker Compose orchestrates the service deployment in docker-compose.yml and development variant docker-compose.dev.yml; each web/API unit has production and development Dockerfiles. Nginx configuration exists at __config/nginx.conf, plus SPA-specific configs. External integrations indicated by code boundaries include Stripe, PayPal, IP geolocation (backend/src/controllers/ipinfoController.ts), email (backend/src/utils/mailHelper.ts), push tokens (backend/src/models/PushToken.ts), reCAPTCHA client contexts, social login, and monitoring instrumentation (backend/src/monitoring/instrument.ts). Shared contracts/helpers/currency logic are packaged in packages/bookcars-types/index.ts, packages/bookcars-helper/index.ts, and packages/currency-converter/index.ts.
Main entry points: src/main.tsx Customer web SPA · src/main.tsx Admin SPA · index.ts Express API · bookingRoutes.ts Feature routes
Components 20
Client channels
- Customer web SPA
frontend/src/main.tsx - Search, booking & checkout · Customer rental journey screens.
frontend/src/pages/Search.tsx - Admin SPA
admin/src/main.tsx - Fleet scheduler
admin/src/components/scheduler/SchedulerComponent.tsx - Mobile client
mobile/app/_layout.tsx - Client API services · Isolate API access per client.
frontend/src/services/axiosInstance.ts - Client auth state
frontend/src/context/UserContext.tsx
Rental API
- Express API · HTTP application and server bootstrap.
backend/src/index.ts - Security middleware
backend/src/middlewares/authJwt.ts - Feature routes · Configured endpoint boundary for rental domains.
backend/src/routes/bookingRoutes.ts - Availability & booking · Car and booking workflows calculate availability and pricing.
backend/src/controllers/bookingController.ts - Rental system of record · Users, suppliers, fleet, locations, pricing, and bookings.
backend/src/models/Booking.ts - Payment endpoints
backend/src/routes/stripeRoutes.ts - Payment adapters
backend/src/payment/stripe.ts - Notifications & push tokens
backend/src/controllers/notificationController.ts
External services
- Stripe
- PayPal
Shared and deployment
- Shared TypeScript packages
packages/bookcars-types/index.ts - Container deployment · Orchestrates deployable web and API units.
docker-compose.yml - Nginx edge
__config/nginx.conf
Connections 27
- Customer web SPA → Search, booking & checkout: renders
- Customer web SPA → Client API services: uses
- Customer web SPA → Client auth state: holds session
- Admin SPA → Fleet scheduler: hosts
- Admin SPA → Client API services: uses equivalent layer
- Mobile client → Client API services: uses equivalent layer
- Mobile client → Client auth state: holds auth state
- Client API services → Express API: HTTPS API calls
- Express API → Security middleware: applies
- Security middleware → Feature routes: guards
- Feature routes → Availability & booking: dispatches
- Availability & booking → Rental system of record: reads and writes
- Feature routes → Payment endpoints: mounts
- Payment endpoints → Payment adapters: invokes
- Payment adapters → Stripe: charges via
- Payment adapters → PayPal: charges via
- Feature routes → Notifications & push tokens: routes events
- Search, booking & checkout → Payment endpoints: checkout
- Shared TypeScript packages → Customer web SPA: shared contracts
- Shared TypeScript packages → Admin SPA: shared contracts
- Shared TypeScript packages → Express API: shared contracts
- Container deployment → Express API: deploys
- Container deployment → Customer web SPA: deploys
- Container deployment → Admin SPA: deploys
- Nginx edge → Customer web SPA: serves
- Nginx edge → Admin SPA: serves
- Nginx edge → Express API: proxies