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

Clever Offers prototype

A working slice of the investor-offers system from my proposal. An agent builds a package, the system matches it to investors and says why, sends it to the top few, investors make offers, and the agent compares them and accepts one. Every record has one owner, the deal's status lives in one place with a timeline, and each status change reaches HubSpot through an outbox. If HubSpot is down, the update waits and retries; it doesn't get lost.

Demo-only shortcuts

I took these on purpose so the prototype runs with one command. None of them would ship.

Run it

docker compose up --build

Open http://localhost:8000/. The first start migrates and loads the demo data. Later starts leave your changes alone. This README and the technical design are also linked from the yellow banner on every page (/docs/readme/ and /docs/technical-design/).

A short walkthrough

You start as agent Dana Whitfield and investor Alan Brightwater. The header shows both, with a Switch link.

  1. Matching with reasons. On Agent deals, open 412 Sample Oak Lane (a draft) and click Find investors. Six investors match, ranked by close rate, each with the reason. The top 5 are marked "Will be sent" and one is "Over cap". Tessa Underhill would match too, but she's paused in the admin, so she isn't listed. If you lower the send cap before sending (in the admin, open Matching policies, change the number in the Cap column and click Save), more investors show "Over cap".
  2. Send. Click Send. The deal moves to "Sent" and the timeline records who it went to. Sending again, from a double-click or two people at once, creates nothing new and says "Already sent". The status now also says "HubSpot sync: 1 pending / 0 dead". That's the outbox: the deal moved on without waiting for HubSpot, and the update is queued. Nothing sends it until the worker runs, so run docker compose exec web python manage.py run_outbox and reload; it says "up to date". Run it again after the steps below whenever you want the line cleared.
  3. An investor offers. Go to Investor deals (you're Alan). Open 88 Example Court, which says "No response yet", and submit an offer.
  4. Compare and accept. Go back to Agent deals → 88 Example Court → Compare offers. There are three offers side by side, each against the listing estimate, labeled "before costs, not net to seller". Accept one. The others are declined, and the timeline says so.
  5. Close. On the deal page, under Close or end this deal, choose Closed (sale completed) and click Save outcome. The status changes to "Closed" and the timeline shows every step.
  6. See the rest. Switch to agent Marcus Oyelaran (a deal with an accepted offer, and a closed one) or Priya Raman-Cole (two ended deals; the deal list shows each reason, and on "contract fell through" the accepted offer stays accepted). Switch to investor Fiona Garrity to see a declined offer and a send that closed when another offer was accepted.
  7. Break HubSpot on purpose (about a minute). HubSpot here is a stand-in table.
    1. Run docker compose exec web python manage.py run_outbox once so nothing from the earlier steps is still waiting.
    2. In the admin, open Integration settings, tick the box in the Hubspot failing column and click Save.
    3. Change a deal's status. For example, Switch to agent Marcus Oyelaran and open 1500 Placeholder Drive. It starts at "Offer accepted" with "HubSpot sync: up to date". Under Close or end this deal, choose Closed (sale completed) and click Save outcome. The deal page now says "Closed" and "HubSpot sync: 1 pending / 0 dead".
    4. Run docker compose exec web python manage.py run_outbox --now four times. The first three runs fail and schedule a retry; the fourth marks the message dead. The deal page says "HubSpot sync: 0 pending / 1 dead".
    5. In the admin's Integration settings, untick the box and click Save. Then open Outbox messages, click Dead under the filter on the right, tick the row, choose Replay selected dead messages in the Action list and click Go.
    6. Run docker compose exec web python manage.py run_outbox once more. The message is sent, Fake hub spot deals shows the deal as "closed", and the deal page says "up to date". Replaying it again does no harm.
  8. Start your own deal. New deal on the agent's list creates a property, a draft deal and its package in one step. Then run steps 1 and 2 on it. A draft isn't sent to HubSpot; the first update goes when it's sent to investors.
  9. Admin. Deals, sends, offers, the timeline and the outbox are read-only in the admin. Investors (including the pause flag), buy boxes, the send cap and the HubSpot fail switch are editable; the send cap and the fail switch can be changed right on their list pages.

How the 5 apps map to the 8 production modules

Dependencies run one way: integrations ← deals ← investors ← matching ← offers. A lower app never imports a higher one.

Prototype app Production modules What it owns here
integrations The shared Integrations piece The outbox, the retry worker, the fail switch, and a fake HubSpot. Imports nothing from the other apps.
deals Properties, Packages, Deals Properties, packages, deals, the deal status rules and the timeline
investors Investors Investors (with the pause flag) and buy boxes. There are no write rules yet; staff edit them in the admin.
matching Matching match(), the send cap, and sends with their match reasons
offers Offers, plus the workflow layer Offers, and the workflows that change several apps at once (send, offer, pass, accept, close, end)
(not built) Fees Fee tracking. See docs/technical-design.md.

The workflows sit in offers because it's the top app, the only one allowed to import all the others. The technical design describes the same thing: a thin workflow layer above the modules.

Code tour

Failure handling in the code

The outbox. Every deal status change writes an outbox row in the same transaction, so the change and the "tell HubSpot" work commit or roll back together. A worker command sends due rows, waits longer after each failure (10, 30 and 90 seconds here, short for the demo), and marks a row dead after four failed tries. Each row's key is fixed when it's written (hubspot_deal_status:<deal>:<version>), so sending it twice does no harm.

Two simplifications to know about:

Left in the written design: Celery and Redis (here the worker is a command you run), leases so several workers can share the list, reconciliation, email and SMS, and alerts.

The integrity guards. These keep the data right when people click twice, act at the same time, or try something out of order.

Corners cut

The full list, with how production would handle each one, is in docs/technical-design.md. The biggest:

Notes on the code

I wrote it so someone new to the codebase, or an AI tool, can follow it on a first read: plain service functions you can call and test, and no Django signals. My background is .NET, so you'll see .NET comparisons in the comments, like select_for_update as an UPDLOCK and a partial unique constraint as an EF Core filtered index.

This is my first Django project. My experience with each piece:

Technology My experience
Python Through AI only; little hand coding
Django and its test framework None before this
PostgreSQL (including JSONB) Production
Docker Compose Some

How this was built

I set the context and made every decision; AI drafted and built.