# dhruvbhadhotiya/ownsquare architecture

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

- Interactive diagram: https://gitdiagram.com/dhruvbhadhotiya/ownsquare
- Repository: https://github.com/dhruvbhadhotiya/ownsquare

## Overview

OwnSquare is an academic fractional-property investment portal for brokers, investors, and administrators; its financial backend is authoritative, while the README says the public marketplace and broker property screens still use fixtures. The principal workflow spans property discovery and listing, investment and wallet activity, portfolio ownership, and eventual property sale and payouts. The graph preserves documented KYC, enquiries, notifications, administration, authentication, and optional media/email capabilities. Evidence is limited to the README and supplied excerpts/index; unsampled implementation links are omitted where their caller is not shown.

Main entry points: [`server/src/utils/backendServices.js`](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/utils/backendServices.js) (Service composition), [`client/src/routes/AppRoutes.jsx`](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/routes/AppRoutes.jsx) (Role-based screens), [`client/src/api/client.js`](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/api/client.js) (API client), [`server/src/app.js`](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/app.js) (Express API application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_client_routes["Role-based screens<br/>[AppRoutes.jsx]"]
  node_auth_context["Session and capabilities<br/>[AuthContext.jsx]"]
  node_api_client["API client<br/>[client.js]"]
  node_public_pages["Property marketplace<br/>[Marketplace.jsx]"]
  node_broker_pages["Broker property tools<br/>[PropertyWizard.jsx]"]
  node_investor_pages["Investor portal<br/>[index.jsx]"]
  node_admin_pages["Administration<br/>[AdminDashboard.jsx]"]
  node_shared_ui["Shared interface"]
end

subgraph group_server["API and access"]
  node_http_app["Express API application<br/>[app.js]"]
  node_auth["Authentication<br/>[auth.service.js]"]
  node_services_root["Service composition<br/>[backendServices.js]"]
  node_data_models[("MongoDB models")]
end

subgraph group_property["Property lifecycle"]
  node_property_api["Property API"]
  node_property_lifecycle["Property lifecycle"]
  node_uploads["Media uploads<br/>[upload.service.js]"]
  node_enquiries["Property enquiries"]
end

subgraph group_finance["Investment finance"]
  node_investment["Investment execution"]
  node_wallet["Wallet and withdrawals<br/>[wallet.service.js]"]
  node_ledger["Transaction ledger<br/>[ledger.service.js]"]
  node_portfolio["Portfolio holdings"]
  node_payouts["Sale payouts<br/>[payout.service.js]"]
end

subgraph group_operations["Trust and operations"]
  node_kyc["Identity verification<br/>[kyc.service.js]"]
  node_admin_service["Admin operations<br/>[admin.service.js]"]
  node_notifications["Notifications"]
end

node_visitors(("Visitors"))
node_users(("Signed-in users"))
node_cloudinary["Cloudinary media"]
node_smtp["SMTP mail"]

node_visitors -->|"browse"| node_client_routes
node_users -->|"open workspace"| node_client_routes
node_client_routes -->|"routes to"| node_public_pages
node_client_routes -->|"routes to"| node_broker_pages
node_client_routes -->|"routes to"| node_investor_pages
node_client_routes -->|"routes to"| node_admin_pages
node_client_routes -.->|"renders"| node_shared_ui
node_auth_context -->|"requests sessions"| node_api_client
node_public_pages -.->|"loads properties"| node_api_client
node_broker_pages -.->|"submits listings"| node_api_client
node_investor_pages -.->|"uses portal APIs"| node_api_client
node_admin_pages -.->|"uses admin APIs"| node_api_client
node_api_client -->|"calls API"| node_http_app
node_http_app -.->|"routes requests"| node_auth
node_http_app -->|"mounts routes"| node_property_api
node_http_app -->|"creates services"| node_services_root
node_property_api -.->|"delegates lifecycle"| node_property_lifecycle
node_property_api -->|"reads property"| node_data_models
node_enquiries -->|"reads and writes"| node_data_models
node_services_root -->|"creates service"| node_investment
node_services_root -->|"creates service"| node_wallet
node_services_root -->|"creates service"| node_ledger
node_services_root -->|"creates service"| node_portfolio
node_services_root -->|"creates service"| node_payouts
node_services_root -->|"creates service"| node_property_lifecycle
node_services_root -->|"optionally creates"| node_uploads
node_services_root -->|"creates service"| node_kyc
node_services_root -->|"creates service"| node_admin_service
node_services_root -->|"creates service"| node_notifications
node_services_root -.->|"uses persistence"| node_data_models
node_uploads -.->|"hosts media"| node_cloudinary
node_auth -->|"sends reset mail"| node_smtp
node_auth -->|"reads and updates"| node_data_models
node_investment -.->|"posts entries"| node_ledger
node_payouts -.->|"posts payouts"| node_ledger

click node_client_routes "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/routes/AppRoutes.jsx"
click node_auth_context "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/context/AuthContext.jsx"
click node_api_client "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/api/client.js"
click node_public_pages "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/pages/public/Marketplace.jsx"
click node_broker_pages "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/features/broker/PropertyWizard.jsx"
click node_investor_pages "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/pages/investor/index.jsx"
click node_admin_pages "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/pages/admin/AdminDashboard.jsx"
click node_shared_ui "https://github.com/dhruvbhadhotiya/ownsquare/tree/main/client/src/components"
click node_http_app "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/app.js"
click node_auth "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/auth.service.js"
click node_property_api "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/routes/propertyAdmin.routes.js"
click node_property_lifecycle "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/propertyLifecycle.service.js"
click node_uploads "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/upload.service.js"
click node_enquiries "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/routes/enquiries.routes.js"
click node_investment "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/investment.service.js"
click node_wallet "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/wallet.service.js"
click node_ledger "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/ledger.service.js"
click node_portfolio "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/portfolio.service.js"
click node_payouts "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/payout.service.js"
click node_kyc "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/kyc.service.js"
click node_admin_service "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/admin.service.js"
click node_notifications "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/notification.service.js"
click node_services_root "https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/utils/backendServices.js"
click node_data_models "https://github.com/dhruvbhadhotiya/ownsquare/tree/main/server/src/models"

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_routes,node_auth_context,node_api_client,node_public_pages,node_broker_pages,node_investor_pages,node_admin_pages,node_shared_ui,node_users toneBlue
class node_http_app,node_auth,node_services_root,node_data_models toneAmber
class node_property_api,node_property_lifecycle,node_uploads,node_enquiries toneMint
class node_investment,node_wallet,node_ledger,node_portfolio,node_payouts toneRose
class node_kyc,node_admin_service,node_notifications,node_visitors,node_cloudinary,node_smtp toneIndigo
```

## Components

### Client experience

- [Role-based screens](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/routes/AppRoutes.jsx): `client/src/routes/AppRoutes.jsx`
- [Session and capabilities](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/context/AuthContext.jsx): `client/src/context/AuthContext.jsx`
- [API client](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/api/client.js): `client/src/api/client.js`
- [Property marketplace](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/pages/public/Marketplace.jsx): `client/src/pages/public/Marketplace.jsx`
- [Broker property tools](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/features/broker/PropertyWizard.jsx): `client/src/features/broker/PropertyWizard.jsx`
- [Investor portal](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/pages/investor/index.jsx): `client/src/pages/investor/index.jsx`
- [Administration](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/client/src/pages/admin/AdminDashboard.jsx): `client/src/pages/admin/AdminDashboard.jsx`
- [Shared interface](https://github.com/dhruvbhadhotiya/ownsquare/tree/main/client/src/components): `client/src/components`

### API and access

- [Express API application](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/app.js): `server/src/app.js`
- [Authentication](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/auth.service.js): `server/src/services/auth.service.js`
- [Service composition](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/utils/backendServices.js): `server/src/utils/backendServices.js`
- [MongoDB models](https://github.com/dhruvbhadhotiya/ownsquare/tree/main/server/src/models): `server/src/models`

### Property lifecycle

- [Property API](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/routes/propertyAdmin.routes.js): `server/src/routes/propertyAdmin.routes.js`
- [Property lifecycle](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/propertyLifecycle.service.js): `server/src/services/propertyLifecycle.service.js`
- [Media uploads](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/upload.service.js): `server/src/services/upload.service.js`
- [Property enquiries](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/routes/enquiries.routes.js): `server/src/routes/enquiries.routes.js`

### Investment finance

- [Investment execution](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/investment.service.js): `server/src/services/investment.service.js`
- [Wallet and withdrawals](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/wallet.service.js): `server/src/services/wallet.service.js`
- [Transaction ledger](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/ledger.service.js): `server/src/services/ledger.service.js`
- [Portfolio holdings](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/portfolio.service.js): `server/src/services/portfolio.service.js`
- [Sale payouts](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/payout.service.js): `server/src/services/payout.service.js`

### Trust and operations

- [Identity verification](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/kyc.service.js): `server/src/services/kyc.service.js`
- [Admin operations](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/admin.service.js): `server/src/services/admin.service.js`
- [Notifications](https://github.com/dhruvbhadhotiya/ownsquare/blob/main/server/src/services/notification.service.js): `server/src/services/notification.service.js`

### Other components

- **Visitors**
- **Signed-in users**
- **Cloudinary media**
- **SMTP mail**

## Connections

- Visitors → Role-based screens: browse (evidence: `client/src/routes/AppRoutes.jsx`)
- Signed-in users → Role-based screens: open workspace (evidence: `client/src/routes/AppRoutes.jsx`)
- Role-based screens → Property marketplace: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Role-based screens → Broker property tools: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Role-based screens → Investor portal: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Role-based screens → Administration: routes to (evidence: `client/src/routes/AppRoutes.jsx`)
- Role-based screens → Shared interface: renders
- Session and capabilities → API client: requests sessions (evidence: `client/src/context/AuthContext.jsx`)
- Property marketplace → API client: loads properties
- Broker property tools → API client: submits listings
- Investor portal → API client: uses portal APIs
- Administration → API client: uses admin APIs
- API client → Express API application: calls API
- Express API application → Authentication: routes requests
- Express API application → Property API: mounts routes (evidence: `server/src/app.js`)
- Express API application → Service composition: creates services (evidence: `server/src/app.js`)
- Property API → Property lifecycle: delegates lifecycle
- Property API → MongoDB models: reads property (evidence: `server/src/routes/propertyAdmin.routes.js`)
- Property enquiries → MongoDB models: reads and writes (evidence: `server/src/routes/enquiries.routes.js`)
- Service composition → Investment execution: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Wallet and withdrawals: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Transaction ledger: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Portfolio holdings: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Sale payouts: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Property lifecycle: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Media uploads: optionally creates (evidence: `server/src/utils/backendServices.js`)
- Service composition → Identity verification: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Admin operations: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → Notifications: creates service (evidence: `server/src/utils/backendServices.js`)
- Service composition → MongoDB models: uses persistence
- Media uploads → Cloudinary media: hosts media
- Authentication → SMTP mail: sends reset mail (evidence: `server/src/services/auth.service.js`)
- Authentication → MongoDB models: reads and updates (evidence: `server/src/services/auth.service.js`)
- Investment execution → Transaction ledger: posts entries
- Sale payouts → Transaction ledger: posts payouts
