# auxomeness/homelane-backend architecture

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

- Interactive diagram: https://gitdiagram.com/auxomeness/homelane-backend
- Repository: https://github.com/auxomeness/homelane-backend

## Overview

Homelane is a standalone Express API for property listings and agent/buyer workspaces. Visitors browse published properties; buyers and staff authenticate to manage conversations, viewing requests, listings, or agent applications. The listing workflow is explicit in the sampled routes and controller: requests are role-gated, validated, handled by services, and persisted through repositories. Workspace and chat internals are represented at their source-directory level because their implementation excerpts were not provided; README-documented capabilities guide those branches.

Main entry points: [`src/app.ts`](https://github.com/auxomeness/homelane-backend/blob/main/src/app.ts) (Express API), [`src/services/database.ts`](https://github.com/auxomeness/homelane-backend/blob/main/src/services/database.ts) (Database pool), [`src/routes/index.ts`](https://github.com/auxomeness/homelane-backend/blob/main/src/routes/index.ts) (API routes), [`src/routes/listings.admin.routes.ts`](https://github.com/auxomeness/homelane-backend/blob/main/src/routes/listings.admin.routes.ts) (Listing routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_api["Express API<br/>[app.ts]"]
  node_routes["API routes<br/>[index.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_authz["Role checks<br/>[requireRole.ts]"]
  node_rate["Auth rate limits<br/>[authRateLimit.ts]"]
end

subgraph group_listings["Listing lifecycle"]
  node_listing_routes["Listing routes"]
  node_listing_controller["Listing handlers"]
  node_listing_validation["Listing validation"]
  node_listing_service["Listing service"]
  node_listing_repo["Listing repository"]
  node_listing_types["Listing contracts<br/>[listings.types.ts]"]
end

subgraph group_workspace["Buyer and agent workspaces"]
  node_buyer_workspace["Buyer workspace<br/>[buyerWorkspace.ts]"]
  node_agent_workspace["Agent workspace<br/>[agentWorkspace.ts]"]
  node_workspace_services["Workspace services<br/>[workspace.ts]"]
  node_chat["Chat events<br/>[chatEvents.ts]"]
end

subgraph group_staff["Staff and applications"]
  node_dashboards["Dashboards"]
  node_dashboard_repos["Dashboard repositories"]
  node_applications["Agent applications"]
  node_agents_service["Agent service<br/>[agents.service.ts]"]
  node_agents_repo["Agent repository"]
end

subgraph group_data["Persistence and events"]
  node_database[("Database pool<br/>[database.ts]")]
  node_postgres[("PostgreSQL")]
end

node_visitor(("Visitor"))
node_buyer(("Buyer"))
node_agent(("Agent"))
node_admin(("Admin"))

node_visitor -->|"browses listings"| node_api
node_buyer -->|"uses buyer APIs"| node_api
node_agent -->|"uses staff APIs"| node_api
node_admin -->|"uses admin APIs"| node_api
node_api -->|"limits auth"| node_rate
node_api -->|"mounts routes"| node_routes
node_routes -->|"mounts listing APIs"| node_listing_routes
node_routes -->|"mounts application APIs"| node_applications
node_routes -->|"mounts buyer APIs"| node_buyer_workspace
node_routes -->|"mounts agent APIs"| node_agent_workspace
node_listing_routes -->|"checks role"| node_authz
node_listing_routes -->|"dispatches handlers"| node_listing_controller
node_listing_controller -->|"validates input"| node_listing_validation
node_listing_controller -->|"calls service"| node_listing_service
node_listing_service -->|"queries listings"| node_listing_repo
node_listing_repo -->|"runs queries"| node_database
node_database -->|"reads and writes"| node_postgres
node_buyer_workspace -.->|"uses services"| node_workspace_services
node_agent_workspace -.->|"uses services"| node_workspace_services
node_buyer_workspace -.->|"supports messaging"| node_chat
node_agent_workspace -.->|"supports messaging"| node_chat
node_workspace_services -.->|"persists workspace"| node_database
node_dashboards -->|"loads metrics"| node_dashboard_repos
node_dashboard_repos -->|"runs queries"| node_database
node_applications -->|"calls service"| node_agents_service
node_agents_service -->|"uses repository"| node_agents_repo
node_agents_repo -->|"runs queries"| node_database
node_auth -.->|"uses password workers"| node_database

click node_api "https://github.com/auxomeness/homelane-backend/blob/main/src/app.ts"
click node_routes "https://github.com/auxomeness/homelane-backend/blob/main/src/routes/index.ts"
click node_auth "https://github.com/auxomeness/homelane-backend/blob/main/src/services/auth.ts"
click node_authz "https://github.com/auxomeness/homelane-backend/blob/main/src/middleware/requireRole.ts"
click node_rate "https://github.com/auxomeness/homelane-backend/blob/main/src/middleware/authRateLimit.ts"
click node_listing_routes "https://github.com/auxomeness/homelane-backend/blob/main/src/routes/listings.admin.routes.ts"
click node_listing_controller "https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/listings.controller.ts"
click node_listing_validation "https://github.com/auxomeness/homelane-backend/blob/main/src/validators/listings.validator.ts"
click node_listing_service "https://github.com/auxomeness/homelane-backend/blob/main/src/services/listings.service.ts"
click node_listing_repo "https://github.com/auxomeness/homelane-backend/blob/main/src/modules/listings/listings.repository.ts"
click node_listing_types "https://github.com/auxomeness/homelane-backend/blob/main/src/types/listings.types.ts"
click node_buyer_workspace "https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/buyerWorkspace.ts"
click node_agent_workspace "https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/agentWorkspace.ts"
click node_workspace_services "https://github.com/auxomeness/homelane-backend/blob/main/src/services/workspace.ts"
click node_chat "https://github.com/auxomeness/homelane-backend/blob/main/src/services/chatEvents.ts"
click node_dashboards "https://github.com/auxomeness/homelane-backend/blob/main/src/services/agent.dashboard.service.ts"
click node_dashboard_repos "https://github.com/auxomeness/homelane-backend/blob/main/src/modules/dashboard/agent.dashboard.repository.ts"
click node_applications "https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/agents.controller.ts"
click node_agents_service "https://github.com/auxomeness/homelane-backend/blob/main/src/services/agents.service.ts"
click node_agents_repo "https://github.com/auxomeness/homelane-backend/blob/main/src/modules/agents/agents.repository.ts"
click node_database "https://github.com/auxomeness/homelane-backend/blob/main/src/services/database.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_api,node_routes,node_auth,node_authz,node_rate toneBlue
class node_listing_routes,node_listing_controller,node_listing_validation,node_listing_service,node_listing_repo,node_listing_types toneAmber
class node_buyer_workspace,node_agent_workspace,node_workspace_services,node_chat toneMint
class node_dashboards,node_dashboard_repos,node_applications,node_agents_service,node_agents_repo toneRose
class node_database,node_postgres,node_visitor,node_buyer,node_agent,node_admin toneIndigo
```

## Components

### API and access

- [Express API](https://github.com/auxomeness/homelane-backend/blob/main/src/app.ts): `src/app.ts`
- [API routes](https://github.com/auxomeness/homelane-backend/blob/main/src/routes/index.ts): `src/routes/index.ts`
- [Authentication](https://github.com/auxomeness/homelane-backend/blob/main/src/services/auth.ts): `src/services/auth.ts`
- [Role checks](https://github.com/auxomeness/homelane-backend/blob/main/src/middleware/requireRole.ts): `src/middleware/requireRole.ts`
- [Auth rate limits](https://github.com/auxomeness/homelane-backend/blob/main/src/middleware/authRateLimit.ts): `src/middleware/authRateLimit.ts`

### Listing lifecycle

- [Listing routes](https://github.com/auxomeness/homelane-backend/blob/main/src/routes/listings.admin.routes.ts): `src/routes/listings.admin.routes.ts`
- [Listing handlers](https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/listings.controller.ts): `src/controllers/listings.controller.ts`
- [Listing validation](https://github.com/auxomeness/homelane-backend/blob/main/src/validators/listings.validator.ts): `src/validators/listings.validator.ts`
- [Listing service](https://github.com/auxomeness/homelane-backend/blob/main/src/services/listings.service.ts): `src/services/listings.service.ts`
- [Listing repository](https://github.com/auxomeness/homelane-backend/blob/main/src/modules/listings/listings.repository.ts): `src/modules/listings/listings.repository.ts`
- [Listing contracts](https://github.com/auxomeness/homelane-backend/blob/main/src/types/listings.types.ts): `src/types/listings.types.ts`

### Buyer and agent workspaces

- [Buyer workspace](https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/buyerWorkspace.ts): `src/controllers/buyerWorkspace.ts`
- [Agent workspace](https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/agentWorkspace.ts): `src/controllers/agentWorkspace.ts`
- [Workspace services](https://github.com/auxomeness/homelane-backend/blob/main/src/services/workspace.ts): `src/services/workspace.ts`
- [Chat events](https://github.com/auxomeness/homelane-backend/blob/main/src/services/chatEvents.ts): `src/services/chatEvents.ts`

### Staff and applications

- [Dashboards](https://github.com/auxomeness/homelane-backend/blob/main/src/services/agent.dashboard.service.ts): `src/services/agent.dashboard.service.ts`
- [Dashboard repositories](https://github.com/auxomeness/homelane-backend/blob/main/src/modules/dashboard/agent.dashboard.repository.ts): `src/modules/dashboard/agent.dashboard.repository.ts`
- [Agent applications](https://github.com/auxomeness/homelane-backend/blob/main/src/controllers/agents.controller.ts): `src/controllers/agents.controller.ts`
- [Agent service](https://github.com/auxomeness/homelane-backend/blob/main/src/services/agents.service.ts): `src/services/agents.service.ts`
- [Agent repository](https://github.com/auxomeness/homelane-backend/blob/main/src/modules/agents/agents.repository.ts): `src/modules/agents/agents.repository.ts`

### Persistence and events

- [Database pool](https://github.com/auxomeness/homelane-backend/blob/main/src/services/database.ts): `src/services/database.ts`
- **PostgreSQL**

### Other components

- **Visitor**
- **Buyer**
- **Agent**
- **Admin**

## Connections

- Visitor → Express API: browses listings
- Buyer → Express API: uses buyer APIs
- Agent → Express API: uses staff APIs
- Admin → Express API: uses admin APIs
- Express API → Auth rate limits: limits auth (evidence: `src/app.ts`)
- Express API → API routes: mounts routes (evidence: `src/app.ts`)
- API routes → Listing routes: mounts listing APIs (evidence: `src/routes/index.ts`)
- API routes → Agent applications: mounts application APIs (evidence: `src/routes/index.ts`)
- API routes → Buyer workspace: mounts buyer APIs (evidence: `src/routes/index.ts`)
- API routes → Agent workspace: mounts agent APIs (evidence: `src/routes/index.ts`)
- Listing routes → Role checks: checks role (evidence: `src/routes/listings.admin.routes.ts`)
- Listing routes → Listing handlers: dispatches handlers (evidence: `src/routes/listings.admin.routes.ts`)
- Listing handlers → Listing validation: validates input (evidence: `src/controllers/listings.controller.ts`)
- Listing handlers → Listing service: calls service (evidence: `src/controllers/listings.controller.ts`)
- Listing service → Listing repository: queries listings (evidence: `src/services/listings.service.ts`)
- Listing repository → Database pool: runs queries (evidence: `src/modules/listings/listings.repository.ts`)
- Database pool → PostgreSQL: reads and writes
- Buyer workspace → Workspace services: uses services
- Agent workspace → Workspace services: uses services
- Buyer workspace → Chat events: supports messaging
- Agent workspace → Chat events: supports messaging
- Workspace services → Database pool: persists workspace
- Dashboards → Dashboard repositories: loads metrics (evidence: `src/services/agent.dashboard.service.ts`)
- Dashboard repositories → Database pool: runs queries (evidence: `src/modules/dashboard/agent.dashboard.repository.ts`)
- Agent applications → Agent service: calls service (evidence: `src/controllers/agents.controller.ts`)
- Agent service → Agent repository: uses repository (evidence: `src/services/agents.service.ts`)
- Agent repository → Database pool: runs queries (evidence: `src/modules/agents/agents.repository.ts`)
- Authentication → Database pool: uses password workers
