# nexmitra/housing-elite architecture

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

- Interactive diagram: https://gitdiagram.com/nexmitra/housing-elite
- Repository: https://github.com/nexmitra/housing-elite

## Overview

Housing Elite is a real-estate discovery and lead-generation application, with developer/project listings, AI-assisted property discovery, user accounts, saved-project features, and administrative management. The typical journey is browsing properties, asking the AI for help or submitting an enquiry, then optionally using account features such as bookmarks and history. Server routes mediate these capabilities and use Firebase-backed data with static catalog fallbacks. The map emphasizes relationships visible in excerpts or the source index; unsampled page-to-API wiring is not asserted.

Main entry points: [`src/lib/firebase-admin.ts`](https://github.com/nexmitra/housing-elite/blob/main/src/lib/firebase-admin.ts) (Firebase Admin), [`src/lib/auth.ts`](https://github.com/nexmitra/housing-elite/blob/main/src/lib/auth.ts) (Session and profiles), [`src/lib/db-helpers.ts`](https://github.com/nexmitra/housing-elite/blob/main/src/lib/db-helpers.ts) (Catalog access), [`src/app/api/auth/login/route.ts`](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/auth/login/route.ts) (Email login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Property discovery"]
  node_browse["Project browsing<br/>[page.tsx]"]
  node_project_detail["Project details<br/>[page.tsx]"]
  node_developer_directory["Developer directory<br/>[page.tsx]"]
  node_featured["Featured projects"]
  node_ai_chat["AI property chat<br/>[route.ts]"]
  node_ai_service["AI model service"]
end

subgraph group_accounts["Accounts and saved items"]
  node_login["Email login<br/>[route.ts]"]
  node_otp["Phone OTP<br/>[route.ts]"]
  node_session["Session and profiles<br/>[auth.ts]"]
  node_bookmarks["Bookmarks<br/>[route.ts]"]
  node_history["View history<br/>[route.ts]"]
  node_profile["Profile updates<br/>[route.ts]"]
end

subgraph group_management["Lead and administration"]
  node_enquiry["Enquiry intake<br/>[route.ts]"]
  node_admin_routes["Admin operations"]
end

subgraph group_platform["Data and services"]
  node_catalog["Property catalog<br/>[data.ts]"]
  node_data_access["Catalog access<br/>[db-helpers.ts]"]
  node_firebase["Firebase Admin<br/>[firebase-admin.ts]"]
  node_firestore[("Firestore")]
  node_firebase_auth["Firebase Auth"]
end

node_visitor(("Property seeker"))
node_crm["Workveu CRM"]
node_sheets[("Google Sheets")]

node_visitor -.->|"browses"| node_browse
node_featured -->|"reads"| node_catalog
node_browse -.->|"loads catalog"| node_data_access
node_project_detail -.->|"loads project"| node_data_access
node_developer_directory -.->|"loads developers"| node_data_access
node_ai_chat -->|"fetches catalog"| node_data_access
node_ai_chat -->|"requests completion"| node_ai_service
node_data_access -->|"reads"| node_firestore
node_data_access -->|"falls back to"| node_catalog
node_firebase -->|"initializes"| node_firestore
node_firebase -->|"initializes"| node_firebase_auth
node_login -->|"verifies user"| node_firebase_auth
node_login -->|"signs session"| node_session
node_login -->|"loads profile"| node_firebase
node_otp -->|"reads users"| node_firebase
node_otp -->|"signs session"| node_session
node_session -->|"manages profiles"| node_firebase
node_bookmarks -->|"authenticates"| node_session
node_bookmarks -->|"reads and writes"| node_firebase
node_history -->|"authenticates"| node_session
node_history -->|"reads and writes"| node_firebase
node_profile -->|"authenticates"| node_session
node_profile -->|"updates profile"| node_firebase
node_enquiry -->|"stores lead"| node_firebase
node_enquiry -->|"forwards lead"| node_crm
node_enquiry -->|"appends lead"| node_sheets
node_admin_routes -.->|"manages records"| node_firebase
node_admin_routes -.->|"checks access"| node_session

click node_browse "https://github.com/nexmitra/housing-elite/blob/main/src/app/projects/page.tsx"
click node_project_detail "https://github.com/nexmitra/housing-elite/blob/main/src/app/projects/%5Bid%5D/page.tsx"
click node_developer_directory "https://github.com/nexmitra/housing-elite/blob/main/src/app/developers/page.tsx"
click node_featured "https://github.com/nexmitra/housing-elite/blob/main/src/components/FeaturedProjects.tsx"
click node_ai_chat "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/ai/chat/route.ts"
click node_login "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/auth/login/route.ts"
click node_otp "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/auth/otp/route.ts"
click node_session "https://github.com/nexmitra/housing-elite/blob/main/src/lib/auth.ts"
click node_bookmarks "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/user/bookmarks/route.ts"
click node_history "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/user/history/route.ts"
click node_profile "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/user/profile/route.ts"
click node_enquiry "https://github.com/nexmitra/housing-elite/blob/main/src/app/api/leads/route.ts"
click node_admin_routes "https://github.com/nexmitra/housing-elite/tree/main/src/app/api/admin"
click node_catalog "https://github.com/nexmitra/housing-elite/blob/main/src/lib/data.ts"
click node_data_access "https://github.com/nexmitra/housing-elite/blob/main/src/lib/db-helpers.ts"
click node_firebase "https://github.com/nexmitra/housing-elite/blob/main/src/lib/firebase-admin.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_browse,node_project_detail,node_developer_directory,node_featured,node_ai_chat,node_ai_service toneBlue
class node_login,node_otp,node_session,node_bookmarks,node_history,node_profile,node_sheets toneAmber
class node_enquiry,node_admin_routes toneMint
class node_catalog,node_data_access,node_firebase,node_firestore,node_firebase_auth toneRose
class node_visitor,node_crm toneIndigo
```

## Components

### Property discovery

- [Project browsing](https://github.com/nexmitra/housing-elite/blob/main/src/app/projects/page.tsx): `src/app/projects/page.tsx`
- [Project details](https://github.com/nexmitra/housing-elite/blob/main/src/app/projects/%5Bid%5D/page.tsx): `src/app/projects/[id]/page.tsx`
- [Developer directory](https://github.com/nexmitra/housing-elite/blob/main/src/app/developers/page.tsx): `src/app/developers/page.tsx`
- [Featured projects](https://github.com/nexmitra/housing-elite/blob/main/src/components/FeaturedProjects.tsx): `src/components/FeaturedProjects.tsx`
- [AI property chat](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/ai/chat/route.ts): `src/app/api/ai/chat/route.ts`
- **AI model service**

### Accounts and saved items

- [Email login](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/auth/login/route.ts): `src/app/api/auth/login/route.ts`
- [Phone OTP](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/auth/otp/route.ts): `src/app/api/auth/otp/route.ts`
- [Session and profiles](https://github.com/nexmitra/housing-elite/blob/main/src/lib/auth.ts): `src/lib/auth.ts`
- [Bookmarks](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/user/bookmarks/route.ts): `src/app/api/user/bookmarks/route.ts`
- [View history](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/user/history/route.ts): `src/app/api/user/history/route.ts`
- [Profile updates](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/user/profile/route.ts): `src/app/api/user/profile/route.ts`

### Lead and administration

- [Enquiry intake](https://github.com/nexmitra/housing-elite/blob/main/src/app/api/leads/route.ts): `src/app/api/leads/route.ts`
- [Admin operations](https://github.com/nexmitra/housing-elite/tree/main/src/app/api/admin): `src/app/api/admin`

### Data and services

- [Property catalog](https://github.com/nexmitra/housing-elite/blob/main/src/lib/data.ts): `src/lib/data.ts`
- [Catalog access](https://github.com/nexmitra/housing-elite/blob/main/src/lib/db-helpers.ts): `src/lib/db-helpers.ts`
- [Firebase Admin](https://github.com/nexmitra/housing-elite/blob/main/src/lib/firebase-admin.ts): `src/lib/firebase-admin.ts`
- **Firestore**
- **Firebase Auth**

### Other components

- **Property seeker**
- **Workveu CRM**
- **Google Sheets**

## Connections

- Property seeker → Project browsing: browses
- Featured projects → Property catalog: reads (evidence: `src/components/FeaturedProjects.tsx`)
- Project browsing → Catalog access: loads catalog
- Project details → Catalog access: loads project
- Developer directory → Catalog access: loads developers
- AI property chat → Catalog access: fetches catalog (evidence: `src/app/api/ai/chat/route.ts`)
- AI property chat → AI model service: requests completion (evidence: `src/app/api/ai/chat/route.ts`)
- Catalog access → Firestore: reads (evidence: `src/lib/db-helpers.ts`)
- Catalog access → Property catalog: falls back to (evidence: `src/lib/db-helpers.ts`)
- Firebase Admin → Firestore: initializes (evidence: `src/lib/firebase-admin.ts`)
- Firebase Admin → Firebase Auth: initializes (evidence: `src/lib/firebase-admin.ts`)
- Email login → Firebase Auth: verifies user (evidence: `src/app/api/auth/login/route.ts`)
- Email login → Session and profiles: signs session (evidence: `src/app/api/auth/login/route.ts`)
- Email login → Firebase Admin: loads profile (evidence: `src/app/api/auth/login/route.ts`)
- Phone OTP → Firebase Admin: reads users (evidence: `src/app/api/auth/otp/route.ts`)
- Phone OTP → Session and profiles: signs session (evidence: `src/app/api/auth/otp/route.ts`)
- Session and profiles → Firebase Admin: manages profiles (evidence: `src/lib/auth.ts`)
- Bookmarks → Session and profiles: authenticates (evidence: `src/app/api/user/bookmarks/route.ts`)
- Bookmarks → Firebase Admin: reads and writes (evidence: `src/app/api/user/bookmarks/route.ts`)
- View history → Session and profiles: authenticates (evidence: `src/app/api/user/history/route.ts`)
- View history → Firebase Admin: reads and writes (evidence: `src/app/api/user/history/route.ts`)
- Profile updates → Session and profiles: authenticates (evidence: `src/app/api/user/profile/route.ts`)
- Profile updates → Firebase Admin: updates profile (evidence: `src/app/api/user/profile/route.ts`)
- Enquiry intake → Firebase Admin: stores lead (evidence: `src/app/api/leads/route.ts`)
- Enquiry intake → Workveu CRM: forwards lead (evidence: `src/app/api/leads/route.ts`)
- Enquiry intake → Google Sheets: appends lead (evidence: `src/app/api/leads/route.ts`)
- Admin operations → Firebase Admin: manages records (evidence: `src/app/api/admin/upload/route.ts`)
- Admin operations → Session and profiles: checks access (evidence: `src/app/api/admin/upload/route.ts`)
