Technical design: Clever Offers
The full design behind Section 2 of my proposal. The prototype in this zip builds a slice of it; the last sections list what it leaves out and how production would handle each piece. Assumptions are labeled A1–A14 and listed at the end. I don't have access to Clever's systems, so this design rests on my best reading of them, which I'd confirm in my first weeks.
The architecture diagram is at the end.
1. Boundaries and modules
One Django service in Clever's existing stack, split into modules. I wouldn't use microservices here: at hundreds of deals a month (A8), the hard problems are getting the data right and seeing when something fails. Scale isn't the problem. I also weighed two alternatives. Pushing more into HubSpot would be faster to set up, but the business rules would stay in automations we can't test, which is the problem today. An investor-deal platform such as InvestorLift, which wholesalers use to send deals to their cash buyers, might be faster still; my guess is it can't carry the pilot because sellers and agents sit outside it, but I'd check in Phase 0 before ruling it out.
| Module | Owns |
|---|---|
| Properties | The property and its standardized address |
| Investors | Investors and their buy boxes |
| Packages | Listing packages: facts, photos, versions |
| Matching | The matching rules and policy, and each send of a package to an investor, with the match reason |
| Offers | Offers and their terms |
| Deals | The deal, its status rules and the timeline |
| Fees | Fees owed and collected |
| Integrations (shared) | The outbox, HubSpot one-way sync, and calls to Communications |
Any module may read another's tables and hold foreign keys to them, but only the owning module's services write them. Business rules live in plain service functions, with no Django signals and no logic in views. Deals owns the deal's status rules (which changes are allowed) and the timeline. The workflows that change several modules at once, such as send, accept, end and close, sit in a thin layer above the modules. Each one locks the deal, then calls the owning module's service for each step, so the rules stay with their owners and the order of steps lives in one place you can read and test. In the prototype that layer is offers/services.py, the top app. A module can be split out later if it ever needs to be.
2. Data model
Postgres only. Core fields are normal columns; flexible parts (extra package details, extra offer terms) are JSONB; photos and documents go in S3.
- Deal: property, agent, status, end reason, listing estimate, and a version that goes up on every status change. The HubSpot sync depends on it (section 7).
- Agents are referenced by the core platform's agent ID, never copied (A1, A10).
- External-ID map on each deal: the core platform's lead ID and
deduplication_id, and the HubSpot deal ID, stored from Phase 1 so the systems can be reconciled. - Package: versioned. A send points to the package version the investor actually saw.
- Buy box: one or more per investor, each with its own geography (states, counties, zips or radius) and criteria (price range, property types, beds and baths, condition, deal types, close timeline). These match the fields Clever's investor application already collects.
- Offer: price, earnest money, close date, contingencies, proof of funds, expiry, with revisions kept as offer versions.
- Deal events: an append-only timeline of every status change, send attempt, policy change and address view.
3. Statuses
Four records have their own status:
| Record | Production | Prototype |
|---|---|---|
| Deal | draft → package ready → out to investors → offers in review → under contract → closed; or ended, with a reason | draft → sent → offer accepted → closed; or ended, with a reason |
| Send | queued → sent → viewed → offered / passed / expired / closed | sent → offered / passed / closed |
| Offer | submitted → accepted / declined / withdrawn / expired, with versions | submitted → accepted / declined |
| Fee | owed → invoiced → collected | not built |
The end reasons are listed with agent, seller withdrew, no acceptable offers and contract fell through. "Listed with agent" is a real outcome, not a failure. Counting it is how the data answers the Section 1 question: does the investor network add revenue, or just move it from agent referral fees to investor fees? In production, a contract falling through sends the deal back to offers in review rather than ending it: when an offer is accepted, the others become "not selected" instead of declined and can be revived until they expire, and a price cut after inspection is a new version of the accepted offer. The deal ends as contract fell through only when no live offer is left. (The prototype ends the deal, and a new deal can then be opened on the same property.)
4. Interfaces
- API to the screens: one API for the Agent Portal and the investor and seller screens. Agents see only their own deals; investors see only deals sent to them. Agents sign in with their existing Agent Portal accounts (A10); investors get new accounts.
- Intake: leads keep arriving through Clever's core API (
contact-ingress, A1). Deals that qualify for investor offers are handed to Offers with the lead ID anddeduplication_id. The same submission sent twice is dropped by that ID. The same property again attaches to the active deal and alerts the agent; a changed price or condition makes a new package version and notifies investors who already have it; a different seller for the same property is flagged for ops. - Outbound: everything sent to another system (Communications for email and SMS, HubSpot) goes through the outbox (section 7). Offers never calls them inside a user's request.
5. Matching
Two steps. First, filter by buy box with plain rules (geography, price, type, condition, timeline), so every match can be explained; that matters for fairness, fair housing and answering investor complaints. Then rank and cap: rank by response rate, close rate, price-cut rate and a fairness rotation, send to the top N, and widen in waves if offers don't come in. Sending to everyone would wear out investors and expose the address more widely, which makes it easier to go around Clever. The ranking weights, caps and wave schedule are a matching policy stored as data and edited in the admin. Policies are versioned, and each send stores its match reason and the policy version, so "why did this investor get this deal?" always has an answer. Ops can pause an investor. I'd keep AI out of the decision about who gets a deal; it might help with ranking later.
6. Moving off today's tools
New deals in 1–2 pilot areas start in the new system; old deals finish the old way. Each automation is switched off when its replacement is ready, and each email or HubSpot update has exactly one sender at a time, old or new, with a switch to go back.
- HubSpot stays for sales work and receives one-way updates. Offers writes only its own fields and stages, and only for deals it owns; staff are told those are system-owned.
- Zaps and Make flows that trigger on those stages are switched off before an area cuts over.
- A daily drift report compares Offers and HubSpot.
- Google Sheets are imported once, with validation (and possibly AI help with free text), and bad rows go to a rejects report. From Phase 1, ops edit investors only in Offers, and a nightly one-way export keeps the investor Sheet current for areas and flows still on the old tools until the last one cuts over. Other Sheets go read-only flow by flow, not all at once.
- Lovable screens: list which are actually used, and retire each one with its flow (A5).
7. When things go wrong
The failures that hurt today are silent: a Zap stops and nobody knows. The design's answer is that nothing is lost, retries are safe as long as the receiver drops repeats (A14 for Communications; for HubSpot the version check below), outages of HubSpot or Communications only delay updates, and anything that keeps failing lands on a list a person reviews.
The prototype builds a thin slice of this section in the integrations app: the outbox row written with each status change, the fixed key, backoff, and a dead list with replay, against a fake HubSpot. It runs one worker by hand, with short demo timings, and it makes the call inside the row's transaction because the fake lives in the same database. Leases, Celery and Redis, reconciliation, Communications and alerts are design only.
Transactional outbox. When a change needs something sent to another system, the service writes the change and an outbox row in the same database transaction. If the transaction rolls back, nothing is sent; if it commits, the work can't be lost. An outbox row holds: deal ID, kind, payload, idempotency key, attempts, next attempt time, status and last error.
The relay. A Celery task claims due rows with FOR UPDATE SKIP LOCKED, so several workers never take the same row. Claiming sets a lease (next_attempt_at = now + timeout) and commits; the outside call happens after that, outside any transaction. If the worker dies mid-call, the lease expires and another worker picks the row up. That's why delivery is at least once. Redis is only the transport for Celery; the Postgres row is the record, so a lost broker message is picked up on the next poll. (This is also why Redis pub/sub isn't used: it drops messages when nobody is listening, which would recreate today's silent failures.)
Safe retries. The idempotency key is fixed when the outbox row is written, for example kind:deal_id:deal_version, so every retry carries the same key. The receiver drops repeats. I'm assuming Communications honors a key we send (A14). If it doesn't, Offers checks its own sent-log before sending, which narrows the duplicate window but can't close it, and I'd raise that with the Systems team. Creates are made safe too: Offers creates its own HubSpot deal in an investor-offers pipeline, carrying the Offers deal ID as a unique property, and uses search-or-upsert rather than a blind create. The returned HubSpot ID is stored when the row is marked sent, and reconciliation flags HubSpot deals that share an Offers deal ID. Notification keys are per send (notify_new_deal:<send_id>), so each investor's message is deduplicated on its own.
HubSpot gets the deal's state, and we keep the order. Each sync sends the deal's current status and version rather than a list of events, so a missed update is fixed by the next one. HubSpot itself won't reject an older update, so Offers enforces the order: the worker reads the deal's current status and version when it sends, skips the send if HubSpot already has that version or newer, and allows one sync in flight per deal. The version is also stored on the HubSpot deal so reconciliation can spot drift. (The prototype's fake HubSpot does the version check itself to keep the demo small.) For state sync, once a newer version is delivered, a deal's older pending or dead rows are superseded, and the dead-list alert counts only rows that are still the newest for their deal.
Backoff and the dead list. Not every failure is worth retrying: a 4xx other than 429 (a bad payload, a deleted deal, revoked access) goes to the dead list at once, while 429s and 5xx back off and honor Retry-After. The lease is longer than the call's timeout, so a slow call isn't picked up twice. Retries back off (about 1 minute, 5, 30, then hourly). After about a day of failures a row is marked dead. The dead list has an owner (Systems on-call), an alert on the oldest row's age, and a replay that's safe to run because of the key.
Inbound outages. If Offers is down when a lead arrives, the core platform's sender retries, and deduplication_id stops duplicates.
Deal-state races. Every change to a deal locks its row first (select_for_update), then checks the status, then writes. Two accepts at once: the second waits, sees the deal already has an accepted offer, and is refused. Late offers and expiry jobs are rejected the same way. Database constraints (one accepted offer per deal, one send per deal and investor) are the backstop. The prototype shows this part in code.
Bad data. Imports are all-or-nothing per row: bad rows go to a rejects report and nothing is half-loaded. Services validate before saving, and constraints catch what slips through.
Reconciliation. A daily job compares deal status and version between Offers and HubSpot, and the open sends against Communications' delivery log. Mismatches go to the same review list as dead outbox rows.
Cutover. Each side effect (an email, a HubSpot update) has exactly one owner during the move, the old automation or the new system, never both. Each cutover step has a kill switch.
Backups. RDS point-in-time recovery, with a restore tested before the pilot areas go live.
8. Team boundaries and ownership
Systems is the home team, with engineers assigned to it (contractors or new hires, based on current priorities and capacity). Experiences owns every screen agents, investors and sellers see; building them is shared by capacity, with Experiences reviewing.
| Piece | Phase | Built by | Long-term owner |
|---|---|---|---|
| Properties, investors and buy boxes, packages, offers, fees | 1–4 | Systems + assigned engineers | Systems |
| Deals: state machine and timeline | 1 | Systems + assigned engineers | Systems |
| Investor matching and sends | 2 | Systems + assigned engineers | Systems (a separate module from today's seller-to-agent matching, same owner) |
| Notifications | 2 | Systems decides what and when; Communications sends | Systems |
| Agent screens (package builder, offer comparison) | 2–3 | Experiences, or Systems in the portal code with Experiences reviewing | Experiences (Agent Portal) |
| Investor screens | 3 | Shared by capacity, in React, Experiences reviewing | Experiences |
| Seller's read-only offer page | 4 | Shared by capacity, in React, Experiences reviewing | Experiences |
| Admin and config (matching policy, investor vetting) | 4 | Systems, in Django admin at first | Systems; may move to Experiences' Internal Tooling |
| One-time investor import from the Sheets | 1 | Systems + assigned engineers | None (runs once) |
| HubSpot one-way sync | 2 | Systems + assigned engineers | Systems |
| Lead intake handoff | 3–4 | Systems (Lead Ingestion), small change | Systems |
| Pilot tooling | 0 | Me, with an engineer reviewing | Retired once replaced |
9. Other
- Fees and the Section 1 numbers: the fee record (owed → invoiced → collected) plus the deal's end reason give revenue per deal and how often an investor deal replaces an agent listing.
- Notifications (a new deal for an investor, a new offer for an agent, an offer about to expire) are triggered by status changes. They're queued through the outbox and sent by the Systems team's existing Communications service, honoring consent and each investor's notification preferences.
- AI in the product: drafting the listing package from the agent's photos and notes, for the agent to approve; reading offers that arrive by email or PDF into the standard offer format; parsing free-text buy boxes during the Sheets import; and summarizing the offer comparison in plain language for the agent to share with the seller. A person checks each result, and matching stays rule-based so every send can be explained.
10. Security and compliance
- Logins and roles: agents through the Agent Portal's existing accounts; investors with new accounts; staff through the admin with permissions.
- Address protection: investors see the area and photos first and the full address only after accepting terms (including non-circumvention). Every address view is logged. When to reveal it is a Product decision. Package photos and notes are screened for the address and seller contact details before the reveal, and investors never get seller contact details through Clever.
- Personal data stays out of logs beyond the deal ID.
- The event log is append-only: no edits or deletes through the app. It also records matching-policy changes and address views.
- Topics for legal review, not engineering decisions: fair housing in matching, texting consent, state wholesaling and licensing rules, vetting investors and proof of funds, how agent and investor fees interact, investor agreement terms, and how long records are kept.
11. Hosting and observability
Django web and Celery workers on AWS ECS with RDS Postgres and S3, all in Terraform, managed with DevOps; CI on GitHub Actions (A9). Datadog and Sentry, with the deal ID on every log line, job and outgoing call so one deal can be traced end to end. Secrets in a secrets manager (an assumption about tooling). Production runs gunicorn with DEBUG off.
12. Corners cut in the prototype
| Left out or simplified | How production handles it |
|---|---|
| Outbox built as a thin slice: one worker command run by hand, demo backoff (10/30/90 s, dead after 4 tries), no leases | Celery workers on ECS with leases, production backoff and an owned, alerted dead list, as in section 7 |
| A fake HubSpot table; no Communications or notifications | The real HubSpot API, one-way and state-based; Communications through the outbox |
| Intake endpoint and duplicate handling | Behind contact-ingress, using deduplication_id; same property attaches to the active deal |
| Sheets import and rejects report | One-time import with validation; ops then edit investors only in Offers, and a nightly export keeps the Sheet current until the last area cuts over |
| React screens | Agent screens in the Agent Portal; investor and seller screens in React, owned by Experiences |
| Real logins and roles; "view as" lets anyone act as anyone | Agent Portal accounts for agents, new accounts for investors |
| Full addresses shown to investors | Hidden until terms are accepted; views logged |
| Ranking by close rate only; cap N is the only setting | Weighted ranking, waves, a versioned policy with per-market overrides |
| No policy versions; sends store the reason only | Each send stores the policy version |
| No package versions; sends point to the deal | Sends point to the package version seen |
| No offer revisions, withdrawals or expiry; a contract falling through ends the deal | Offer versions with history; falling through returns the deal to offers in review |
| Price compared to the listing estimate, not net to seller | Net to seller after fees, concessions and timing |
| No fees | Fee state machine feeding the Section 1 numbers |
| No external-ID map | Lead ID, deduplication_id and HubSpot ID on each deal |
Offer.deal is a copy of the send's deal, kept in step by the service |
A composite foreign key |
| Photos, the seller's offer page, the "different seller, same property" review | S3 with signed URLs; a read-only seller page; an ops review queue |
Django runserver, DEBUG on, placeholder secret key, ALLOWED_HOSTS=*, demo admin password, reachable on your network while running |
gunicorn behind a load balancer, DEBUG off, secrets in a secrets manager, real host names |
| Terraform, CI, Datadog, Sentry | As in section 11 |
| The deal lock is tested for order, plus one test that races two real accepts; no load test | A load test of the accept path before launch |
13. Assumptions
Each is marked observed (seen on Clever's public site or job postings), inferred, or assumed.
| # | Assumption | Basis |
|---|---|---|
| A1 | Seller leads come in through Clever's core API (contact-ingress), and the core platform matches sellers to agents. |
Observed (form code), inferred (matching) |
| A2 | HubSpot is the CRM for sellers and deals; pipeline stages stand in for transaction status. | Observed (Meetings), inferred (pipeline) |
| A3 | Google Sheets hold the investor roster, buy boxes and an offer tracker; leads are also written to a Sheet through Make. | Observed (Make → Sheet), inferred (the rest) |
| A4 | Zapier and Make move data between HubSpot, Sheets, email and SMS, and hold real routing logic. | Observed (Make), inferred (Zapier) |
| A5 | Some agent, investor or ops screens are Lovable apps with their own databases. | Assumed |
| A6 | Staff do the vetting, investor selection, package building and offer collection by hand. | Observed (site copy), inferred (details) |
| A7 | Clever earns only at close: a referral fee from agents or a fee from investors. Sellers pay nothing. | Observed (site and terms) |
| A8 | Volume is hundreds of deals a month. | Assumed |
| A9 | The stack is Django, Postgres, Celery, Redis and React on AWS ECS and RDS, with Terraform, GitHub Actions, Datadog and Sentry. | Observed (job postings) |
| A10 | The Agent Portal (Experiences) is a React app agents already sign in to. There's no investor portal. | Assumed |
| A11 | Teams work in 6-week cycles with 2 weeks of planning. | Observed (job postings) |
| A12 | Engineers own testing; no dedicated QA roles are open today (to confirm). | Inferred (careers page, job postings) |
| A13 | No team has spare capacity today. | Assumed |
| A14 | The Communications service drops repeat messages using a key we send. | Assumed (fallback in section 7) |
Architecture diagram
