Architecture Decision Records (ADRs)
Complete catalog of all technical decisions for TVL Platform
What are ADRs?
Architecture Decision Records document WHY we chose specific technologies, patterns, and approaches. Each ADR captures:
- Context - The problem we're solving
- Decision - What we chose
- Rationale - Why we chose it (3-5 key reasons)
- Alternatives - What else we considered (and why we rejected them)
- Consequences - Trade-offs and mitigations
Status Legend
- ✅ Accepted - Decision is active and implemented
- 🚧 Proposed - Under review
- ⛔ Deprecated - No longer recommended
- 🔄 Superseded - Replaced by newer ADR
ADR Index (55 Total)
Pre-Existing Foundation (4 ADRs)
| # | Title | Status | Category | 
|---|---|---|---|
| ADR-0001 | Google OIDC + RBAC + RLS | ✅ Accepted | Security | 
| ADR-0002 | PostgreSQL 15+ Data Modeling | ✅ Accepted | Database | 
| ADR-0003 | BullMQ + Exponential Backoff | ✅ Accepted | Infrastructure | 
| ADR-0004 | Vercel + Railway + Supabase + Upstash | ✅ Accepted | Hosting | 
Foundation & Infrastructure (11 ADRs)
Core technologies and architectural patterns
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0005 | TypeScript 5.3+ Strict Mode | Type safety | Catch 70% of bugs at compile time | 
| ADR-0006 | Node.js 20 LTS | Runtime stability | LTS support until 2026-04-30 | 
| ADR-0007 | pnpm 8.x for Monorepo | Fast installs | 2-3x faster than npm | 
| ADR-0008 | Doppler Secrets Management | SOC 2 compliance | 10min rotation vs 2hr manual | 
| ADR-0009 | Domain-Driven Design (14 domains) | Modular architecture | Clear boundaries | 
| ADR-0010 | pnpm Workspaces | Code sharing | Shared packages across apps | 
| ADR-0011 | Nx Build System | Build performance | 68% faster builds (cold) | 
| ADR-0012 | Drizzle ORM | Type-safe queries | Lightweight vs Prisma | 
| ADR-0013 | Zod Validation | Runtime safety | Type inference + validation | 
| ADR-0014 | Vitest Testing Framework | Test speed | 10x faster than Jest | 
| ADR-0055 | NODE_ENV vs APP_ENV Strategy | Environment clarity | Correct framework optimizations | 
Frontend Stack (7 ADRs)
User interface and client-side architecture
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0015 | React 18 | UI framework | Concurrent rendering | 
| ADR-0016 | Next.js 14 App Router | SSR + routing | Server Components | 
| ADR-0017 | Tailwind CSS 3.x | Styling | Utility-first CSS | 
| ADR-0018 | Shadcn UI Components | Component library | Copy-paste, not dependency | 
| ADR-0019 | Zustand State Management | Client state | Simpler than Redux | 
| ADR-0020 | TanStack Query (React Query) | Server state | Auto cache invalidation | 
| ADR-0021 | React Hook Form + Zod | Forms | Performance + validation | 
Backend API (7 ADRs)
REST API architecture and design
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0022 | Fastify 4.x | API framework | 3x faster than Express | 
| ADR-0023 | REST over GraphQL | API pattern | Industry standard (92% adoption) | 
| ADR-0024 | OpenAPI 3.0 Specification | API docs | Auto-generated from Fastify | 
| ADR-0025 | RFC 7807 Error Handling | Error format | Standardized problem details | 
| ADR-0026 | URL-Based API Versioning | Versioning | /api/v1/,/api/v2/ | 
| ADR-0053 | ⛔ Rejected | Superseded by ADR-0054 | |
| ADR-0054 | API-First Approach for MVP.0 | Production architecture | No migration debt, mobile-ready | 
Integration Architecture (9 ADRs)
External API integrations and webhooks
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0027 | HMAC SHA-256 Webhook Security | Security | Prevent tampering | 
| ADR-0028 | Webhook Idempotency (Payload Hashing) | Reliability | Prevent duplicate processing | 
| ADR-0029 | Async Webhook Processing (BullMQ) | Performance | <100ms response time | 
| ADR-0030 | Transactional Outbox Pattern | Event reliability | No lost events | 
| ADR-0031 | Redis Streams as Event Bus | Event distribution | Persistent pub/sub | 
| ADR-0032 | Adapter Pattern for Channels | Integration | Uniform API for all channels | 
| ADR-0033 | JSONB Field Mapping | Flexibility | No code changes for new fields | 
| ADR-0034 | Circuit Breaker (Opossum) | Resilience | Prevent cascade failures | 
| ADR-0035 | Structured Integration Logging | Debugging | Correlation IDs for tracing | 
Caching & Performance (7 ADRs)
Redis caching strategy and optimization
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0036 | Redis Application Caching | Performance | <1ms cache hits | 
| ADR-0037 | Cache Key Naming Convention | Organization | Prevent collisions | 
| ADR-0038 | Cache Invalidation Strategy | Correctness | Prevent stale data | 
| ADR-0039 | Cache Stampede Prevention | Scalability | Prevent DB overload | 
| ADR-0040 | LRU Cache Eviction | Memory management | Keep hot data | 
| ADR-0041 | Redis Session Storage | Authentication | Fast, distributed sessions | 
| ADR-0042 | Redis-Based Rate Limiting | Abuse prevention | Token bucket algorithm | 
Observability & Monitoring (5 ADRs)
Metrics, traces, logs, and error tracking
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0043 | OpenTelemetry for Distributed Tracing | Debugging | Track requests across services | 
| ADR-0044 | Grafana Cloud (Mimir + Tempo + Loki) | Unified observability | Single pane of glass | 
| ADR-0045 | Loki for Log Aggregation | Log centralization | 50GB/month free tier | 
| ADR-0046 | Sentry for Error Tracking | Error management | Stack traces + breadcrumbs | 
| ADR-0047 | Winston for Application Logging | Structured logging | JSON logs for parsing | 
Code Quality & DX (4 ADRs)
Developer experience and code standards
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0048 | ESLint for Code Quality | Consistency | Catch bugs early | 
| ADR-0049 | Prettier for Code Formatting | No debates | Auto-format on save | 
| ADR-0050 | Husky for Git Hooks | Quality gates | Prevent bad commits | 
| ADR-0051 | 80% Test Coverage Requirement | Reliability | Critical paths tested | 
Documentation Infrastructure (1 ADR)
Documentation publishing and hosting
| # | Title | Why It Matters | Key Benefit | 
|---|---|---|---|
| ADR-0052 | Docusaurus + Cloudflare Pages | Documentation hosting | Free tier + Google SSO | 
ADRs by Category
Security (5 ADRs)
- ADR-0001: Google OIDC + RBAC + RLS
- ADR-0008: Doppler Secrets Management
- ADR-0027: HMAC SHA-256 Webhook Security
- ADR-0041: Redis Session Storage
- ADR-0042: Rate Limiting
Database (4 ADRs)
- ADR-0002: PostgreSQL 15+ Data Modeling
- ADR-0012: Drizzle ORM
- ADR-0030: Transactional Outbox Pattern
- ADR-0033: JSONB Field Mapping
Performance (8 ADRs)
- ADR-0011: Nx Build System
- ADR-0022: Fastify (3x faster than Express)
- ADR-0036-0042: Caching ADRs
Observability (6 ADRs)
- ADR-0035: Integration Logging
- ADR-0043-0047: Observability ADRs
Developer Experience (7 ADRs)
- ADR-0005: TypeScript Strict Mode
- ADR-0013: Zod Validation
- ADR-0014: Vitest Testing
- ADR-0048-0051: Code Quality ADRs
How to Use ADRs
When making technical decisions:
- Check existing ADRs first - Decision may already be made
- Reference ADRs in code - Link to ADR in comments
- Update ADRs if context changes - Mark as deprecated, create superseding ADR
When onboarding:
- Read Foundation ADRs (0005-0014) - Understand core stack
- Read your domain's ADRs - E.g., Frontend team reads ADR-0015-0021
- Reference ADRs during code review - "This violates ADR-0005 (TypeScript strict mode)"
When proposing changes:
- Create new ADR - Document decision + rationale
- Get team review - Discuss alternatives
- Mark old ADR as superseded - If replacing existing decision
Quick Reference
Most referenced ADRs:
- ADR-0001 (Auth): Every authentication/authorization question
- ADR-0002 (Database): Every schema change
- ADR-0005 (TypeScript): Every code style question
- ADR-0022 (Fastify): Every API endpoint question
ADRs with code samples:
- All ADRs include TypeScript/SQL code examples
- See "Implementation" section in each ADR
ADRs with cost implications:
- ADR-0004: Hosting topology ($0-50/month)
- ADR-0008: Doppler ($0-12/user/month)
- ADR-0044: Grafana Cloud ($0-250/month)
Related Documentation
- DEVELOPMENT_PREP_CHECKLIST.md - Implementation roadmap
- LICENSE_COMPLIANCE.md - Third-party licenses
- COST_ANALYSIS.md - TCO by phase
- CONTRIBUTING.md - Development workflow
- Architecture Docs - System design diagrams
ADR Process
Creating a new ADR:
# 1. Copy template
cp docs/reference/decisions/adr-template.md docs/reference/decisions/adr-XXXX-title.md
# 2. Fill in sections:
#    - Status (Proposed)
#    - Context
#    - Decision
#    - Alternatives (3-5)
#    - Consequences
# 3. Get team review
# 4. Mark as Accepted
# 5. Update this index
Updating an ADR:
## Status
**Deprecated** - 2025-02-01
**Superseded by:** [ADR-0052](./adr-0052-new-approach.md)
Statistics
- Total ADRs: 54
- Accepted: 53
- Rejected: 1 (ADR-0053)
- Proposed: 0
- Deprecated: 0
- Categories: 9 (Foundation, Frontend, Backend, Integration, Caching, Observability, Code Quality, Documentation, Pre-Existing)
- Last Updated: 2025-01-26
Questions about ADRs? See CONTRIBUTING.md or ask in #tvl-dev Slack channel.
Last Updated: 2025-01-26 Maintained By: Tech Lead Status: Complete (54/54 ADRs documented)