# mrehmanx64/munna-assignment9-server architecture

> Architecture diagram of the GitHub repository mrehmanx64/munna-assignment9-server, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrehmanx64/munna-assignment9-server
- Repository: https://github.com/mrehmanx64/munna-assignment9-server

## Overview

Rentora is an Express backend for an equipment-rental marketplace. Clients call the API; route handlers validate and authorize requests, controllers invoke domain services, and services operate on MongoDB-backed models or payment and image-hosting integrations. The documented product includes renter, fleet-owner, and administrator capabilities. Source excerpts verify key authentication, equipment, booking, and payment relationships; several other feature branches are documented or named in the tree but their internal calls were not sampled, so those links are omitted rather than inferred.

Main entry points: [`src/services/bookingService.ts`](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/bookingService.ts) (Booking lifecycle), [`src/controllers/authController.ts`](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/authController.ts) (Authentication handlers), [`src/services/authService.ts`](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/authService.ts) (Authentication logic), [`src/services/stripeService.ts`](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/stripeService.ts) (Stripe payments)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_server["Server lifecycle<br/>[server.ts]"]
  node_app["Express application<br/>[app.ts]"]
  node_routes["API routers<br/>[index.ts]"]
  node_authmw["JWT and RBAC<br/>[authMiddleware.ts]"]
  node_validators["Request validation<br/>[validateRequest.ts]"]
  node_response["Response formatting<br/>[ApiResponse.ts]"]
end

subgraph group_identity["Identity and accounts"]
  node_authctl["Authentication handlers<br/>[authController.ts]"]
  node_authsvc["Authentication logic<br/>[authService.ts]"]
  node_jwt["JWT service<br/>[jwtService.ts]"]
  node_user[("User accounts<br/>[userModel.ts]")]
end

subgraph group_market["Rental marketplace"]
  node_equipmentctl["Equipment handlers"]
  node_equipmentsvc["Equipment catalog"]
  node_equipment[("Equipment records<br/>[equipmentModel.ts]")]
  node_bookingctl["Booking handlers"]
  node_bookingsvc["Booking lifecycle<br/>[bookingService.ts]"]
  node_booking[("Booking records<br/>[bookingModel.ts]")]
  node_favorites["Favorites<br/>[favoriteService.ts]"]
  node_paymentctl["Payment handlers"]
end

subgraph group_operations["Platform operations"]
  node_analytics["Analytics"]
  node_admin["Admin operations"]
  node_owner["Owner operations"]
  node_upgrade["Role upgrades"]
end

subgraph group_platform["Persistence and integrations"]
  node_stripe["Stripe payments<br/>[stripeService.ts]"]
  node_payment[("Payment records<br/>[paymentModel.ts]")]
  node_imgbb["Image hosting<br/>[imgbbService.ts]"]
  node_mongo[("MongoDB<br/>[database.ts]")]
end

node_client(("API client"))

node_client -->|"calls API"| node_app
node_server -->|"starts"| node_app
node_app -->|"mounts routers"| node_routes
node_authctl -->|"invokes"| node_authsvc
node_authctl -->|"renews token"| node_jwt
node_authsvc -->|"issues tokens"| node_jwt
node_authmw -->|"verifies tokens"| node_jwt
node_authsvc -->|"reads and creates"| node_user
node_equipmentctl -->|"invokes"| node_equipmentsvc
node_equipmentsvc -->|"queries and updates"| node_equipment
node_bookingctl -->|"invokes"| node_bookingsvc
node_bookingsvc -->|"reads and writes"| node_booking
node_bookingsvc -->|"uses equipment"| node_equipment
node_bookingsvc -->|"coordinates payment"| node_stripe
node_stripe -->|"updates booking"| node_booking
node_stripe -->|"records payment"| node_payment
node_authctl -->|"formats responses"| node_response
node_mongo -->|"connects at startup"| node_server

