StableFlow is designed as a revenue-to-settlement pipeline for internet businesses.
flowchart LR
A["Customer"] --> B["StableFlow UI"]
B --> C["POST /api/checkout"]
C --> D["Dodo Checkout Sessions API"]
D --> E["Hosted Dodo Checkout"]
E --> F["Dodo payment event"]
F --> G["POST /api/webhooks/dodo"]
G --> H["Webhook verification + idempotency"]
H --> I["Supabase Postgres ledger"]
I --> J["Payout policy compiler"]
J --> K["Payout run + queued transfers"]
K --> L["Settlement executor"]
L --> M["Solana devnet stablecoin transfers"]
M --> N["Explorer links + dashboard proof"]
src/app/api/checkout/route.tssrc/lib/dodo.ts
The server creates a Dodo checkout session using the configured Dodo product. Metadata tags the request so the downstream webhook can be linked back to the StableFlow ledger.
src/app/api/webhooks/dodo/route.tssrc/lib/ledger.ts
The webhook layer:
- reads raw request body
- verifies Standard Webhooks headers
- stores unique
webhook-idvalues - marks duplicates idempotently
- creates or updates the payment record
- creates a payout run from policy rules
prisma/schema.prismasrc/lib/ledger.ts
The Postgres model tracks:
- organizations
- Dodo checkout sessions
- webhook events
- payments
- recipients
- payout policies
- payout rules
- payout runs
- payout transfers
- audit logs
This is the product core, because financial operations need relational consistency and traceability.
src/app/api/payouts/simulate/route.tssrc/lib/solana.ts
The settlement executor drains queued transfers and sends stablecoin payouts on Solana devnet. Each transfer stores:
- mint
- recipient wallet
- signature
- status
- timestamps
- explorer URL
StableFlow separates revenue verification from settlement execution on purpose.
That gives us:
- cleaner idempotency
- safer retry semantics
- a visible queue for operator review
- a path to background workers later
For the hackathon build, this makes the product easier to reason about and demo honestly.
- signed Dodo webhook verification
- idempotent processing keyed by
webhook-id - database-backed ledger instead of in-memory state
- explicit payout run states:
READY,EXECUTING,SETTLED,PARTIAL,FAILED - explorer-linked transfer proofs for settlement visibility
Current settlement rail:
- network: devnet
- asset:
StableFlow USD Demo (sUSD) - mint:
5iupsp2SQHETtJAyrqKbxwPuLn9me1Zh4jmqspLTNJ8Z - treasury wallet:
5ykZEE69NaDU9SfoK53MjbQ4g7Rawx1jqZtQFf6eAFfZ
- Dodo drives the real-world revenue event
- Solana handles the stablecoin settlement edge
- the app solves a business workflow, not just a wallet interaction
- the system can grow into contractor payouts, affiliate payouts, AI vendor payouts, and agentic micropayment flows
After the hackathon, the next production steps are:
- background job execution for payout runs
- auth and multi-tenant org controls
- approvals, thresholds, and payout windows
- compliance and recipient verification
- mainnet pilot with selected businesses