# santhosh-svss2018/passage architecture

> Architecture diagram of the GitHub repository santhosh-svss2018/passage, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/santhosh-svss2018/passage
- Repository: https://github.com/santhosh-svss2018/passage

## Overview

#### Purpose and entry points
Passage is a full-stack rental marketplace for foreign tenants in India, covering property discovery, bookings, payments, identity documents, and role-specific operations. The local Express entry point is `server.js`; static SPA assets are served from `public/index.html`. Serverless deployment wraps the backend at `netlify/functions/server.js`.

#### Application shell and client flow
The browser app is a React SPA rooted in `public/js/App.jsx`, with shared API access in `public/js/api.js`. Navigation exposes public search/detail pages and authenticated tenant, owner, and admin workspaces. Key booking UI stages span `public/js/pages/SearchPage.jsx`, `public/js/pages/PropertyDetailPage.jsx`, `public/js/pages/BookingPage.jsx`, and `public/js/pages/PaymentPage.jsx`.

#### API boundary, identity, and roles
Express routes in `routes/` form the backend boundary for the SPA. Authentication issues/consumes JWTs and enforces tenant, owner, and admin permissions through `routes/authRoutes.js` and `middleware/authMiddleware.js`. Upload handling is isolated in `middleware/uploadMiddleware.js`; document access and verification workflows are exposed through `routes/documentRoutes.js` and admin APIs.

#### Core rental domain
Mongo/Mongoose models represent the durable marketplace state: users, listings, availability, booking lifecycle, payments, reviews, inquiries, wishlists, and audit/notification records. Primary booking control flow is property selection → availability/double-booking validation → booking creation → payment record/status updates. Architectural anchors include `models/Property.js`, `models/Availability.js`, `models/Booking.js`, `routes/propertyRoutes.js`, and `routes/bookingRoutes.js`.

#### Payments, currency, and compliance
Payment routes support Razorpay and Stripe-oriented integration with a mock/test fallback; transaction data is stored separately from bookings in `models/Payment.js` and exposed by `routes/paymentRoutes.js`. INR is the base pricing model with conversion rates held in `models/CurrencyRate.js` and served by `routes/currencyRoutes.js`. Passport/visa metadata and verification status are managed through `models/Document.js`, supporting an admin review queue.

#### Operations and role workspaces
Owners manage listings, availability blocks, and booking requests through property, availability, and booking APIs. Admins operate platform metrics, moderation/approval queues, user controls, and document verification via `routes/adminRoutes.js`. Corresponding client boundaries are `public/js/pages/OwnerDashboard.jsx` and `public/js/pages/AdminDashboard.jsx`.

#### AI and deployment/runtime
The relocation assistant calls backend AI endpoints, intended for Gemini/OpenAI with a rule-based fallback: `public/js/aiChatbot.js`, `public/js/components/AIAssistantModal.jsx`, and `routes/aiRoutes.js`. Runtime is Node.js/Express with MongoDB; `config/db.js` provides a MongoDB Memory Server fallback. Seeded demo data enters through `seed.js`. Deployment targets include container/process hosting (`Dockerfile`, `Procfile`, `render.yaml`) and Netlify serverless/static hosting (`netlify.toml`, `netlify/functions/server.js`).

