Retrofit an endpoint
Goal: move one fragile workflow into Causet without rewriting your system.
Causet can be introduced one endpoint at a time. Your frontend, database, and other routes stay put.
This page is the short overview. Full DSL, SDK, webhooks, retries, and production detail: Full retrofit guide.
Architecture
Client
→ existing API (auth, validate, response shape)
→ Causet (intent)
→ state + events (timeline)
→ projections / queries
→ outbound webhook / side effects
→ existing database (updated from webhook or still owned by the API)Your API route accepts the request. Causet owns what happens next.
Before Causet
Example from the real retrofit-commerce demo — only refunds are retrofitted:
await refundService.processDirectly(refund);
// provider timeout → failed → manual retry onlyAfter Causet
await client.submitIntent(
'refund_stream',
refund.id,
'REFUND_REQUESTED',
{ refund_id: refund.id, order_id: refund.orderId, /* … */ },
refund.id, // idempotency key
);
return Response.json({ status: 'accepted', refundId: refund.id }, { status: 202 });What remains in the existing app: products, orders, inventory, payments, SQLite schema, frontend, and the public POST /api/orders/:id/refund contract.
Intent → state → events
| Piece | Example |
|---|---|
| Intent | REFUND_REQUESTED |
| State | refund entity (status, attempts, risk_level, …) |
| Events | REFUND_APPROVED → REFUND_PROVIDER_SUBMISSION_STARTED → REFUND_COMPLETED |
| Timeline | Inspect with causet inspect timeline --stream refund_stream --entity <id> |
Verification
- Hit the existing endpoint
causet inspect timeline --entity <refund-id> --stream refund_stream --fork sandbox- Confirm webhook or projection updated your app DB
Next step
Full retrofit implementation → (DSL, saga, webhooks, retries, rollout)
Or run the wallet local quickstart first if you have not used the local runtime yet.