Documentation Index
Fetch the complete documentation index at: https://docs-terra.withunify.org/llms.txt
Use this file to discover all available pages before exploring further.
System Map
A bird’s-eye view of how Terra’s components connect.This page provides visual maps of Terra’s architecture. Use it as a reference when navigating the codebase or debugging data flow issues.
High-Level Architecture
Terra follows a layered architecture with clear boundaries between concerns:Request Flow
Every request follows a consistent path through the system:Key Decision Points
| Step | Decision | Fail Behavior |
|---|---|---|
| Middleware | Valid session? | Redirect to login |
| Middleware | Custom domain? | Route to correct folder |
| Server Action | Has permission? | Throw unauthorized |
| Database | RLS policies | N/A (using service role) |
Form Submission Flow
When an applicant submits a form, here’s what happens:Timing
| Step | Typical Duration | Blocking? |
|---|---|---|
| Client validation | 50-100ms | Yes |
| Server save | 100-200ms | Yes |
| Queue enqueue | 10-20ms | Yes |
| User sees success | ~300ms total | — |
| Airtable sync | 500ms-2s | No |
| Email send | 200-500ms | No |
| Webhook fire | 100-500ms | No |
Authentication Flow
How users authenticate and how sessions are managed:Session Management
Data Model Overview
The core database entities and their relationships: For complete schema documentation, see Database Schema.File Upload Flow
How files move from the applicant’s browser to secure storage:Storage Paths
Files are stored with unpredictable paths to prevent enumeration:Async Queue Architecture
The persistent queue that powers background processing:Operation Types
| Type | Trigger | Retry Strategy |
|---|---|---|
airtable_sync | Submission/update | 5 retries, exponential backoff |
send_email | Submission | 3 retries, 1 min delay |
send_sms | Submission/status change | 3 retries, 1 min delay |
fire_webhook | Submission/status change | 5 retries, exponential backoff |
plaid_enrichment | Plaid link complete | 3 retries, 30s delay |
Directory Structure
Where to find things in the codebase:Next Steps
Design Philosophy
Why we made these architectural choices
Database Schema
Complete table documentation