Jonatas Silva

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 design

System diagram

Layered request + async flow across the platform.

Edge / Client

Browser, OAuth, public API surface

Google OAuth
LinkedIn OAuth
Tenant Users (SSR/CSR)

Next.js Monolith (App Router)

Single deployable: UI + API + Server Actions

App Router (RSC)
API Routes
Server Actions

Async Processing

Durable workers decoupled from request lifecycle

Redis (BullMQ)
BullMQ Workers ×6
Dead Letter Queue

Data & Security

Single source of truth with row-level isolation

PostgreSQL / Supabase
Supabase RLS
AWS S3 (assets)

External Providers

AI, legal data, publishing, billing & observability

Claude / Gemini / Perplexity / DALL-E
CourtListener API
WordPress REST API
Stripe
Langfuse / LangSmith / Helicone

Migration Plan

Strangler-fig migration off N8N/ECS with zero production downtime.

Phase 1

Foundations

  • Map existing N8N workflows
  • Define typed job contracts
  • Stand up BullMQ queues
  • Build provider mocks & adapters
Phase 2

Migrate critical pipelines

  • Migrate highest-risk pipelines
  • Implement Dead Letter Queue
  • Add AI tracing
  • Programmatic retries + backoff
Phase 3

Security, billing & observability

  • Enforce Supabase RLS everywhere
  • Usage-based billing metering
  • Per-tenant observability
  • Compliance hardening
Phase 4

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.