Architecture Map
System design for Lexora — a consolidated Next.js platform with durable async workers, database-level tenant isolation and first-class AI observability.
System diagram
Layered request + async flow across the platform.
Edge / Client
Browser, OAuth, public API surface
Next.js Monolith (App Router)
Single deployable: UI + API + Server Actions
Async Processing
Durable workers decoupled from request lifecycle
Data & Security
Single source of truth with row-level isolation
External Providers
AI, legal data, publishing, billing & observability
Migration Plan
Strangler-fig migration off N8N/ECS with zero production downtime.
Foundations
- Map existing N8N workflows
- Define typed job contracts
- Stand up BullMQ queues
- Build provider mocks & adapters
Migrate critical pipelines
- Migrate highest-risk pipelines
- Implement Dead Letter Queue
- Add AI tracing
- Programmatic retries + backoff
Security, billing & observability
- Enforce Supabase RLS everywhere
- Usage-based billing metering
- Per-tenant observability
- Compliance hardening
Decommission legacy
- Remove N8N
- Consolidate Express/ECS into Next.js
- Full operational monitoring
- Runbooks + on-call
Architectural Decisions
Condensed ADRs documenting the key trade-offs.
Decision
Adopt a single Next.js App Router deployable for UI, API and server actions.
Rationale
A small team ships faster with one codebase, one deploy and shared types end-to-end. Workers run as separate processes against the same repo, so we keep operational simplicity without sacrificing async scalability. We can extract services later behind stable job contracts.