How walphi/auro-app works
1. This repo is a multi-surface AI real-estate platform, not a single app. The production runtime is centered on Netlify serverless functions, a Supabase-backed data layer, and external AI/communications services. The root also contains extensive operational scripts and diagnostics, but those are support tooling rather than user-facing runtime.
2. There are two main client surfaces:
- src/ is the root React app, which includes a dashboard plus marketing pages.
- sites/ is a separate Vite React app for generated “agent sites” and their section-based rendering system.
Both are static frontends that consume APIs and content from the backend layer.
3. The backend is mostly in netlify/functions/ with one edge function in netlify/edge-functions/. These handlers expose the product’s API surface: WhatsApp, VAPI, RAG, listings sync, OCR, site generation, CRM sync, image proxying, booking notifications, and tenant/agent site lookup. This is the primary boundary where all external requests enter the system.
4. Core AI orchestration lives under lib/. Important subsystems include:
- lib/gemini.ts for model access.
- lib/aiBuilder/ for generating agent sites/content.
- lib/rag/ for embeddings, prompts, and retrieval helpers.
- lib/agentLogic.ts, lib/crmRouter.ts, lib/notificationOrchestrator.ts, and tenant config helpers for routing requests across tenants, channels, and downstream actions.
These modules are shared by the Netlify handlers rather than serving directly.
5. The main conversational flow is channel-driven. Incoming WhatsApp or VAPI events hit their respective Netlify functions, which then:
- identify tenant/agent context,
- fetch relevant knowledge or listing data,
- call Gemini or other tools,
- persist lead/session state,
- and respond back through Twilio/VAPI.
This is the most important request/response loop in the system.
6. Retrieval-Augmented Generation is a distinct subsystem. It has ingestion, learning, query, delete, and embedding-processing handlers (rag-ingest, rag-learn, rag-query, rag-delete, process-embeddings) plus supporting SQL/schema files. The knowledge base is tenant-aware and appears to index project/listing documents, campaign history, and other real-estate content used by the assistants.
7. CRM and lead management form another boundary. Functions such as update-lead, crm sync handlers, HubSpot OAuth/webhook handlers, and Bitrix webhooks connect external sales systems to the platform. The data model tracks leads, intents, bookings, and agent activity so conversational events can be mirrored into CRM workflows.
8. Real-estate listings and media are handled as a separate ingestion/sync pipeline. There are functions for scraping listings and site style, syncing listings, formatting images, proxying images, and updating listing records. This pipeline feeds both the AI assistants and the generated sites, rather than being just a content feed.
9. Agent-site generation is its own product subdomain. The backend can build or rebuild a site from structured data and templates, while the sites/ app renders the final public-facing experience with reusable sections like hero, services, listings, testimonials, and contact. The generated site content is stored and later served through lookup functions such as get-agent-site.
10. Persistence is primarily Supabase/Postgres. The repo includes both supabase/migrations/ and standalone sql/ scripts, indicating a mix of formal migrations and one-off schema/data fixes. The schema covers tenants, profiles, projects, RAG chunks, leads, bookings, agent configs, and site-related tables, which makes tenancy a first-class architectural boundary.
11. Operationally, the repository includes many scripts for validation, backfills, simulation, image cleanup, DB checks, and webhook testing. These are important for maintenance and verification, but they sit outside the runtime request path.
12. Deployment is Netlify-centric. The repo ships static frontend builds plus serverless functions, with environment variables for Gemini, Twilio, and optional VAPI verification. External dependencies are therefore not embedded services but runtime integrations orchestrated at the function layer.
Main entry points: orchestrator.ts Netlify API · supabase_schema.sql Schema · whatsapp.ts WhatsApp Flow · vapi.ts VAPI Flow
Components 21
Frontends
Static React surfaces for dashboard, marketing, and generated agent sites.
- Dashboard · Root React app with admin/dashboard and marketing pages.
src/App.jsx - Marketing · Public-facing marketing pages and conversion components.
src/marketing/pages/Home.jsx - Agent Sites · Generated public agent-site frontend with section-based rendering.
sites/src/App.tsx - Sections · Reusable section renderer and page blocks for generated sites.
sites/src/components/SectionRenderer.tsx
Runtime API
Netlify handlers that expose the product's request/response boundary.
- Netlify API · Primary serverless API boundary for chat, RAG, listings, CRM, OCR, and site generation.
netlify/functions/orchestrator.ts - WhatsApp Flow · WhatsApp entrypoint and downstream messaging handlers.
netlify/functions/whatsapp.ts - VAPI Flow · Voice assistant entrypoint and webhook handling.
netlify/functions/vapi.ts - RAG API · Ingest, learn, query, delete, and embed-processing handlers for tenant knowledge.
netlify/functions/rag-api.ts - CRM Sync · Lead updates, HubSpot/Bitrix sync, and booking notifications.
netlify/functions/update-lead.ts - Site Build · Agent-site generation, lookup, and rebuild handlers.
netlify/functions/build-site-background.ts - Listings Sync · Listing scraping, sync, image formatting, and image proxy handlers.
netlify/functions/sync-listings.ts
Shared Core
Reusable orchestration, AI, tenant, CRM, and media logic used by handlers.
- Site Builder · Generates agent sites and content from structured data and prompts.
lib/aiBuilder/buildSite.ts - Gemini · Shared model access layer for LLM calls.
lib/gemini.ts - RAG Core · Embedding, prompt, and retrieval helpers used by knowledge functions.
lib/rag/rag-utils.ts - Tenant Logic · Tenant config, agent logic, and channel routing across subsystems.
lib/tenantConfig.ts - CRM Logic · HubSpot, Bitrix, and lead-routing helpers.
lib/crmRouter.ts - Media Core · Image processing, proxying, and media helpers shared by handlers.
lib/mediaHandler.ts
Data Layer
Supabase/Postgres schema, migrations, and SQL scripts that define tenancy and persistence.
- Schema · Tenants, profiles, projects, leads, bookings, RAG chunks, and site tables.
supabase_schema.sql - Migrations · Formal schema evolution for tenancy, RAG, profiles, and WhatsApp numbers.
supabase/migrations/20260118000000_add_tenants_and_lead_tenant_id.sql - SQL Scripts · One-off schema, data, and backfill scripts for production fixes.
sql/create_site_tables.sql
Ops Tooling
Support scripts, diagnostics, and maintenance utilities outside the main runtime path.
- Ops Scripts · Validation, debugging, simulation, and backfill tooling.
scripts/rag_eval.ts
Connections 28
- Dashboard → Netlify API: dashboard data · Dashboard UI consumes backend APIs for admin and tenant operations.
- Marketing → Netlify API: lead capture · Marketing pages feed waitlist and inquiry traffic into the backend.
- Agent Sites → Site Build: render data · Generated sites fetch agent-site content and configuration from lookup handlers.
- Sections → Agent Sites: compose UI · Section components build the public site experience.
- Netlify API → WhatsApp Flow: route events · Netlify functions route inbound WhatsApp traffic to conversation handlers.
- Netlify API → VAPI Flow: route events · Netlify functions route voice interactions to VAPI handlers.
- Netlify API → RAG API: knowledge ops · API surface exposes tenant-aware RAG ingestion and query endpoints.
- Netlify API → CRM Sync: lead sync · API surface exposes lead and CRM integration endpoints.
- Netlify API → Site Build: site ops · API surface exposes generation, lookup, and rebuild endpoints for agent sites.
- Netlify API → Listings Sync: listing ops · API surface exposes scraping, sync, OCR, and image utilities.
- WhatsApp Flow → Tenant Logic: identify tenant · WhatsApp requests resolve tenant and agent context before responding.
- VAPI Flow → Tenant Logic: identify tenant · Voice requests resolve tenant and agent context before responding.
- WhatsApp Flow → RAG Core: retrieve knowledge · Chat flow queries tenant knowledge and listing context.
- VAPI Flow → RAG Core: retrieve knowledge · Voice flow queries tenant knowledge and listing context.
- WhatsApp Flow → Gemini: generate reply · Chat flow calls the model for response generation and summarization.
- VAPI Flow → Gemini: generate reply · Voice flow calls the model for response generation and tool use.
- CRM Sync → CRM Logic: sync leads · CRM handlers normalize and route events into external sales systems.
- Site Build → Site Builder: build site · Site generation handlers invoke the site builder pipeline.
- Site Builder → Gemini: generate content · Builder uses the model to synthesize content and structure.
- Listings Sync → Media Core: process media · Listing pipeline formats and proxies property images.
- RAG API → Schema: store chunks · Retrieval system persists embeddings and knowledge records in Postgres.
- CRM Sync → Schema: store leads · Lead and booking state is mirrored into the database.
- Site Build → Schema: store sites · Generated site content and configuration are persisted for later lookup.
- Listings Sync → Schema: store listings · Listings and media metadata are written back to the database.
- Migrations → Schema: evolve schema · Migrations define the canonical database evolution path.
- SQL Scripts → Schema: fix schema · One-off SQL scripts patch and backfill production data structures.
- Ops Scripts → Netlify API: verify runtime · Maintenance scripts exercise and diagnose the production handlers.
- Ops Scripts → Schema: inspect data · Support tooling checks tables, columns, and records.