# ainaasim/ai-property-lead-automation architecture

> Architecture diagram of the GitHub repository ainaasim/ai-property-lead-automation, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ainaasim/ai-property-lead-automation
- Repository: https://github.com/ainaasim/ai-property-lead-automation

## Overview

#### Purpose and Delivery Model
This is a documented architecture for a real-estate lead-nurturing automation platform. It captures SpareRoom leads, conducts AI-assisted follow-up over portal and WhatsApp channels, coordinates viewings/deposits, and synchronizes lead state into ClickUp CRM. The repository currently exposes documentation rather than executable workflow, scraper, or schema artifacts: `README.md` and `Case_Study_Sila_Estates.md`.

#### Entry Points
Operational triggers are n8n webhook and scheduled-workflow entry points described in `README.md`:
- Portal scraper webhook for inbound SpareRoom enquiries.
- Ten-minute scheduled job for outbound WhatsApp initiation.
- WhatsApp provider webhook for inbound replies.
- Internal workflow callouts for CRM synchronization.
- Scheduled 30-minute retry processing for failed ClickUp updates.

#### Lead and Inventory Data Boundary
Supabase/PostgreSQL is the system-of-record boundary. The documented schema models:
- Leads: identity/contact information, portal advert association, lifecycle status, booking state, and reservation response.
- Rooms: advert-number-keyed room inventory, pricing, amenities, address, and availability.
- CRM retry records: failed ClickUp update payloads, errors, retry counters, and timestamps.
Workflow stages query leads and rooms before messaging, then persist/update status needed for future conversations and follow-up. Schema details and provisioning instructions are defined in `README.md`.

#### Inbound Portal Lead Processing
The portal flow accepts scraper-produced inbound content, removes HTML artifacts, extracts lead contact data, and matches the enquiry against current room inventory. It then calls OpenAI GPT-4o to create a personalized response and includes a shortened WhatsApp handoff link. This is the transition from portal-originated interest to a trackable WhatsApp conversation, as described in `README.md`.

#### WhatsApp Engagement and Conversation Control
A scheduled outbound stage finds eligible phone numbers that have not yet received a WhatsApp message, selects a room-specific template, and dispatches through WATI/Woztell. A separate inbound WhatsApp stage receives replies, classifies intent—booking, portfolio, callback, or FAQ—maintains conversation state, and uses GPT-4o for answers. These stages make WhatsApp the primary ongoing engagement channel. Provider/API responsibilities are documented in `README.md`.

#### Viewing, Deposit, and CRM Synchronization
Viewing coordination is handled by a scheduled reminders flow that reads Calendly scheduling data and sends warnings/reminders. Downstream workflows invoke a centralized ClickUp sync engine to update custom CRM fields such as price, room type, and deposit status, and to attach conversation transcripts. Failed ClickUp API operations are durably recorded and retried, separating customer-facing automation from CRM delivery reliability. These integrations are specified in `README.md`.

#### Runtime and External Services
n8n is the orchestration runtime. Supabase provides hosted PostgreSQL persistence. Selenium and Playwright are described as browser-automation runtimes for SpareRoom and WhatsApp extraction. External service boundaries include OpenAI GPT-4o, WATI/Woztell WhatsApp APIs, Short.io link shortening, Calendly, and ClickUp. Required credentials are environment-provided API keys/tokens, documented in `README.md`.

