Case study · 02 · Personal project

DealFlow

From the first chat to money in the bank.

A sales-to-cash tool for small B2B businesses that track leads, quotations, follow-ups and invoices across WhatsApp, spreadsheets and separate documents.

Role
Product definition, architecture, backend, frontend, tests
Year
2026
Type
Personal project
Built with
Next.js, TypeScript, PostgreSQL
DealFlow: main screen
01 / Overview

Context

Built around how B2B vendors in Indonesia actually get paid: deposits, milestone payments, and customers who pay net of withholding tax.

02 / Problem

What made it hard

Small B2B teams run a sale across WhatsApp threads, a spreadsheet and loose documents. Sales never sees what Finance has collected, and Finance never sees which promise Sales made. DealFlow puts the whole journey in one place, from first contact through quotation, follow-up, deal outcome, invoice and payment.

The hard part is the money. A model of one deal, one invoice and one payment breaks on contact with real customers: a single transfer pays two invoices, a deposit arrives before any invoice exists, and a customer pays less than the invoice because they withheld tax. The data model had to survive all of that without anyone editing a number by hand.

03 / Decisions

Key decisions

i.

A payment received is not the same as an invoice paid

Money that arrives is recorded as a receipt, and what settles an invoice is a separate record. A settlement can be a receipt, a withholding-tax certificate, or a small write-off with a note. Corrections are appended rather than edited. I rejected the simpler payments-per-invoice table because it cannot express a transfer that covers two invoices, and the first typo would need a database script to fix.

ii.

A deal moves by condition, not by activity

The first version had seven linear statuses like Contacted and Qualified, which record what a salesperson did rather than where the opportunity stands, and it could not go backwards. Pipeline now has four stages that can move forward or back, plus an on-hold state, so a deal that is waiting on next year's budget stops inflating the pipeline value.

iii.

Emails go through a transactional outbox

Sending an email inside the request means a failed email cancels an invoice, or an invoice goes out with no email and no trace. So the email is written to an outbox table in the same transaction as the business change, sent right after commit, and swept by a scheduled job with retries and a visible dead state. Whether an invoice is overdue never depends on that job.

04 / Outcome

What shipped

  • Authentication, organizations, and four roles (Owner, Admin, Sales, Finance) with invitations.
  • A pipeline board with stage dialogs and an activity timeline, customers, follow-ups with WhatsApp links, and role-specific dashboards.
  • Quotations with revisions, version comparison and PDF output, invoices with partial payments and overdue tracking.
  • Playwright end-to-end tests, including the Sales to Finance hand-off with a tenant-isolation check, and an axe accessibility scan against WCAG 2.1 A and AA, run in CI.
  • Security headers and a content security policy, structured logging with redaction, and a dependency audit in CI.
  • Deployed with seeded demo data, and a health endpoint that also checks the database.

Built with

Next.jsReactTypeScriptPostgreSQLDrizzle ORMBetter AuthZodTailwind CSSVitestPlaywright

All projects