Main entry points: [`server.js`](https://github.com/santhosh-svss2018/passage/blob/main/server.js) (Express application), [`public/js/App.jsx`](https://github.com/santhosh-svss2018/passage/blob/main/public/js/App.jsx) (React application shell), [`public/js/pages/OwnerDashboard.jsx`](https://github.com/santhosh-svss2018/passage/blob/main/public/js/pages/OwnerDashboard.jsx) (Owner & admin workspaces), [`routes/paymentRoutes.js`](https://github.com/santhosh-svss2018/passage/blob/main/routes/paymentRoutes.js) (Payment APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React SPA"]
  node_browser(("Browser<br/>user client"))
  node_spa["React application shell<br/>React SPA<br/>[App.jsx]"]
  node_api_client["API client<br/>client integration<br/>[api.js]"]
  node_booking_ui["Search, detail &amp; booking flow<br/>booking UI<br/>[SearchPage.jsx]"]
  node_role_workspaces["Owner &amp; admin workspaces<br/>role UI<br/>[OwnerDashboard.jsx]"]
  node_ai_assistant["Relocation assistant<br/>AI UI<br/>[aiChatbot.js]"]
end

subgraph group_api["Express API"]
  node_express["Express application<br/>API runtime<br/>[server.js]"]
  node_auth["JWT auth &amp; role guard<br/>identity middleware<br/>[authMiddleware.js]"]
  node_rental_routes["Property &amp; booking APIs<br/>route layer<br/>[bookingRoutes.js]"]
  node_payment_routes["Payment APIs<br/>route layer<br/>[paymentRoutes.js]"]
  node_document_admin_routes["Document &amp; admin APIs<br/>route layer<br/>[documentRoutes.js]"]
  node_ai_routes["AI APIs<br/>route layer<br/>[aiRoutes.js]"]
end

subgraph group_domain["Marketplace Data"]
  node_marketplace_models[("Listings, availability &amp; bookings<br/>Mongoose models<br/>[Booking.js]")]
  node_payment_models[("Payment records<br/>Mongoose model<br/>[Payment.js]")]
  node_compliance_models[("Documents &amp; currency rates<br/>Mongoose models<br/>[Document.js]")]
end

subgraph group_runtime["Runtime &amp; Deployment"]
  node_mongodb[("MongoDB<br/>database<br/>[db.js]")]
  node_netlify{{"Netlify serverless entry<br/>serverless adapter<br/>[server.js]"}}
  node_static_assets["Static SPA entry<br/>HTML asset<br/>[index.html]"]
end

node_payment_providers{{"Razorpay, Stripe &amp; mock<br/>payment providers"}}

node_browser -->|"loads"| node_static_assets
node_static_assets -->|"boots"| node_spa
node_spa -->|"navigates to"| node_booking_ui
node_spa -->|"role-based navigation"| node_role_workspaces
node_spa -->|"opens"| node_ai_assistant
node_spa -->|"uses"| node_api_client
node_api_client -->|"HTTP requests"| node_express
node_netlify -->|"wraps"| node_express
node_express -->|"protects routes with"| node_auth
node_express -->|"serves"| node_rental_routes
node_express -->|"serves"| node_payment_routes
node_express -->|"serves"| node_document_admin_routes
node_express -->|"serves"| node_ai_routes
node_rental_routes -->|"validates and persists"| node_marketplace_models
node_payment_routes -->|"records status"| node_payment_models
node_payment_routes -->|"charges via"| node_payment_providers
node_document_admin_routes -->|"reviews and serves"| node_compliance_models
node_ai_assistant -->|"assistant requests"| node_ai_routes
node_marketplace_models -->|"persists in"| node_mongodb
node_payment_models -->|"persists in"| node_mongodb
node_compliance_models -->|"persists in"| node_mongodb
node_role_workspaces -->|"manages marketplace"| node_rental_routes
node_role_workspaces -->|"operates review queues"| node_document_admin_routes

click node_spa "https://github.com/santhosh-svss2018/passage/blob/main/public/js/App.jsx"
click node_api_client "https://github.com/santhosh-svss2018/passage/blob/main/public/js/api.js"
click node_booking_ui "https://github.com/santhosh-svss2018/passage/blob/main/public/js/pages/SearchPage.jsx"
click node_role_workspaces "https://github.com/santhosh-svss2018/passage/blob/main/public/js/pages/OwnerDashboard.jsx"
click node_ai_assistant "https://github.com/santhosh-svss2018/passage/blob/main/public/js/aiChatbot.js"
click node_express "https://github.com/santhosh-svss2018/passage/blob/main/server.js"
click node_auth "https://github.com/santhosh-svss2018/passage/blob/main/middleware/authMiddleware.js"
click node_rental_routes "https://github.com/santhosh-svss2018/passage/blob/main/routes/bookingRoutes.js"
click node_payment_routes "https://github.com/santhosh-svss2018/passage/blob/main/routes/paymentRoutes.js"
click node_document_admin_routes "https://github.com/santhosh-svss2018/passage/blob/main/routes/documentRoutes.js"
click node_ai_routes "https://github.com/santhosh-svss2018/passage/blob/main/routes/aiRoutes.js"
click node_marketplace_models "https://github.com/santhosh-svss2018/passage/blob/main/models/Booking.js"
click node_payment_models "https://github.com/santhosh-svss2018/passage/blob/main/models/Payment.js"
click node_compliance_models "https://github.com/santhosh-svss2018/passage/blob/main/models/Document.js"
click node_mongodb "https://github.com/santhosh-svss2018/passage/blob/main/config/db.js"
click node_netlify "https://github.com/santhosh-svss2018/passage/blob/main/netlify/functions/server.js"
click node_static_assets "https://github.com/santhosh-svss2018/passage/blob/main/public/index.html"

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_browser,node_spa,node_api_client,node_booking_ui,node_role_workspaces,node_ai_assistant toneBlue
class node_express,node_auth,node_rental_routes,node_payment_routes,node_document_admin_routes,node_ai_routes toneAmber
class node_marketplace_models,node_payment_models,node_compliance_models toneMint
class node_mongodb,node_netlify,node_static_assets toneRose
class node_payment_providers toneNeutral
```

## Components

### React SPA

- **Browser**: user client
- [React application shell](https://github.com/santhosh-svss2018/passage/blob/main/public/js/App.jsx): React SPA · `public/js/App.jsx`
- [API client](https://github.com/santhosh-svss2018/passage/blob/main/public/js/api.js): client integration · `public/js/api.js`
- [Search, detail & booking flow](https://github.com/santhosh-svss2018/passage/blob/main/public/js/pages/SearchPage.jsx): booking UI · Search through payment screens drive rental reservations. · `public/js/pages/SearchPage.jsx`
- [Owner & admin workspaces](https://github.com/santhosh-svss2018/passage/blob/main/public/js/pages/OwnerDashboard.jsx): role UI · `public/js/pages/OwnerDashboard.jsx`
- [Relocation assistant](https://github.com/santhosh-svss2018/passage/blob/main/public/js/aiChatbot.js): AI UI · `public/js/aiChatbot.js`

### Express API

- [Express application](https://github.com/santhosh-svss2018/passage/blob/main/server.js): API runtime · `server.js`
- [JWT auth & role guard](https://github.com/santhosh-svss2018/passage/blob/main/middleware/authMiddleware.js): identity middleware · Authenticates users and enforces tenant, owner, and admin access. · `middleware/authMiddleware.js`
- [Property & booking APIs](https://github.com/santhosh-svss2018/passage/blob/main/routes/bookingRoutes.js): route layer · `routes/bookingRoutes.js`
- [Payment APIs](https://github.com/santhosh-svss2018/passage/blob/main/routes/paymentRoutes.js): route layer · `routes/paymentRoutes.js`
- [Document & admin APIs](https://github.com/santhosh-svss2018/passage/blob/main/routes/documentRoutes.js): route layer · `routes/documentRoutes.js`
- [AI APIs](https://github.com/santhosh-svss2018/passage/blob/main/routes/aiRoutes.js): route layer · Uses Gemini/OpenAI when available, with rule-based fallback. · `routes/aiRoutes.js`

### Marketplace Data

- [Listings, availability & bookings](https://github.com/santhosh-svss2018/passage/blob/main/models/Booking.js): Mongoose models · Availability validation prevents double booking before booking creation. · `models/Booking.js`
- [Payment records](https://github.com/santhosh-svss2018/passage/blob/main/models/Payment.js): Mongoose model · Transactions are stored separately from bookings. · `models/Payment.js`
- [Documents & currency rates](https://github.com/santhosh-svss2018/passage/blob/main/models/Document.js): Mongoose models · Holds verification metadata and INR conversion rates. · `models/Document.js`

### Runtime & Deployment

- [MongoDB](https://github.com/santhosh-svss2018/passage/blob/main/config/db.js): database · Memory Server fallback is configured for local runtime. · `config/db.js`
- [Netlify serverless entry](https://github.com/santhosh-svss2018/passage/blob/main/netlify/functions/server.js): serverless adapter · `netlify/functions/server.js`
- [Static SPA entry](https://github.com/santhosh-svss2018/passage/blob/main/public/index.html): HTML asset · `public/index.html`

### Other components

- **Razorpay, Stripe & mock**: payment providers

## Connections

- Browser → Static SPA entry: loads
- Static SPA entry → React application shell: boots
- React application shell → Search, detail & booking flow: navigates to
- React application shell → Owner & admin workspaces: role-based navigation
- React application shell → Relocation assistant: opens
- React application shell → API client: uses
- API client → Express application: HTTP requests
- Netlify serverless entry → Express application: wraps
- Express application → JWT auth & role guard: protects routes with
- Express application → Property & booking APIs: serves
- Express application → Payment APIs: serves
- Express application → Document & admin APIs: serves
- Express application → AI APIs: serves
- Property & booking APIs → Listings, availability & bookings: validates and persists
- Payment APIs → Payment records: records status
- Payment APIs → Razorpay, Stripe & mock: charges via
- Document & admin APIs → Documents & currency rates: reviews and serves
- Relocation assistant → AI APIs: assistant requests
- Listings, availability & bookings → MongoDB: persists in
- Payment records → MongoDB: persists in
- Documents & currency rates → MongoDB: persists in
- Owner & admin workspaces → Property & booking APIs: manages marketplace
- Owner & admin workspaces → Document & admin APIs: operates review queues