Main entry points: [`README.md`](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md) (Portal lead processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_automation["n8n automation"]
  node_portal_scraper["Portal scraper webhook<br/>n8n trigger<br/>[README.md]"]
  node_portal_processing["Portal lead processing<br/>n8n workflow<br/>[README.md]"]
  node_outbound_whatsapp["10-minute WhatsApp initiation<br/>scheduled workflow<br/>[README.md]"]
  node_inbound_whatsapp["WhatsApp reply webhook<br/>n8n trigger<br/>[README.md]"]
  node_conversation_control["Conversation control<br/>n8n workflow<br/>[README.md]"]
  node_viewing_reminders["Viewing reminders<br/>scheduled workflow<br/>[README.md]"]
  node_crm_sync["ClickUp sync engine<br/>n8n workflow<br/>[README.md]"]
  node_retry_processing["30-minute CRM retry<br/>scheduled workflow<br/>[README.md]"]
end

subgraph group_data["System of record"]
  node_leads[("Leads<br/>PostgreSQL table<br/>[README.md]")]
  node_rooms[("Rooms inventory<br/>PostgreSQL table<br/>[README.md]")]
  node_crm_retries[("CRM retry records<br/>PostgreSQL table<br/>[README.md]")]
  node_supabase[("Supabase PostgreSQL<br/>persistence platform<br/>[README.md]")]
end

subgraph group_external["External services"]
  node_spareroom["SpareRoom<br/>lead portal<br/>[README.md]"]
  node_browser_automation["Selenium / Playwright<br/>browser automation<br/>[README.md]"]
  node_openai["OpenAI GPT-4o<br/>AI service<br/>[README.md]"]
  node_whatsapp_provider["WATI / Woztell<br/>WhatsApp API<br/>[README.md]"]
  node_shortio["Short.io<br/>link shortener<br/>[README.md]"]
  node_calendly["Calendly<br/>scheduling service<br/>[README.md]"]
  node_clickup["ClickUp<br/>CRM<br/>[README.md]"]
end

node_spareroom -->|"portal content"| node_browser_automation
node_browser_automation -->|"inbound enquiry"| node_portal_scraper
node_portal_scraper -->|"trigger"| node_portal_processing
node_portal_processing -->|"create or update"| node_leads
node_portal_processing -->|"match advert"| node_rooms
node_portal_processing -->|"personalized response"| node_openai
node_portal_processing -->|"handoff link"| node_shortio
node_outbound_whatsapp -->|"eligible leads"| node_leads
node_outbound_whatsapp -->|"room template data"| node_rooms
node_outbound_whatsapp -->|"send initiation"| node_whatsapp_provider
node_whatsapp_provider -->|"inbound reply"| node_inbound_whatsapp
node_inbound_whatsapp -->|"trigger"| node_conversation_control
node_conversation_control -->|"conversation and intent state"| node_leads
node_conversation_control -->|"FAQ answers"| node_openai
node_conversation_control -->|"send reply"| node_whatsapp_provider
node_calendly -->|"scheduling data"| node_viewing_reminders
node_viewing_reminders -->|"warnings and reminders"| node_whatsapp_provider
node_portal_processing -.->|"lead update"| node_crm_sync
node_conversation_control -.->|"state and transcript"| node_crm_sync
node_viewing_reminders -.->|"viewing status"| node_crm_sync
node_crm_sync -->|"CRM fields and transcript"| node_clickup
node_crm_sync -.->|"record failure"| node_crm_retries
node_retry_processing -->|"load pending retries"| node_crm_retries
node_retry_processing -->|"retry update"| node_clickup
node_leads -->|"stored in"| node_supabase
node_rooms -->|"stored in"| node_supabase
node_crm_retries -->|"stored in"| node_supabase

click node_portal_scraper "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_portal_processing "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_outbound_whatsapp "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_inbound_whatsapp "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_conversation_control "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_viewing_reminders "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_crm_sync "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_retry_processing "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_leads "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_rooms "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_crm_retries "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_supabase "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_spareroom "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_browser_automation "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_openai "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_whatsapp_provider "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_shortio "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_calendly "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"
click node_clickup "https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md"

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_portal_scraper,node_portal_processing,node_outbound_whatsapp,node_inbound_whatsapp,node_conversation_control,node_viewing_reminders,node_crm_sync,node_retry_processing toneBlue
class node_leads,node_rooms,node_crm_retries,node_supabase toneAmber
class node_spareroom,node_browser_automation,node_openai,node_whatsapp_provider,node_shortio,node_calendly,node_clickup toneMint
```

## Components

### n8n automation

Webhook and scheduled workflows.

- [Portal scraper webhook](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): n8n trigger · Accepts SpareRoom enquiry content. · `README.md`
- [Portal lead processing](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): n8n workflow · Cleans, matches, and responds to new enquiries. · `README.md`
- [10-minute WhatsApp initiation](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): scheduled workflow · Finds leads not yet contacted on WhatsApp. · `README.md`
- [WhatsApp reply webhook](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): n8n trigger · Receives ongoing lead replies. · `README.md`
- [Conversation control](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): n8n workflow · Classifies intent and maintains conversation state. · `README.md`
- [Viewing reminders](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): scheduled workflow · Sends scheduling warnings and reminders. · `README.md`
- [ClickUp sync engine](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): n8n workflow · Updates CRM fields and attaches transcripts. · `README.md`
- [30-minute CRM retry](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): scheduled workflow · Retries failed ClickUp operations. · `README.md`

### System of record

- [Leads](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): PostgreSQL table · Lead identity, lifecycle, booking, and reservation state. · `README.md`
- [Rooms inventory](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): PostgreSQL table · Advert-keyed availability and room details. · `README.md`
- [CRM retry records](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): PostgreSQL table · Durable failed-update payloads and retry metadata. · `README.md`
- [Supabase PostgreSQL](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): persistence platform · System-of-record database boundary. · `README.md`

### External services

- [SpareRoom](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): lead portal · `README.md`
- [Selenium / Playwright](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): browser automation · Extracts portal and WhatsApp content. · `README.md`
- [OpenAI GPT-4o](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): AI service · Generates personalized replies and answers. · `README.md`
- [WATI / Woztell](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): WhatsApp API · Dispatches and receives WhatsApp messages. · `README.md`
- [Short.io](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): link shortener · Creates WhatsApp handoff links. · `README.md`
- [Calendly](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): scheduling service · `README.md`
- [ClickUp](https://github.com/ainaasim/ai-property-lead-automation/blob/main/README.md): CRM · `README.md`

## Connections

- SpareRoom → Selenium / Playwright: portal content
- Selenium / Playwright → Portal scraper webhook: inbound enquiry
- Portal scraper webhook → Portal lead processing: trigger
- Portal lead processing → Leads: create or update
- Portal lead processing → Rooms inventory: match advert
- Portal lead processing → OpenAI GPT-4o: personalized response
- Portal lead processing → Short.io: handoff link
- 10-minute WhatsApp initiation → Leads: eligible leads
- 10-minute WhatsApp initiation → Rooms inventory: room template data
- 10-minute WhatsApp initiation → WATI / Woztell: send initiation
- WATI / Woztell → WhatsApp reply webhook: inbound reply
- WhatsApp reply webhook → Conversation control: trigger
- Conversation control → Leads: conversation and intent state
- Conversation control → OpenAI GPT-4o: FAQ answers
- Conversation control → WATI / Woztell: send reply
- Calendly → Viewing reminders: scheduling data
- Viewing reminders → WATI / Woztell: warnings and reminders
- Portal lead processing → ClickUp sync engine: lead update
- Conversation control → ClickUp sync engine: state and transcript
- Viewing reminders → ClickUp sync engine: viewing status
- ClickUp sync engine → ClickUp: CRM fields and transcript
- ClickUp sync engine → CRM retry records: record failure
- 30-minute CRM retry → CRM retry records: load pending retries
- 30-minute CRM retry → ClickUp: retry update
- Leads → Supabase PostgreSQL: stored in
- Rooms inventory → Supabase PostgreSQL: stored in
- CRM retry records → Supabase PostgreSQL: stored in
