Revora/Documentation/Sessions & State Machine
Data Layer Specification

Sessions & State Machine

Cancellation sessions in Revora are governed by a finite state machine enforced server-side in lib/revora/session.ts.

Session State Machine

Every cancellation session begins at started with a 64-character cryptographic token (session_token) and a 30-minute time-to-live (expires_at).

Valid State Transitions

// Retention Path

started -> reason_selected -> offer_shown -> offer_accepted -> billing_processing -> billing_confirmed -> completed

// Finalized Cancellation Path

started -> reason_selected -> cancellation_continued -> cancellation_confirmed -> completed

// Timeout & Abandonment

started -> expired (TTL > 30 mins) | abandoned (modal dismissed)

PostgreSQL Database Schema

Revora persists data across 6 core relational tables defined in supabase/migrations/001_revora_core.sql:

  • revora_merchants: Stores public keys, plan tiers, and encrypted Stripe API credentials.
  • revora_widget_configs: Stores theme colors, retention flow configurations, and competitor comparisons.
  • revora_sessions: Master cancellation session records with plan value, selected reason, and status.
  • revora_session_events: Append-only audit trail logging micro-events with timestamps.
  • revora_stripe_operations: Idempotent Stripe operation tracking table.
  • revora_rate_limits: Monthly session quota counter per merchant.

Exporting Audit Logs

Export complete, tenant-isolated session audit logs via the authenticated endpoint:

curl-export.sh
curl -X GET "https://revorahq.vercel.app/api/sessions/export?format=csv&duration=month" \
  -H "Cookie: sb-access-token=..."

Supported formats: csv, txt, md. Durations: 15, 100, month, all.