High-Level Architecture
The LTV.ai backend follows a modular monolith architecture built on NestJS. Each domain area is encapsulated in its own module with clear boundaries.Module Architecture
Reactivate Module
The email automation and AI marketing engine. Manages email sequences, campaign generation, customer segmentation, scheduling, and AI-powered content creation. Contains 23 controllers.Ecommerce Stores Module
Adapters for Shopify and BigCommerce. Handles OAuth flows, webhook processing, order/customer sync, product catalog updates, and platform-specific SSO.Billing Module
Manages merchant subscription billing, payment processing, and invoice generation.Public API Module
GraphQL resolvers for customer-facing operations: authentication, OTP verification, and billing management.Design Patterns
Use Case Pattern
Business logic is encapsulated in Use Case classes following clean architecture principles. Each use case represents a single business operation.Guard-Based Authorization
Authentication and authorization use NestJS guards that validate JWTs and API keys before requests reach controllers.Event-Driven Processing
Asynchronous operations use AWS SQS queues and NestJS event emitters for decoupled processing of:- Email delivery and scheduling
- Webhook event processing
- Catalog updates
- Customer segmentation
- Profile sync operations
Data Flow
Email Sequence Flow
Ecommerce Data Sync Flow
Database Architecture
| Database | Purpose | Key Data |
|---|---|---|
| PostgreSQL | Transactional data | Customers, retailers, emails, sequences |
| ClickHouse | Analytics | Email metrics, conversion rates, aggregated reports |
| Redis | Caching & sessions | JWT sessions, rate limiting, report caching, throttling |
| Elasticsearch | Search | Customer profiles, full-text search |