How muhammadumar7195/car-rental-crm works
1. Overall shape
Astro Motors is a two-tier full-stack CRM for car rental operations: a React/Vite frontend in client/ and an Express/MongoDB backend in server/. Docker Compose is the primary local deployment path, with separate containers for UI and API.
2. Frontend boundary
The client is a single-page application built with React 19 and Vite. src/main.jsx and src/App.jsx act as the composition root, while src/Routes/ProtectedRoute.jsx and the layout components enforce authenticated navigation and dashboard framing.
3. Feature-oriented UI
The UI is organized by business domain under src/Pages/: Home, Rental, Fleet, Customer, Inventory, POS, Accounting, Workshop, Contacts, and Payment. This makes the frontend diagram easier to draw as a set of business workflows rather than generic screens.
4. State and data orchestration
Redux Toolkit under src/store/Slices/ holds domain state for accounting, auth, customer, fleet, inventory, rental, service, and walk-in service. The pages and hooks consume this shared state to coordinate list/detail views, forms, and multi-step flows like rentals and service visits.
5. Frontend support layers
The components/ folder provides shared UI primitives and shell components: common navbar/footer/dialogs, dashboard sidebar/layout, auth forms, and a reusable UI kit. Custom hooks such as useAvailableCars, useCarImageUpload, and useSearchRentalDateFilter encapsulate cross-page logic for availability, uploads, and filtering.
6. Primary business workflows
The key operational paths are rental processing, fleet lifecycle management, customer CRM, inventory management, POS/service transactions, and workshop scheduling. Several pages are clearly workflow-specific, such as RentalFlow, RentalInvoice, FleetServiceHistory, InventoryAddForm, WalkInServiceHistory, and AccountingCart.
7. Backend layering
The server follows a classic Express architecture: Routes/ define HTTP endpoints, Controller/ contains request handling, Model/ defines Mongoose schemas, Middleware/ handles cross-cutting concerns, and Utils/ holds shared integrations and helpers. This separation is the main server-side architectural boundary.
8. Backend domains and persistence
The backend models mirror the frontend business areas: users/admins, customers, fleets, inventory, rentals, accounting, services, walk-in services, contact forms, and workshop appointments. MongoDB is the system of record, with Mongoose used to connect requests to collections and enforce domain structure.
9. Security and access control
Authentication is JWT-based, with authMiddleware.js protecting privileged routes. The README also indicates security hardening through Helmet, rate limiting, and Mongo sanitization, so the API boundary is designed to reject unsafe or unauthenticated requests before they reach controllers.
10. External integrations
File uploads flow through Multer and then to Cloudinary for image hosting, which is important for fleet/inventory media. Email notifications are handled via Nodemailer, and node-cron supports scheduled background tasks. These integrations sit in Utils/ and are consumed by controllers rather than by the UI directly.
11. Operational support
Logging and error handling are centralized with a custom logger, error.js middleware, and Utils/ErrorHandler.js. The README notes log rotation and persistent server logs, so observability is treated as a backend platform concern rather than a frontend concern.
12. Deployment and runtime boundaries
The app is built for local development with separate client/server processes and environment-specific URLs for CORS/CSP. server/vercel.json suggests the API can also be deployed as a serverless or edge-hosted backend, while client/public/_redirects indicates SPA routing support in static hosting.
Main entry points: App.jsx Client app · Routes HTTP routes · app.js API app · Pages Business pages
Components 20
Client
React/Vite SPA for CRM workflows
- Client app · Frontend composition root
client/src/App.jsx - Bootstrapping · Vite/React entry point
client/src/main.jsx - Protected nav · Authenticated routing boundary
client/src/Routes/ProtectedRoute.jsx - Dashboard shell · Shared dashboard framing and navigation
client/src/components/Layouts/DashboardLayout.jsx - Auth UI · Login, register, and password recovery
client/src/components/auth/Login.jsx - Business pages · Domain workflows: rental, fleet, customer, inventory, POS, accounting, workshop, contacts, payment
client/src/Pages - UI hooks · Cross-page availability, upload, filtering, and data fetch helpers
client/src/hooks/useAvailableCars.jsx - Redux store · Shared client state composition
client/src/store/index.js - Domain slices · Auth, customer, fleet, inventory, rental, service, accounting, walk-in service state
client/src/store/Slices/auth.slice.js
Server
Express/Mongo API and integrations
- API app · Server composition root
server/app.js - HTTP routes · Endpoint definitions by domain
server/Routes - Controllers · Business request handling
server/Controller - Mongoose models · Domain schemas for CRM records
server/Model - Middleware · Auth, error handling, and request safety
server/Middleware/authMiddleware.js - Integrations · Cloudinary, Multer, Nodemailer, logger, and cron helpers
server/Utils/cloudinary.js - Mongo connect · Mongoose connection setup
server/Config/connect.js - Seed data · Initial data loading
server/seed.js
Deployment
Container and hosting boundaries
- Compose · Local multi-container runtime
docker-compose.yml - Serverless config · Alternative API deployment target
server/vercel.json - SPA redirects · Static host routing support
client/public/_redirects
Connections 21
- Compose → Client app: runs · Starts the frontend container
- Compose → API app: runs · Starts the API container
- Bootstrapping → Client app: boots · Entry point mounts the React application
- Client app → Protected nav: uses · App composition applies route protection
- Client app → Dashboard shell: frames · Dashboard layout wraps business pages
- Client app → Auth UI: renders · Auth screens are part of the UI shell
- Client app → Business pages: hosts · Feature pages implement business workflows
- Business pages → UI hooks: consumes · Pages reuse shared workflow hooks
- Business pages → Redux store: reads/writes · Pages coordinate through shared state
- Redux store → Domain slices: composed of · Store combines domain slices
- UI hooks → HTTP routes: calls API · Hooks fetch and submit server data
- Protected nav → HTTP routes: guards · Protected client flows depend on authenticated API access
- API app → HTTP routes: mounts · Express app registers route modules
- HTTP routes → Middleware: protects · Routes are guarded by middleware where needed
- HTTP routes → Controllers: dispatches · Endpoints delegate to controllers
- Controllers → Mongoose models: persists via · Controllers read and write Mongo documents
- Controllers → Integrations: uses · Controllers call external integrations and helpers
- API app → Mongo connect: connects · Server initializes MongoDB connection
- Seed data → Mongoose models: populates · Seed script creates initial records
- Serverless config → API app: deploys · Alternative runtime packaging for the API
- SPA redirects → Client app: supports · Static hosting fallback routes to SPA entry