Engineering
aleoflow architecture
A modular full-stack SSR marketplace on TanStack Start. Routes, modules, adapters, secrets, and how to extend.
Routes
| Route | Purpose |
|---|---|
| / | County-aware discovery home: search, featured pro, categories, newsletter, for-pros CTA. |
| /categories/$slug | SEO category page with filters (city, availability, rating, verified) and provider cards. |
| /pros/$slug | Indexable business profile: hours, services, reviews, FAQs, sticky Request Service CTA. |
| /request/$proSlug | Multi-step guided intake with local progress save and reference number. |
| /for-pros | Business value prop + onboarding application form. |
| /pro/dashboard | Demo business portal: Overview, Leads, Profile, Services, Reviews, Analytics, Settings. |
| /about, /privacy, /terms | Static legal/about pages. |
| GET /api/v1/businesses | Filtered business list (REST). |
| GET /api/v1/businesses/$slug | Single business (REST). |
| POST /api/v1/leads | Public lead submission (REST). |
| POST /api/v1/chat | Custom chat widget start/send (REST). |
| POST /api/v1/webhooks/lead-status | HMAC-verified lead status webhook (REST). |
Modules
| File | Responsibility |
|---|---|
| src/lib/db/types.ts | Typed domain models (Market, City, Category, Business, Lead, …). |
| src/lib/db/seed.ts | Seeded local JSON (markets, categories, businesses, leads). |
| src/lib/db/adapters.ts | Adapter interfaces: Database, Email/SMS, CRM, Analytics, Geocoding, ReviewSource. |
| src/lib/db/demo.ts | In-memory demo repository implementing the Database adapter. |
| src/lib/db/repo.ts | Factory wiring adapters from env; falls back to demo with no credentials. |
| src/lib/chat.server.ts | Chat adapter: demo in-memory + live Conversations API (GHL_API_KEY/GHL_LOCATION_ID). |
| src/lib/chat.functions.ts | Server functions for the custom chat widget: startChat, sendChatMessage, getChatMessages. |
| src/lib/aleo.functions.ts | Server functions: search, getBusiness, submitLead, updateLeadStatus, etc. |
| src/lib/schemas.ts | Zod schemas shared by server functions and REST routes. |
| src/lib/rate-limit.ts | In-memory rate-limit adapter + client IP helper. |
Adapters
Each external concern is behind an interface. The demo implementation keeps preview working with no credentials.
| Adapter | Demo | Real (with secret) |
|---|---|---|
| Database | In-memory store | DATABASE_URL → Postgres |
| No-op | RESEND_API_KEY → Resend | |
| SMS | No-op | TWILIO_ACCOUNT_SID / TWILIO_AUTH_TOKEN → Twilio |
| CRM | No-op | GHL_API_KEY / GHL_LOCATION_ID → CRM + Conversations API |
| Chat | Branded local echo | GHL_API_KEY / GHL_LOCATION_ID → Conversations API |
| Geocoding | Static MN coords | GOOGLE_MAPS_API_KEY → Google Maps |
| Review source | Seed reviews + reputation widget | Provider review API |
Secrets
All optional. The app runs in demo mode without any of them.
Postgres database
Persists businesses, leads, subscriptions. Without it the in-memory demo store is used.
DATABASE_URLCRM (contact + lead sync)
Sync contacts and log leads to the connected CRM.
GHL_API_KEYCRM location
Required alongside the CRM key.
GHL_LOCATION_IDEmail notifications
Sends the owner a lead notification and the homeowner a confirmation.
RESEND_API_KEYSMS (lead alerts)
Texts owners new lead alerts.
TWILIO_ACCOUNT_SIDSMS auth
Required alongside the Twilio account SID.
TWILIO_AUTH_TOKENGeocoding + maps
Resolves ZIP codes to coordinates and renders maps.
GOOGLE_MAPS_API_KEYLead-status webhook HMAC
Verifies POST /api/v1/webhooks/lead-status signatures.
WEBHOOK_SIGNING_SECRETAdding a new market
- Add a
Market+ itsCityentries tosrc/lib/db/seed.ts. - Seed businesses referencing the new
marketId/cityId. - Update
DEFAULT_MARKETinsrc/lib/constants.tsif it becomes the default.
Adding a new category
- Add a
Categorytosrc/lib/db/seed.ts. - The category page at
/categories/$slugpicks it up automatically.
Adding a new business
- Add a
BusinesstobusinessSeedwith a unique slug. - Mark
sample: trueuntil details are confirmed. - It appears in search, category pages, and the home grid automatically.