# arshad-dev57/realtor_backend architecture

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

- Interactive diagram: https://gitdiagram.com/arshad-dev57/realtor_backend
- Repository: https://github.com/arshad-dev57/realtor_backend

## Overview

This is an Express/MongoDB real-estate marketplace API. Buyers and realtors enter through API routes to authenticate, manage property listings, request tours, and use lead/contact features; dashboards, payments, subscriptions, and device/notification capabilities support those workflows. Controllers own domain operations, while Mongoose models hold the principal records and services handle email and push delivery. Several route and controller files were not excerpted, so their features are represented by supported directory paths without guessed internal call chains.

Main entry points: [`app.js`](https://github.com/arshad-dev57/realtor_backend/blob/main/app.js) (Express API), [`controllers/tour.controller.js`](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/tour.controller.js) (Tour scheduling), [`controllers/property.controller.js`](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/property.controller.js) (Property listings), [`controllers/dashboard.controller.js`](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/dashboard.controller.js) (User dashboards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_app["Express API<br/>[app.js]"]
  node_authroutes["Authentication routes<br/>[auth.routes.js]"]
  node_authguard["Authentication guard<br/>[auth.middleware.js]"]
end

subgraph group_marketplace["Marketplace workflows"]
  node_propertyroutes["Property routes<br/>[property.routes.js]"]
  node_propertyctl["Property listings"]
  node_tourroutes["Tour routes<br/>[tour.routes.js]"]
  node_tourctl["Tour scheduling<br/>[tour.controller.js]"]
  node_leads["Lead workflows<br/>[lead.controller.js]"]
  node_leadrequests["Lead requests"]
  node_dashboard["User dashboards"]
  node_admin["Admin dashboard"]
end

subgraph group_accounts["Accounts and revenue"]
  node_users[("User accounts<br/>[user.model.js]")]
  node_authctl["Authentication and profiles<br/>[auth.controller.js]"]
  node_devices["Device management"]
  node_payments["Payments"]
  node_subscriptions["Subscriptions"]
end

subgraph group_engagement["Engagement and messaging"]
  node_notifications["Notification workflows"]
  node_push["Push delivery<br/>[onesignal.js]"]
  node_email["Email delivery<br/>[email.service.js]"]
end

subgraph group_persistence["Domain records"]
  node_notificationdata[("Notification records")]
  node_propertydata[("Property records<br/>[property.model.js]")]
  node_tourdata[("Tour records<br/>[tour.model.js]")]
  node_leaddata[("Lead records<br/>[lead.model.js]")]
  node_leadrequestdata[("Lead request records")]
  node_devicedata[("Device records<br/>[device.model.js]")]
  node_blacklist[("Revoked tokens")]
  node_otpdata[("One-time codes<br/>[otp.model.js]")]
  node_paymentdata[("Payment records<br/>[payment.model.js]")]
end

node_client(("API client"))
node_cloudinary["Image storage"]
node_onesignal["OneSignal"]
node_smtp["Gmail SMTP"]

node_client -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_authroutes
node_app -->|"mounts routes"| node_propertyroutes
node_app -->|"mounts routes"| node_tourroutes
node_app -->|"mounts lead routes"| node_leads
node_app -->|"mounts request routes"| node_leadrequests
node_app -->|"mounts routes"| node_dashboard
node_authroutes -->|"dispatches to"| node_authctl
node_authroutes -->|"dispatches to"| node_subscriptions
node_authroutes -->|"protects routes"| node_authguard
node_propertyroutes -->|"dispatches to"| node_propertyctl
node_propertyroutes -->|"protects routes"| node_authguard
node_propertyroutes -->|"uploads images"| node_cloudinary
node_tourroutes -->|"dispatches to"| node_tourctl
node_tourroutes -->|"protects routes"| node_authguard
node_authguard -->|"checks tokens"| node_blacklist
node_authguard -->|"checks devices"| node_devicedata
node_authctl -->|"reads and updates"| node_users
node_authctl -->|"uses devices"| node_devicedata
node_authctl -->|"uses codes"| node_otpdata
node_propertyctl -->|"manages listings"| node_propertydata
node_propertyctl -->|"looks up users"| node_users
node_propertyctl -->|"notifies users"| node_notifications
node_propertyctl -->|"sends alerts"| node_email
node_propertyctl -->|"sends alerts"| node_push
node_tourctl -->|"manages tours"| node_tourdata
node_tourctl -->|"looks up listings"| node_propertydata
node_tourctl -->|"looks up users"| node_users
node_tourctl -->|"saves notices"| node_notificationdata
node_tourctl -->|"sends alerts"| node_push
node_tourctl -->|"sends email"| node_email
node_leads -->|"manages leads"| node_leaddata
node_leads -->|"looks up users"| node_users
node_leads -->|"calls notifications"| node_notifications
node_dashboard -->|"reads tours"| node_tourdata
node_dashboard -->|"reads listings"| node_propertydata
node_dashboard -->|"reads users"| node_users
node_dashboard -->|"reads leads"| node_leaddata
node_dashboard -->|"reads requests"| node_leadrequestdata
node_notifications -->|"manages notices"| node_notificationdata
node_notifications -->|"looks up users"| node_users
node_notifications -->|"sends push"| node_push
node_notifications -->|"sends email"| node_email
node_push -->|"saves notice"| node_notificationdata
node_push -->|"sends push"| node_onesignal
node_email -->|"sends email"| node_smtp
node_payments -.->|"uses records"| node_paymentdata
node_subscriptions -.->|"updates accounts"| node_users

click node_app "https://github.com/arshad-dev57/realtor_backend/blob/main/app.js"
click node_authroutes "https://github.com/arshad-dev57/realtor_backend/blob/main/routes/auth.routes.js"
click node_authguard "https://github.com/arshad-dev57/realtor_backend/blob/main/middlewares/auth.middleware.js"
click node_propertyroutes "https://github.com/arshad-dev57/realtor_backend/blob/main/routes/property.routes.js"
click node_propertyctl "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/property.controller.js"
click node_tourroutes "https://github.com/arshad-dev57/realtor_backend/blob/main/routes/tour.routes.js"
click node_tourctl "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/tour.controller.js"
click node_leads "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/lead.controller.js"
click node_leadrequests "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/leadrequest.controller.js"
click node_dashboard "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/dashboard.controller.js"
click node_admin "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/admin.dashboard.controller.js"
click node_users "https://github.com/arshad-dev57/realtor_backend/blob/main/models/user.model.js"
click node_authctl "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/auth.controller.js"
click node_devices "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/device.controller.js"
click node_payments "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/payment.controller.js"
click node_subscriptions "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/subscription.controller.js"
click node_notifications "https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/notification.controller.js"
click node_push "https://github.com/arshad-dev57/realtor_backend/blob/main/services/onesignal.js"
click node_email "https://github.com/arshad-dev57/realtor_backend/blob/main/services/email.service.js"
click node_notificationdata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/notification.model.js"
click node_propertydata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/property.model.js"
click node_tourdata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/tour.model.js"
click node_leaddata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/lead.model.js"
click node_leadrequestdata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/leadRequest.model.js"
click node_devicedata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/device.model.js"
click node_blacklist "https://github.com/arshad-dev57/realtor_backend/blob/main/models/tokenBlacklist.model.js"
click node_otpdata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/otp.model.js"
click node_paymentdata "https://github.com/arshad-dev57/realtor_backend/blob/main/models/payment.model.js"

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_app,node_authroutes,node_authguard,node_client toneBlue
class node_propertyroutes,node_propertyctl,node_tourroutes,node_tourctl,node_leads,node_leadrequests,node_dashboard,node_admin,node_cloudinary toneAmber
class node_users,node_authctl,node_devices,node_payments,node_subscriptions toneMint
class node_notifications,node_push,node_email toneRose
class node_notificationdata,node_propertydata,node_tourdata,node_leaddata,node_leadrequestdata,node_devicedata,node_blacklist,node_otpdata,node_paymentdata,node_onesignal,node_smtp toneIndigo
```

## Components

### API and access

- [Express API](https://github.com/arshad-dev57/realtor_backend/blob/main/app.js): `app.js`
- [Authentication routes](https://github.com/arshad-dev57/realtor_backend/blob/main/routes/auth.routes.js): `routes/auth.routes.js`
- [Authentication guard](https://github.com/arshad-dev57/realtor_backend/blob/main/middlewares/auth.middleware.js): `middlewares/auth.middleware.js`

### Marketplace workflows

- [Property routes](https://github.com/arshad-dev57/realtor_backend/blob/main/routes/property.routes.js): `routes/property.routes.js`
- [Property listings](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/property.controller.js): `controllers/property.controller.js`
- [Tour routes](https://github.com/arshad-dev57/realtor_backend/blob/main/routes/tour.routes.js): `routes/tour.routes.js`
- [Tour scheduling](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/tour.controller.js): `controllers/tour.controller.js`
- [Lead workflows](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/lead.controller.js): `controllers/lead.controller.js`
- [Lead requests](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/leadrequest.controller.js): `controllers/leadrequest.controller.js`
- [User dashboards](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/dashboard.controller.js): `controllers/dashboard.controller.js`
- [Admin dashboard](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/admin.dashboard.controller.js): `controllers/admin.dashboard.controller.js`

### Accounts and revenue

- [User accounts](https://github.com/arshad-dev57/realtor_backend/blob/main/models/user.model.js): `models/user.model.js`
- [Authentication and profiles](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/auth.controller.js): `controllers/auth.controller.js`
- [Device management](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/device.controller.js): `controllers/device.controller.js`
- [Payments](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/payment.controller.js): `controllers/payment.controller.js`
- [Subscriptions](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/subscription.controller.js): `controllers/subscription.controller.js`

### Engagement and messaging

- [Notification workflows](https://github.com/arshad-dev57/realtor_backend/blob/main/controllers/notification.controller.js): `controllers/notification.controller.js`
- [Push delivery](https://github.com/arshad-dev57/realtor_backend/blob/main/services/onesignal.js): `services/onesignal.js`
- [Email delivery](https://github.com/arshad-dev57/realtor_backend/blob/main/services/email.service.js): `services/email.service.js`

### Domain records

- [Notification records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/notification.model.js): `models/notification.model.js`
- [Property records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/property.model.js): `models/property.model.js`
- [Tour records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/tour.model.js): `models/tour.model.js`
- [Lead records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/lead.model.js): `models/lead.model.js`
- [Lead request records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/leadRequest.model.js): `models/leadRequest.model.js`
- [Device records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/device.model.js): `models/device.model.js`
- [Revoked tokens](https://github.com/arshad-dev57/realtor_backend/blob/main/models/tokenBlacklist.model.js): `models/tokenBlacklist.model.js`
- [One-time codes](https://github.com/arshad-dev57/realtor_backend/blob/main/models/otp.model.js): `models/otp.model.js`
- [Payment records](https://github.com/arshad-dev57/realtor_backend/blob/main/models/payment.model.js): `models/payment.model.js`

### Other components

- **API client**
- **Image storage**
- **OneSignal**
- **Gmail SMTP**

## Connections

- API client → Express API: sends requests (evidence: `app.js`)
- Express API → Authentication routes: mounts routes (evidence: `app.js`)
- Express API → Property routes: mounts routes (evidence: `app.js`)
- Express API → Tour routes: mounts routes (evidence: `app.js`)
- Express API → Lead workflows: mounts lead routes (evidence: `app.js`)
- Express API → Lead requests: mounts request routes (evidence: `app.js`)
- Express API → User dashboards: mounts routes (evidence: `app.js`)
- Authentication routes → Authentication and profiles: dispatches to (evidence: `routes/auth.routes.js`)
- Authentication routes → Subscriptions: dispatches to (evidence: `routes/auth.routes.js`)
- Authentication routes → Authentication guard: protects routes (evidence: `routes/auth.routes.js`)
- Property routes → Property listings: dispatches to (evidence: `routes/property.routes.js`)
- Property routes → Authentication guard: protects routes (evidence: `routes/property.routes.js`)
- Property routes → Image storage: uploads images (evidence: `routes/property.routes.js`)
- Tour routes → Tour scheduling: dispatches to (evidence: `routes/tour.routes.js`)
- Tour routes → Authentication guard: protects routes (evidence: `routes/tour.routes.js`)
- Authentication guard → Revoked tokens: checks tokens (evidence: `middlewares/auth.middleware.js`)
- Authentication guard → Device records: checks devices (evidence: `middlewares/auth.middleware.js`)
- Authentication and profiles → User accounts: reads and updates (evidence: `controllers/auth.controller.js`)
- Authentication and profiles → Device records: uses devices (evidence: `controllers/auth.controller.js`)
- Authentication and profiles → One-time codes: uses codes (evidence: `controllers/auth.controller.js`)
- Property listings → Property records: manages listings (evidence: `controllers/property.controller.js`)
- Property listings → User accounts: looks up users (evidence: `controllers/property.controller.js`)
- Property listings → Notification workflows: notifies users (evidence: `controllers/property.controller.js`)
- Property listings → Email delivery: sends alerts (evidence: `controllers/property.controller.js`)
- Property listings → Push delivery: sends alerts (evidence: `controllers/property.controller.js`)
- Tour scheduling → Tour records: manages tours (evidence: `controllers/tour.controller.js`)
- Tour scheduling → Property records: looks up listings (evidence: `controllers/tour.controller.js`)
- Tour scheduling → User accounts: looks up users (evidence: `controllers/tour.controller.js`)
- Tour scheduling → Notification records: saves notices (evidence: `controllers/tour.controller.js`)
- Tour scheduling → Push delivery: sends alerts (evidence: `controllers/tour.controller.js`)
- Tour scheduling → Email delivery: sends email (evidence: `controllers/tour.controller.js`)
- Lead workflows → Lead records: manages leads (evidence: `controllers/lead.controller.js`)
- Lead workflows → User accounts: looks up users (evidence: `controllers/lead.controller.js`)
- Lead workflows → Notification workflows: calls notifications (evidence: `controllers/lead.controller.js`)
- User dashboards → Tour records: reads tours (evidence: `controllers/dashboard.controller.js`)
- User dashboards → Property records: reads listings (evidence: `controllers/dashboard.controller.js`)
- User dashboards → User accounts: reads users (evidence: `controllers/dashboard.controller.js`)
- User dashboards → Lead records: reads leads (evidence: `controllers/dashboard.controller.js`)
- User dashboards → Lead request records: reads requests (evidence: `controllers/dashboard.controller.js`)
- Notification workflows → Notification records: manages notices (evidence: `controllers/notification.controller.js`)
- Notification workflows → User accounts: looks up users (evidence: `controllers/notification.controller.js`)
- Notification workflows → Push delivery: sends push (evidence: `controllers/notification.controller.js`)
- Notification workflows → Email delivery: sends email (evidence: `controllers/notification.controller.js`)
- Push delivery → Notification records: saves notice (evidence: `services/onesignal.js`)
- Push delivery → OneSignal: sends push (evidence: `services/onesignal.js`)
- Email delivery → Gmail SMTP: sends email (evidence: `services/email.service.js`)
- Payments → Payment records: uses records (evidence: `controllers/payment.controller.js`)
- Subscriptions → User accounts: updates accounts
