# asm-hanif/flatmate architecture

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

- Interactive diagram: https://gitdiagram.com/asm-hanif/flatmate
- Repository: https://github.com/asm-hanif/flatmate

## Overview

FlatMate is a property marketplace: seekers discover listings and can favorite, request, or message owners; owners publish and manage listings and respond to requests. Accounts and profiles support both roles, with notifications and email alongside the marketplace workflow. Mira offers property recommendations, price advice, and chat. The graph reflects documented capabilities and sampled route/controller behavior; unsampled route wiring is represented only where the repository structure and README support it.

Main entry points: [`Backend/server/db.js`](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/db.js) (PostgreSQL), [`Backend/server/controllers/botController.js`](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/botController.js) (Assistant API), [`Backend/server/services/mailService.js`](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/services/mailService.js) (Email delivery), [`Backend/server.js`](https://github.com/asm-hanif/flatmate/blob/main/Backend/server.js) (Express application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Property discovery"]
  node_listing_ui["Browse listings<br/>[flats.js]"]
  node_listing_routes["Listing routes<br/>[flatRoutes.js]"]
  node_listing_controller["Listing management<br/>[flatController.js]"]
  node_request_ui["Requests dashboard<br/>[requests.js]"]
  node_request_controller["Request management"]
end

subgraph group_accounts["Accounts and engagement"]
  node_auth_ui["Sign-in and account<br/>[auth.js]"]
  node_auth_controller["Authentication<br/>[authController.js]"]
  node_profile_ui["Profile<br/>[profile.js]"]
  node_profile_controller["Profile management"]
  node_favorite_ui["Favorites<br/>[flats.js]"]
  node_favorite_controller["Favorite management"]
  node_chat_ui["Property chat<br/>[chat.js]"]
  node_chat_routes["Conversation API<br/>[chatRoutes.js]"]
  node_notification_controller["Notifications"]
  node_contact_controller["Contact and inquiry"]
  node_mail_service["Email delivery<br/>[mailService.js]"]
end

subgraph group_mira["Mira assistant"]
  node_mira_ui["Mira chat<br/>[bot.js]"]
  node_bot_controller["Assistant API<br/>[botController.js]"]
  node_recommend_engine["Flat recommendations<br/>[recommendEngine.js]"]
  node_price_model["Price advisor<br/>[priceModel.js]"]
  node_location_rates["Location rate data<br/>[locationRates.js]"]
  node_llm_service["Optional LLM chat<br/>[llmService.js]"]
end

subgraph group_platform["Application platform"]
  node_server["Express application<br/>[server.js]"]
  node_database[("PostgreSQL<br/>[db.js]")]
end

node_seeker(("Home seeker"))
node_owner(("Property owner"))
node_smtp(("SMTP email provider"))
node_llm_provider(("LLM API"))

node_seeker -->|"browses"| node_listing_ui
node_owner -->|"manages listings"| node_listing_ui
node_listing_ui -->|"requests listings"| node_listing_routes
node_listing_routes -->|"dispatches"| node_listing_controller
node_listing_controller -->|"reads and writes"| node_database
node_seeker -->|"submits requests"| node_request_ui
node_owner -->|"manages requests"| node_request_ui
node_request_ui -->|"requests actions"| node_request_controller
node_request_controller -->|"reads and writes"| node_database
node_request_controller -->|"creates notifications"| node_notification_controller
node_seeker -->|"registers or signs in"| node_auth_ui
node_owner -->|"registers or signs in"| node_auth_ui
node_auth_ui -->|"submits credentials"| node_auth_controller
node_auth_controller -->|"reads and writes"| node_database
node_seeker -->|"edits profile"| node_profile_ui
node_owner -->|"edits profile"| node_profile_ui
node_profile_ui -->|"requests profile"| node_profile_controller
node_profile_controller -->|"reads and writes"| node_database
node_seeker -->|"saves properties"| node_favorite_ui
node_favorite_ui -->|"requests favorites"| node_favorite_controller
node_favorite_controller -->|"reads and writes"| node_database
node_seeker -->|"messages owner"| node_chat_ui
node_owner -->|"replies to seeker"| node_chat_ui
node_chat_ui -->|"requests conversations"| node_chat_routes
node_chat_routes -->|"reads and writes"| node_database
node_notification_controller -->|"reads and writes"| node_database
node_seeker -->|"sends inquiry"| node_contact_controller
node_contact_controller -->|"sends email"| node_mail_service
node_auth_controller -->|"sends reset email"| node_mail_service
node_mail_service -.->|"delivers mail"| node_smtp
node_mail_service -.->|"no direct access"| node_database
node_seeker -->|"asks Mira"| node_mira_ui
node_owner -->|"asks Mira"| node_mira_ui
node_mira_ui -->|"submits prompt"| node_bot_controller
node_bot_controller -->|"requests matches"| node_recommend_engine
node_bot_controller -->|"requests valuation"| node_price_model
node_bot_controller -->|"requests chat"| node_llm_service
node_recommend_engine -->|"queries listings"| node_database
node_price_model -->|"uses rate data"| node_location_rates
node_price_model -->|"reads comparable listings"| node_database
node_llm_service -.->|"calls chat API"| node_llm_provider
node_server -->|"mounts routes"| node_listing_routes
node_server -->|"mounts routes"| node_chat_routes
node_server -->|"initializes database"| node_database

click node_listing_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/flats.js"
click node_listing_routes "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/routes/flatRoutes.js"
click node_listing_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/flatController.js"
click node_request_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/requests.js"
click node_request_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/requestController.js"
click node_auth_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/auth.js"
click node_auth_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/authController.js"
click node_profile_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/profile.js"
click node_profile_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/profileController.js"
click node_favorite_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/flats.js"
click node_favorite_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/favoriteController.js"
click node_chat_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/chat.js"
click node_chat_routes "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/routes/chatRoutes.js"
click node_notification_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/notificationController.js"
click node_contact_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/contactController.js"
click node_mail_service "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/services/mailService.js"
click node_mira_ui "https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/bot.js"
click node_bot_controller "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/botController.js"
click node_recommend_engine "https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/recommendEngine.js"
click node_price_model "https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/priceModel.js"
click node_location_rates "https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/data/locationRates.js"
click node_llm_service "https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/llmService.js"
click node_server "https://github.com/asm-hanif/flatmate/blob/main/Backend/server.js"
click node_database "https://github.com/asm-hanif/flatmate/blob/main/Backend/server/db.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_listing_ui,node_listing_routes,node_listing_controller,node_request_ui,node_request_controller toneBlue
class node_auth_ui,node_auth_controller,node_profile_ui,node_profile_controller,node_favorite_ui,node_favorite_controller,node_chat_ui,node_chat_routes,node_notification_controller,node_contact_controller,node_mail_service toneAmber
class node_mira_ui,node_bot_controller,node_recommend_engine,node_price_model,node_location_rates,node_llm_service,node_llm_provider toneMint
class node_server,node_database toneRose
class node_seeker,node_owner,node_smtp toneIndigo
```

## Components

### Property discovery

- [Browse listings](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/flats.js): `Frontend/js/flats.js`
- [Listing routes](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/routes/flatRoutes.js): `Backend/server/routes/flatRoutes.js`
- [Listing management](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/flatController.js): `Backend/server/controllers/flatController.js`
- [Requests dashboard](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/requests.js): `Frontend/js/requests.js`
- [Request management](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/requestController.js): `Backend/server/controllers/requestController.js`

### Accounts and engagement

- [Sign-in and account](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/auth.js): `Frontend/js/auth.js`
- [Authentication](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/authController.js): `Backend/server/controllers/authController.js`
- [Profile](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/profile.js): `Frontend/js/profile.js`
- [Profile management](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/profileController.js): `Backend/server/controllers/profileController.js`
- [Favorites](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/flats.js): `Frontend/js/flats.js`
- [Favorite management](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/favoriteController.js): `Backend/server/controllers/favoriteController.js`
- [Property chat](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/chat.js): `Frontend/js/chat.js`
- [Conversation API](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/routes/chatRoutes.js): `Backend/server/routes/chatRoutes.js`
- [Notifications](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/notificationController.js): `Backend/server/controllers/notificationController.js`
- [Contact and inquiry](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/contactController.js): `Backend/server/controllers/contactController.js`
- [Email delivery](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/services/mailService.js): `Backend/server/services/mailService.js`

### Mira assistant

- [Mira chat](https://github.com/asm-hanif/flatmate/blob/main/Frontend/js/bot.js): `Frontend/js/bot.js`
- [Assistant API](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/controllers/botController.js): `Backend/server/controllers/botController.js`
- [Flat recommendations](https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/recommendEngine.js): `Backend/ai/recommendEngine.js`
- [Price advisor](https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/priceModel.js): `Backend/ai/priceModel.js`
- [Location rate data](https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/data/locationRates.js): `Backend/ai/data/locationRates.js`
- [Optional LLM chat](https://github.com/asm-hanif/flatmate/blob/main/Backend/ai/llmService.js): `Backend/ai/llmService.js`

### Application platform

- [Express application](https://github.com/asm-hanif/flatmate/blob/main/Backend/server.js): `Backend/server.js`
- [PostgreSQL](https://github.com/asm-hanif/flatmate/blob/main/Backend/server/db.js): `Backend/server/db.js`

### Other components

- **Home seeker**
- **Property owner**
- **SMTP email provider**
- **LLM API**

## Connections

- Home seeker → Browse listings: browses
- Property owner → Browse listings: manages listings
- Browse listings → Listing routes: requests listings
- Listing routes → Listing management: dispatches
- Listing management → PostgreSQL: reads and writes
- Home seeker → Requests dashboard: submits requests
- Property owner → Requests dashboard: manages requests
- Requests dashboard → Request management: requests actions
- Request management → PostgreSQL: reads and writes
- Request management → Notifications: creates notifications
- Home seeker → Sign-in and account: registers or signs in
- Property owner → Sign-in and account: registers or signs in
- Sign-in and account → Authentication: submits credentials
- Authentication → PostgreSQL: reads and writes
- Home seeker → Profile: edits profile
- Property owner → Profile: edits profile
- Profile → Profile management: requests profile
- Profile management → PostgreSQL: reads and writes
- Home seeker → Favorites: saves properties
- Favorites → Favorite management: requests favorites
- Favorite management → PostgreSQL: reads and writes
- Home seeker → Property chat: messages owner
- Property owner → Property chat: replies to seeker
- Property chat → Conversation API: requests conversations
- Conversation API → PostgreSQL: reads and writes
- Notifications → PostgreSQL: reads and writes
- Home seeker → Contact and inquiry: sends inquiry
- Contact and inquiry → Email delivery: sends email
- Authentication → Email delivery: sends reset email
- Email delivery → SMTP email provider: delivers mail
- Email delivery → PostgreSQL: no direct access
- Home seeker → Mira chat: asks Mira
- Property owner → Mira chat: asks Mira
- Mira chat → Assistant API: submits prompt
- Assistant API → Flat recommendations: requests matches
- Assistant API → Price advisor: requests valuation
- Assistant API → Optional LLM chat: requests chat
- Flat recommendations → PostgreSQL: queries listings
- Price advisor → Location rate data: uses rate data
- Price advisor → PostgreSQL: reads comparable listings
- Optional LLM chat → LLM API: calls chat API
- Express application → Listing routes: mounts routes
- Express application → Conversation API: mounts routes
- Express application → PostgreSQL: initializes database
