Revenue & Sales Operating System

    How do you make prospect-to-cash attributable in one system?

    Link every step to the next in one tenant-scoped data model. SourceMate replaced a five-tool commercial stack with discovery, research, drafting, deals, engagements, phased invoicing and collections in one place — AI drafts and extracts under human approval, while Postgres rules own numbering, overdue status, balances and margin.

    Alex Scharifker · Co-founder, product architect, and systems lead

    SourceMate Clear Revenue Hub was designed and led by Alex Scharifker for SourceMate, the consultancy he co-founded in 2023.

    15
    Edge Functions
    20+
    Tenant-Scoped Tables
    50+
    Leads Generated
    Problem

    SourceMate Clear Revenue Hub

    The commercial function ran on a spreadsheet stack plus memory: prospects in a notes app, deals in a spreadsheet, invoices in a document template, payments in a bank statement. Nothing linked to the next thing, so 'which outreach produced revenue?' was unanswerable — while overdue AR was discovered by accident, vendor cost stayed invisible until close-out, and banking details sat in plaintext.

    System

    How the system is put together

    Sources in, deterministic logic in the middle, AI restricted to interpretation.

    Data sources

    • AI prospect discovery under a strict tool schema
    • Firecrawl site research and lead enrichment
    • Call transcripts and email replies
    • Proposals and service briefs
    • Manual payment and referral settlement entry
    • Encrypted company banking configuration

    Layers

    • Operator UI with org-scoped query cache
    • PostgREST under row-level security
    • Deno edge functions for privileged work
    • Tenant-scoped Postgres system of record
    • Trigger-enforced business rules
    • Client-side PDF and CSV generation

    Deterministic logic

    • Invoice numbering AI-YYYY-NNN generated in Postgres
    • Overdue enforcement by trigger, not by human review
    • Balance = total − amount paid; receivables over Sent and Overdue only
    • Engagement margin: phase value versus vendor cost
    • Bidirectional referral fee split, income versus expense
    • Tenant predicate on every read and write

    Where AI is used

    • Discovers fit companies from an ICP written in prose
    • Synthesizes scraped research into a usable angle
    • Drafts grounded first emails and follow-ups for human review
    • Extracts transcripts, proposals and briefs into typed rows
    • Never computes money, sets status, or grants access

    Decision loop

    • Discover and research under caps
    • Draft, then gate on human approval
    • Convert to deal, engagement and phased invoice
    • Attribute collected cash back to the agent run

    My role

    • Product architecture and backend surface split
    • Data model and tenancy design
    • Business-rule and state-machine design
    • Applied AI use-case design and guardrails
    • Security decisions and implementation leadership
    Architecture

    The architecture case file

    Layer-by-layer architecture, deterministic model, AI guardrails, and the decision loop.

    The commercial function ran on spreadsheets and memory, so nobody could answer which outreach produced revenue. This system closes the loop between selling effort and collected cash — with AI drafting and a human deciding.

    DiscoverResearchDraftApproveCollect

    Key takeaways

    • A five-tool commercial stack — notes app, spreadsheet, invoice template, bank statement, memory — collapsed into one attributable data model from prospect to collected cash.
    • Prospect research and drafting went from roughly 30 minutes of manual work to a reviewable, grounded draft inside a single agent run.
    • AR is self-policing: a Postgres trigger, not a person, declares an invoice overdue.
    • Multi-tenant from the database up, with AES-256-GCM banking storage and every model call routed through one governed proxy.

    Architecture Principle

    One attributable spine from prospect to collected cash.

    • One data model runs the full commercial lifecycle: prospect discovery through collected cash.
    • Tenant isolation is a database property, not a query filter — a second company is a new org, not a new deployment.
    • Privileged edge functions re-authorize every request against org membership; they never trust a client-supplied org id.
    01

    Operator surface

    React 18 + Vite + TypeScript with TanStack Query as the only state boundary — roughly 25 typed domain hooks, no global store. Every query key carries the active org id, so switching tenants re-partitions the cache instead of filtering client-side.

    02

    Two backend surfaces

    Deterministic CRUD and aggregation go straight to PostgREST under row-level security. Anything needing a secret, an external call, or privileged logic goes to a Deno edge function — 15 of them. No API layer re-implements what SQL already enforces.

    03

    Tenant-scoped system of record

    Isolation

    About 20 Postgres tables spanning demand generation, outreach, pipeline, delivery and finance. Every row is predicated on user_belongs_to_org(auth.uid(), org_id); roles live in a separate user_roles table behind a security-definer has_role().

    04

    Rules in the database

    Invoice numbering (AI-YYYY-NNN), overdue enforcement, and timestamps are Postgres triggers — not application code. The rule holds no matter which client path writes the row, so status can never drift out of sync with reality.

    05

    One attributable spine

    Payoff

    Every dollar on the dashboard traces back through payment → invoice → engagement phase → deal → outreach touch → the researched prospect that started it. That traceability is the product.

    Outcome

    What changed

    • Collapsed a five-tool commercial stack into one attributable data model spanning prospect to cash.
    • Cut prospect research and drafting from roughly 30 minutes to a reviewable draft inside one agent run.
    • Made AR self-policing — a database trigger declares an invoice overdue.
    • Zero-plaintext banking: AES-256-GCM at rest, last-4 in the UI, re-auth-gated reveal, immutable per-invoice snapshot.
    • Multi-tenant from the database up: a second company is a new org, not a new deployment.

    Follow Me

    LinkedIn


    From Chaos to Clarity Newsletter

    From Chaos to Clarity

    Get insights on product management and operations delivered to your inbox.

    Subscribe on LinkedIn

    Send me a message