Drift Legal — Infrastructure Diagram

Full-stack immigration case management platform

Production Architecture
●
Client Portal
Questionnaire, case timeline, documents, chat, POA signing
React 18 TypeScript Vite + SWC
Dashboard & case cards
Phase-based timeline (6 phases)
Document upload & preview
Embedded DocuSeal signing
◆
Admin Portal
Case management, workflow designer, user management, AI tools
React 18 TypeScript shadcn/ui
Workflow blueprint designer
Question flow builder
Document requests & redaction
Team assignments & messaging
◊
Lawyer Portal
Case review, AI workspace, client messaging, appointments
React 18 TypeScript TanStack Query
Assigned case overview
Gemini AI chat workspace
Document review
Appointment management
❖
UI System
52 Radix primitives via shadcn/ui, Tailwind CSS, Lucide icons
shadcn/uiTailwindRadix
↻
State & Data
TanStack React Query for server state, Context API for auth
React QueryContext56+ hooks
☉
Auth Guards
Role-based route protection, POA gate, 4 role types
ProtectedRouteAdminRouteLawyerRoute
⚡
Realtime
Live case sync, notifications, message updates via Supabase
WebSocketAuto-invalidation
HTTPS · Supabase Client SDK · REST + Realtime WS
☁
Cloudflare Pages
Static SPA hosting with global CDN, Web Analytics, instant deploys
Wrangler CLIEdge cachingWeb Analytics
▲
Supabase Cloud
Managed Postgres, Auth, Storage, Edge Functions, Realtime
Project: juxqgvon...EU region
Edge Functions · PostgREST · Auth API · Storage API
⚙
Case & Workflow
Case creation, workflow initialization, blueprint sync
create-user-and-case
initialize-case-from-visa-type
sync-blueprint-to-cases
save-case-progress
check-overdue-steps
✶
AI & Extraction
Gemini-powered chat, document extraction, skills engine
ai-chat (context-aware)
ai-skill-invoke
process-document
generate-case-summary
generate-application
✎
POA & Signing
DocuSeal POA flow, DocuSign envelopes, webhook handlers
create-poa-envelope
check-poa-status (poll 15s)
docuseal-webhook
docusign-create-envelope
docusign-webhook
✉
Comms & Notifs
Email via Resend, Slack alerts, Zapier triggers, digests
send-notification-email
send-notification-digest
send-welcome-email
send-slack-notification
notify-zapier
🔒
Auth & Users
User creation, invites, password reset, OAuth flows
resend-invite / send-password-reset
google-oauth-initiate / callback
slack-oauth-initiate / callback
admin-delete-user
📄
Documents
Combine, redact, vault access, secure retrieval
combine-documents
redact-document
get-vault-document
set-vault-password
⚕
Shared Modules
Reusable logic across all edge functions
withErrorHandling() wrapper
logger, CORS, types
geminiApi, googleAuth
skillEngine, contextBuilder
SQL · Service Role Key · RLS Policies · Triggers
☃
PostgreSQL (Supabase)
50+ tables, 129 migrations, Row-Level Security enforced
RLSJSONBPostgRESTRealtime
Core Tables
profiles · user_roles
customer_cases (JSONB answers)
case_workflow_steps
case_messages · case_assignments
poa_agreements
notifications · document_requests
Config & AI Tables
visa_types · visa_type_phase_templates
workflow_templates · workflow_steps
question_flow_templates
ai_conversations · ai_messages
case_data_points (extracted)
escalation_rules · invoices
🗃
Supabase Storage
5 buckets with signed URLs and RLS
assessment-documents — client uploads
signed-documents — completed POA/DocuSign
poa-templates — DOCX templates
avatars — profile photos
workflow-documents — admin files
REST APIs · OAuth · Webhooks
✨
Google Gemini 2.5 Pro
Document extraction, case chat, AI skills, summaries
OAuth tokensStreaming
✎
DocuSeal
POA e-signature, embedded forms, webhook completion
API keyWebhooks
✍
DocuSign
Document signing envelopes (non-POA), EU endpoints
OAuthWebhooks
✉
Resend
Transactional email: invites, resets, notifications, digests
API key
⚡
Slack
Admin notifications, OAuth integration
OAuthWebhooks
❘
Zapier
External workflow triggers on signup/events
Webhooks
◎
Google Drive
Document sync for case files
OAuthDrive API
◉
Intercom
Customer support chat widget
JS SDK
⚙
GitHub Actions
Automated pipeline on PR & push
ESLint → TypeScript check
Vitest (70% coverage threshold)
Deno edge function tests
Coverage artifact upload
✓
Frontend Deploy
Vite build → Cloudflare Pages via Wrangler CLI
BunViteWrangler
▲
Backend Deploy
Supabase CLI → Edge Functions & Migrations
supabase deploysupabase db push
Client Questionnaire → Case Creation
1
User signs up → question flow loaded from templates
2
Answers saved via save-case-progress
3
Submission triggers initialize-case-from-visa-type
4
Blueprint creates workflow steps → case appears on dashboard
POA Signing Flow
1
Client enters DOB/passport → create-poa-envelope
2
DOCX template → DocuSeal submission → embedded form
3
check-poa-status polls every 15s + webhook listener
4
Status: pending → envelope_sent → signed (stored in DB)
~79K
Total LOC (TS + SQL)
338
TypeScript files
50+
Database tables
41
Edge functions
129
SQL migrations
56+
Custom hooks
8
External integrations
3
User portals