Skip to content

Instantly share code, notes, and snippets.

@andreajparker
Created February 6, 2026 16:58
Show Gist options
  • Select an option

  • Save andreajparker/f9b166d45e5cbfa09158fe20f6992b8d to your computer and use it in GitHub Desktop.

Select an option

Save andreajparker/f9b166d45e5cbfa09158fe20f6992b8d to your computer and use it in GitHub Desktop.
Revenue Leakage v2 — Railway + Supabase Deployment Guide

Revenue Leakage v2 — Railway + Supabase Deployment Guide

Deploy the feat/kpi-pipeline-feature-flags-synthetic branch from
https://github.com/Techtorch/revenue-leakage-v2


1. Supabase (Database)

  1. Go to supabase.comNew Project
  2. Pick a region close to your Railway region (e.g. US East)
  3. Set a strong database password — you'll need it below
  4. Once created, go to Settings → Database → Connection string → URI
  5. Copy the connection string — it looks like:
    postgresql://postgres.[project-ref]:[PASSWORD]@aws-0-us-east-1.pooler.supabase.com:6543/postgres
    

    Use the Transaction (port 6543) pooler URI for the backend.


2. Railway — Backend Service

  1. Go to railway.appNew Project → Deploy from GitHub repo

  2. Select Techtorch/revenue-leakage-v2, branch feat/kpi-pipeline-feature-flags-synthetic

  3. Settings:

    • Root Directory: rev-leak-agents
    • Builder: Dockerfile (auto-detected from rev-leak-agents/Dockerfile)
    • Start Command: leave blank (Dockerfile CMD handles it)
  4. Environment Variables:

    Variable Value
    RL_DB_DSN postgresql://postgres.[ref]:[PASSWORD]@aws-0-us-east-1.pooler.supabase.com:6543/postgres
    RL_RUN_MIGRATIONS_ON_STARTUP true
    RL_OPENAI_API_KEY sk-... (your OpenAI key for GPT-4o extraction)
    RL_CORS_ORIGINS https://<frontend-domain>.up.railway.app (set after frontend deploys)
    RL_LOG_LEVEL info
    PORT 8001
  5. Networking: Generate a public domain (e.g. rev-leak-backend-production.up.railway.app)

  6. Deploy — first deploy runs Alembic migrations automatically


3. Railway — Frontend Service

  1. In the same Railway project → New Service → Deploy from GitHub repo

  2. Select same repo + branch

  3. Settings:

    • Root Directory: revenue-leakage-v2/remix-of-revenue-leakage-ui
    • Builder: Dockerfile (auto-detected)
  4. Environment Variables:

    Variable Value
    VITE_API_BASE_URL https://rev-leak-backend-production.up.railway.app

    This gets baked in at build time. If you change the backend URL, redeploy the frontend.

  5. Networking: Generate a public domain (e.g. rev-leak-ui-production.up.railway.app)

  6. Deploy


4. Post-Deploy Checklist

  • Update backend RL_CORS_ORIGINS with the actual frontend Railway URL
  • Hit https://<backend>/health — should return {"status": "ok"}
  • Open frontend URL — dashboard should load (empty until you run pipeline)
  • Click "Load CITI Data" on Ingestion page to process CITI documents
  • Click "Process Synthetic" to run synthetic test documents through KPI pipeline
  • Verify Dashboard shows KPI signals, leakage categories, and trend chart
  • Verify Knowledge Graph shows document relationships (not all orphans)

5. Optional: Basic Auth

To protect the API with HTTP Basic Auth, set these on the backend service:

Variable Value
RL_BASIC_AUTH_USER your-username
RL_BASIC_AUTH_PASS your-password

The /health endpoint is excluded from auth (for Railway healthchecks).


Architecture

┌─────────────┐     HTTPS      ┌─────────────────┐     SQL      ┌──────────┐
│  React/Vite │ ──────────────→ │  FastAPI Backend │ ───────────→ │ Supabase │
│  (Railway)  │  VITE_API_URL   │    (Railway)     │  RL_DB_DSN   │ Postgres │
└─────────────┘                 └─────────────────┘              └──────────┘
                                        │
                                        │ RL_OPENAI_API_KEY
                                        ▼
                                 ┌──────────────┐
                                 │  OpenAI API  │
                                 │  (GPT-4o)    │
                                 └──────────────┘

Troubleshooting

  • Migrations fail: Check RL_DB_DSN is correct and Supabase allows connections from Railway IPs
  • CORS errors: Ensure RL_CORS_ORIGINS matches the exact frontend URL (including https://)
  • Empty dashboard: Run the pipeline first via Ingestion page buttons
  • OpenAI errors: Verify RL_OPENAI_API_KEY is set and has GPT-4o access
@andreajparker
Copy link
Author

image

@andreajparker
Copy link
Author

  • techtorch

  • 2026d3m0z0om.

@andreajparker
Copy link
Author

image

@andreajparker
Copy link
Author

image

@andreajparker
Copy link
Author

revenue-leakage-v2-production-880a.up.railway.app

@andreajparker
Copy link
Author

https://revenue-leakage-v2-production-880a.up.railway.app/health

{"status":"ok","version":"0.1.0","time":"2026-02-06T17:36:34.841265"}

@andreajparker
Copy link
Author

image

@andreajparker
Copy link
Author

image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment