Architecture Diagram
The MCP server exposes 105 platform capabilities as AI tools for use from Claude Code, Cursor, and other MCP-compatible IDEs. The AI Assistant provides 130+ tools with guided autonomy for in-app natural language control.Technology Stack
| Component | Technology | Version | Why |
|---|---|---|---|
| Runtime | Node.js | 22+ | Native ESM, stable async hooks, LTS performance |
| Framework | Next.js (App Router) | 16.x | Unified UI and API in one deployable, Turbopack dev speed |
| Language | TypeScript (strict) | 5.9 | Type safety across frontend, API, and domain layers |
| UI Library | React | 19.x | Component model, concurrent features, Server Components |
| Styling | Tailwind CSS | 3.x | Utility-first, consistent dark theme, small bundle |
| Server State | TanStack React Query | 5.x | Cache invalidation, optimistic updates, request deduplication |
| Client State | Zustand | 5.x | Minimal store for UI-only state (panels, selections) |
| ORM | Prisma 7 with @prisma/adapter-pg | 7.x | Type-safe queries, driver adapter for connection pooling |
| Database | PostgreSQL | 15+ | Relational integrity, JSON columns, DDL for dynamic schemas |
| Cache / Rate Limit | Redis (via ioredis) | — | Enrichment cache, sliding-window rate limiting, session store |
| Validation | Zod | 4.x | Runtime schema validation shared between client and API |
| Flow Editor | React Flow (@xyflow/react) | 12.x | Visual pipeline and Decision Flow editors |
| Job Queue | BullMQ | 5.x | Durable async jobs backed by Redis |
| AI SDK | Vercel AI SDK (multi-provider) | 6.x | Anthropic, OpenAI, Google, Bedrock provider abstraction |
| Auth | NextAuth.js | 5 beta | Session-based auth with Prisma adapter, SAML support |
| Metrics | prom-client | 15.x | Prometheus-format metrics for operations dashboards |
| Charts | Recharts | 3.x | Composable chart components for dashboards |
| Testing | Vitest + Playwright | 4.x / 1.x | Unit tests (Vitest), E2E browser tests (Playwright) |
Module Architecture
The platform is organized into seven top-level modules. Each module owns its domain types, API client, and React Query hooks to enable parallel development without merge conflicts.| Module | Scope | Key Capabilities |
|---|---|---|
| Data | /data/* | Connectors (25 types), Schemas (real DDL), Pipelines (visual ETL with 15 transform types), Segments |
| Studio | /studio/* | Decision Flows, Business Hierarchy, Offers, Creatives, Channels, Contact Policies, Qualification Rules, Portfolio Optimization, Journeys, Triggers, Simulation |
| Algorithms | /algorithms/* | Scoring Models, Experiments with holdout groups and uplift calculation |
| AI | /ai/* | AI-powered Insights, Policy Recommendations, Segment Discovery, Content Intelligence |
| Dashboards | /dashboards/* | Operations (pipeline metrics, DLQ, circuit breakers), Business KPIs, Data Health, Model Health, Attribution |
| Settings | /settings/* | Tenant configuration, Integrations, API Explorer, Approval workflows, Appearance, AI configuration |
| Runs | /runs | Pipeline and flow execution history |
domain/types.ts, lib/api/client.ts, lib/api/hooks.ts) re-export everything for backward compatibility with older imports.
Data Flow
The platform’s data pipeline moves information from external sources through transformation and enrichment into real-time decisioning:- Connectors ingest data from 24 registered source types (17 production-ready, 7 coming-soon): S3, Snowflake, BigQuery, PostgreSQL, MySQL, Kafka/Confluent (batch polling), REST APIs, and more. See Connectors for the full status table.
- Schemas define entity structures (customer, account, product) and create real PostgreSQL tables via DDL.
- Pipelines transform and load data using a visual flow editor with 15 transform types (cast, filter, expression, hash, mask PII, rename, and others).
- Enrichment queries schema tables at decision time to load customer context, with Redis caching for performance.
- Decision Engine runs the configured flow: qualification rules, formula-based computed values, scoring models, ranking, and multi-objective portfolio optimization.
- API Response returns personalized offer recommendations with computed values merged into the response payload.
API Layer
All API endpoints live under/api/v1/* and follow a consistent pattern:
- Validation — Every request body is validated against a Zod schema before processing. Invalid requests return
400with structured error details. - ORM — Prisma 7 with the
@prisma/adapter-pgdriver adapter handles all database access. The PrismaClient singleton uses apg.Poolwith configurable connection limits, timeouts, and graceful shutdown hooks. - Tenant Isolation — Queries are scoped to the authenticated tenant. Tenant settings control feature flags like decision tracing sample rates.
- Error Handling — Standard HTTP status codes (
200,201,400,404,409,500) with JSON error bodies. - Rate Limiting — Sliding-window rate limiter protects high-throughput endpoints (journey callbacks, recommend API).
| Endpoint | Purpose |
|---|---|
POST /api/v1/recommend | Execute a Decision Flow and return ranked offers with computed values |
POST /api/v1/respond | Record an outcome event (impression, click, conversion) with attribution |
CRUD /api/v1/decision-flows | Manage Decision Flow configurations |
CRUD /api/v1/schemas | Manage entity schemas (triggers real DDL) |
CRUD /api/v1/connectors | Manage data source connections |
CRUD /api/v1/pipelines | Manage ETL pipeline definitions |
GET /api/v1/metrics | Prometheus-format platform metrics |
Frontend Architecture
The frontend uses the Next.js App Router with a consistent two-panel layout: a list view on the left and a detail/editor panel on the right.- React Query manages all server state. Mutations automatically invalidate related queries so lists stay current after creates, updates, or deletes.
- Zustand holds ephemeral UI state (selected items, panel visibility, editor mode) that does not need to survive a page reload.
- React Flow (
@xyflow/react) powers the visual editors for data pipelines, Decision Flows, and customer journeys. Nodes and edges are persisted as JSON in the database. - Component Library — Radix UI primitives with Tailwind styling. The theme uses oklch CSS variables with light, dark, and system modes.
- Formula Engine — A custom tokenizer and recursive-descent parser evaluates computed field formulas safely (no
eval). Supports arithmetic, comparisons, ternary expressions, and functions likemin,max,round,coalesce, andconcat.
Related
Decision Engine
How the Decision Flow engine processes recommend requests.
Operations & Monitoring
Metrics, tracing, circuit breakers, and dead-letter queues.
Scaling Guide
Connection pooling, caching, and horizontal scaling patterns.
Deployment Options
Local, App Runner, and Kubernetes deployment methods.