Demo only. No real logins, DEBUG is on and the secret key is a placeholder. All data is made up. New here? Follow the step-by-step test walkthrough in the README, or read the technical design.
Clever Offers prototype Agent: Dana Whitfield · Investor: Alan Brightwater · Switch Agent deals Investor deals

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.

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

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.

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

10. Security and compliance

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

Architecture diagram: who calls what, which system owns which data, and which calls go through the outbox