# muhammadumar7195/car-rental-crm architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadumar7195/car-rental-crm
- Repository: https://github.com/muhammadumar7195/car-rental-crm

## Overview

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: [`client/src/App.jsx`](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/App.jsx) (Client app), [`server/Routes`](https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Routes) (HTTP routes), [`server/app.js`](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/app.js) (API app), [`client/src/Pages`](https://github.com/muhammadumar7195/car-rental-crm/tree/main/client/src/Pages) (Business pages)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Client"]
  node_client_app["Client app<br/>react spa<br/>[App.jsx]"]
  node_client_main["Bootstrapping<br/>react entry<br/>[main.jsx]"]
  node_client_routes{{"Protected nav<br/>route guard<br/>[ProtectedRoute.jsx]"}}
  node_client_layout["Dashboard shell<br/>layout"]
  node_client_auth["Auth UI<br/>auth screens<br/>[Login.jsx]"]
  node_client_pages["Business pages<br/>feature pages"]
  node_client_hooks["UI hooks<br/>react hooks"]
  node_client_store[("Redux store<br/>state container<br/>[index.js]")]
  node_client_slices["Domain slices<br/>redux slices<br/>[auth.slice.js]"]
end

subgraph group_backend["Server"]
  node_server_app["API app<br/>express app<br/>[app.js]"]
  node_server_routes["HTTP routes<br/>route layer"]
  node_server_ctrl["Controllers<br/>request handlers"]
  node_server_models[("Mongoose models<br/>persistence models")]
  node_server_mw{{"Middleware<br/>cross-cutting<br/>[authMiddleware.js]"}}
  node_server_utils["Integrations<br/>utilities<br/>[cloudinary.js]"]
  node_server_db[("Mongo connect<br/>database link<br/>[connect.js]")]
  node_server_seed["Seed data<br/>bootstrap script<br/>[seed.js]"]
end

subgraph group_ops["Deployment"]
  node_docker["Compose<br/>deployment<br/>[docker-compose.yml]"]
  node_server_vercel["Serverless config<br/>deploy config<br/>[vercel.json]"]
  node_client_redirects["SPA redirects<br/>hosting config"]
end

node_docker -->|"runs"| node_client_app
node_docker -->|"runs"| node_server_app
node_client_main -->|"boots"| node_client_app
node_client_app -->|"uses"| node_client_routes
node_client_app -->|"frames"| node_client_layout
node_client_app -->|"renders"| node_client_auth
node_client_app -->|"hosts"| node_client_pages
node_client_pages -->|"consumes"| node_client_hooks
node_client_pages -->|"reads/writes"| node_client_store
node_client_store -->|"composed of"| node_client_slices
node_client_hooks -.->|"calls API"| node_server_routes
node_client_routes -.->|"guards"| node_server_routes
node_server_app -->|"mounts"| node_server_routes
node_server_routes -->|"protects"| node_server_mw
node_server_routes -->|"dispatches"| node_server_ctrl
node_server_ctrl -->|"persists via"| node_server_models
node_server_ctrl -->|"uses"| node_server_utils
node_server_app -->|"connects"| node_server_db
node_server_seed -.->|"populates"| node_server_models
node_server_vercel -.->|"deploys"| node_server_app
node_client_redirects -.->|"supports"| node_client_app

click node_docker "https://github.com/muhammadumar7195/car-rental-crm/blob/main/docker-compose.yml"
click node_client_app "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/App.jsx"
click node_client_main "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/main.jsx"
click node_client_routes "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/Routes/ProtectedRoute.jsx"
click node_client_layout "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/components/Layouts/DashboardLayout.jsx"
click node_client_auth "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/components/auth/Login.jsx"
click node_client_pages "https://github.com/muhammadumar7195/car-rental-crm/tree/main/client/src/Pages"
click node_client_hooks "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/hooks/useAvailableCars.jsx"
click node_client_store "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/store/index.js"
click node_client_slices "https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/store/Slices/auth.slice.js"
click node_server_app "https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/app.js"
click node_server_routes "https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Routes"
click node_server_ctrl "https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Controller"
click node_server_models "https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Model"
click node_server_mw "https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/Middleware/authMiddleware.js"
click node_server_utils "https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/Utils/cloudinary.js"
click node_server_db "https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/Config/connect.js"
click node_server_seed "https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/seed.js"
click node_server_vercel "https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/vercel.json"
click node_client_redirects "https://github.com/muhammadumar7195/car-rental-crm/tree/main/client/public/_redirects"

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_app,node_client_main,node_client_routes,node_client_layout,node_client_auth,node_client_pages,node_client_hooks,node_client_store,node_client_slices toneBlue
class node_server_app,node_server_routes,node_server_ctrl,node_server_models,node_server_mw,node_server_utils,node_server_db,node_server_seed toneAmber
class node_docker,node_server_vercel,node_client_redirects toneMint
```

## Components

### Client

React/Vite SPA for CRM workflows

- [Client app](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/App.jsx): react spa · Frontend composition root · `client/src/App.jsx`
- [Bootstrapping](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/main.jsx): react entry · Vite/React entry point · `client/src/main.jsx`
- [Protected nav](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/Routes/ProtectedRoute.jsx): route guard · Authenticated routing boundary · `client/src/Routes/ProtectedRoute.jsx`
- [Dashboard shell](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/components/Layouts/DashboardLayout.jsx): layout · Shared dashboard framing and navigation · `client/src/components/Layouts/DashboardLayout.jsx`
- [Auth UI](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/components/auth/Login.jsx): auth screens · Login, register, and password recovery · `client/src/components/auth/Login.jsx`
- [Business pages](https://github.com/muhammadumar7195/car-rental-crm/tree/main/client/src/Pages): feature pages · Domain workflows: rental, fleet, customer, inventory, POS, accounting, workshop, contacts, payment · `client/src/Pages`
- [UI hooks](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/hooks/useAvailableCars.jsx): react hooks · Cross-page availability, upload, filtering, and data fetch helpers · `client/src/hooks/useAvailableCars.jsx`
- [Redux store](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/store/index.js): state container · Shared client state composition · `client/src/store/index.js`
- [Domain slices](https://github.com/muhammadumar7195/car-rental-crm/blob/main/client/src/store/Slices/auth.slice.js): redux 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](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/app.js): express app · Server composition root · `server/app.js`
- [HTTP routes](https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Routes): route layer · Endpoint definitions by domain · `server/Routes`
- [Controllers](https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Controller): request handlers · Business request handling · `server/Controller`
- [Mongoose models](https://github.com/muhammadumar7195/car-rental-crm/tree/main/server/Model): persistence models · Domain schemas for CRM records · `server/Model`
- [Middleware](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/Middleware/authMiddleware.js): cross-cutting · Auth, error handling, and request safety · `server/Middleware/authMiddleware.js`
- [Integrations](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/Utils/cloudinary.js): utilities · Cloudinary, Multer, Nodemailer, logger, and cron helpers · `server/Utils/cloudinary.js`
- [Mongo connect](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/Config/connect.js): database link · Mongoose connection setup · `server/Config/connect.js`
- [Seed data](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/seed.js): bootstrap script · Initial data loading · `server/seed.js`

### Deployment

Container and hosting boundaries

- [Compose](https://github.com/muhammadumar7195/car-rental-crm/blob/main/docker-compose.yml): deployment · Local multi-container runtime · `docker-compose.yml`
- [Serverless config](https://github.com/muhammadumar7195/car-rental-crm/blob/main/server/vercel.json): deploy config · Alternative API deployment target · `server/vercel.json`
- [SPA redirects](https://github.com/muhammadumar7195/car-rental-crm/tree/main/client/public/_redirects): hosting config · Static host routing support · `client/public/_redirects`

## Connections

- 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
