Get startedRetrofit overview

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 only

After 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

PieceExample
IntentREFUND_REQUESTED
Staterefund entity (status, attempts, risk_level, …)
EventsREFUND_APPROVEDREFUND_PROVIDER_SUBMISSION_STARTEDREFUND_COMPLETED
TimelineInspect with causet inspect timeline --stream refund_stream --entity <id>

Verification

  1. Hit the existing endpoint
  2. causet inspect timeline --entity <refund-id> --stream refund_stream --fork sandbox
  3. 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.