click node_server "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/server.ts"
click node_app "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/app.ts"
click node_routes "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/routes/index.ts"
click node_authmw "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/middlewares/authMiddleware.ts"
click node_validators "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/validators/validateRequest.ts"
click node_response "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/utils/ApiResponse.ts"
click node_authctl "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/authController.ts"
click node_authsvc "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/authService.ts"
click node_jwt "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/jwtService.ts"
click node_user "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/userModel.ts"
click node_equipmentctl "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/equipmentController.ts"
click node_equipmentsvc "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/equipmentService.ts"
click node_equipment "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/equipmentModel.ts"
click node_bookingctl "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/bookingController.ts"
click node_bookingsvc "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/bookingService.ts"
click node_booking "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/bookingModel.ts"
click node_favorites "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/favoriteService.ts"
click node_paymentctl "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/paymentController.ts"
click node_stripe "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/stripeService.ts"
click node_payment "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/paymentModel.ts"
click node_imgbb "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/imgbbService.ts"
click node_mongo "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/config/database.ts"
click node_analytics "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/analyticsService.ts"
click node_admin "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/adminEquipmentController.ts"
click node_owner "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/ownerEquipmentController.ts"
click node_upgrade "https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/upgradeController.ts"

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_server,node_app,node_routes,node_authmw,node_validators,node_response,node_client toneBlue
class node_authctl,node_authsvc,node_jwt,node_user toneAmber
class node_equipmentctl,node_equipmentsvc,node_equipment,node_bookingctl,node_bookingsvc,node_booking,node_favorites,node_paymentctl toneMint
class node_analytics,node_admin,node_owner,node_upgrade toneRose
class node_stripe,node_payment,node_imgbb,node_mongo toneIndigo
```

## Components

### API and access

- [Server lifecycle](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/server.ts): `src/server.ts`
- [Express application](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/app.ts): `src/app.ts`
- [API routers](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/routes/index.ts): `src/routes/index.ts`
- [JWT and RBAC](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/middlewares/authMiddleware.ts): `src/middlewares/authMiddleware.ts`
- [Request validation](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/validators/validateRequest.ts): `src/validators/validateRequest.ts`
- [Response formatting](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/utils/ApiResponse.ts): `src/utils/ApiResponse.ts`

### Identity and accounts

- [Authentication handlers](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/authController.ts): `src/controllers/authController.ts`
- [Authentication logic](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/authService.ts): `src/services/authService.ts`
- [JWT service](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/jwtService.ts): `src/services/jwtService.ts`
- [User accounts](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/userModel.ts): `src/models/userModel.ts`

### Rental marketplace

- [Equipment handlers](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/equipmentController.ts): `src/controllers/equipmentController.ts`
- [Equipment catalog](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/equipmentService.ts): `src/services/equipmentService.ts`
- [Equipment records](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/equipmentModel.ts): `src/models/equipmentModel.ts`
- [Booking handlers](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/bookingController.ts): `src/controllers/bookingController.ts`
- [Booking lifecycle](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/bookingService.ts): `src/services/bookingService.ts`
- [Booking records](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/bookingModel.ts): `src/models/bookingModel.ts`
- [Favorites](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/favoriteService.ts): `src/services/favoriteService.ts`
- [Payment handlers](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/paymentController.ts): `src/controllers/paymentController.ts`

### Platform operations

- [Analytics](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/analyticsService.ts): `src/services/analyticsService.ts`
- [Admin operations](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/adminEquipmentController.ts): `src/controllers/adminEquipmentController.ts`
- [Owner operations](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/ownerEquipmentController.ts): `src/controllers/ownerEquipmentController.ts`
- [Role upgrades](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/controllers/upgradeController.ts): `src/controllers/upgradeController.ts`

### Persistence and integrations

- [Stripe payments](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/stripeService.ts): `src/services/stripeService.ts`
- [Payment records](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/models/paymentModel.ts): `src/models/paymentModel.ts`
- [Image hosting](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/services/imgbbService.ts): `src/services/imgbbService.ts`
- [MongoDB](https://github.com/mrehmanx64/munna-assignment9-server/blob/main/src/config/database.ts): `src/config/database.ts`

### Other components

- **API client**

## Connections

- API client → Express application: calls API (evidence: `src/app.ts`)
- Server lifecycle → Express application: starts (evidence: `src/server.ts`)
- Express application → API routers: mounts routers (evidence: `src/app.ts`)
- Authentication handlers → Authentication logic: invokes (evidence: `src/controllers/authController.ts`)
- Authentication handlers → JWT service: renews token (evidence: `src/controllers/authController.ts`)
- Authentication logic → JWT service: issues tokens (evidence: `src/services/authService.ts`)
- JWT and RBAC → JWT service: verifies tokens (evidence: `src/middlewares/authMiddleware.ts`)
- Authentication logic → User accounts: reads and creates (evidence: `src/services/authService.ts`)
- Equipment handlers → Equipment catalog: invokes
- Equipment catalog → Equipment records: queries and updates (evidence: `src/services/equipmentService.ts`)
- Booking handlers → Booking lifecycle: invokes (evidence: `src/controllers/bookingController.ts`)
- Booking lifecycle → Booking records: reads and writes (evidence: `src/services/bookingService.ts`)
- Booking lifecycle → Equipment records: uses equipment (evidence: `src/services/bookingService.ts`)
- Booking lifecycle → Stripe payments: coordinates payment (evidence: `src/services/bookingService.ts`)
- Stripe payments → Booking records: updates booking (evidence: `src/services/stripeService.ts`)
- Stripe payments → Payment records: records payment (evidence: `src/services/stripeService.ts`)
- Authentication handlers → Response formatting: formats responses (evidence: `src/controllers/authController.ts`)
- MongoDB → Server lifecycle: connects at startup (evidence: `src/server.ts`)
