← Hub | Overview & IDE
System Ready
PDI Ref Services Architecture Tickets Guide
Technology Stack
Lula Direct × PDI Conexxus Loyalty Integration — 3 services, 12+ technologies, 1 unified platform
🌐
Frontend
Next.js 14 · React 18 · Tailwind
⚙️
Backend
MedusaJS · Node.js 18 · PostgreSQL
🛡️
Microservice
NestJS 10 · TypeORM · PDI REST
🔌
External
PDI Conexxus v1.1 · OAuth2 · TLS
📦
MedusaJS
v1.x
Open-source headless commerce engine powering catalog, inventory, orders, and checkout orchestration with plugin architecture.
Backend core, REST API endpoints, database ORM, plugin system
⚛️
Next.js
v14 (App Router)
React framework with server components, App Router, and built-in optimizations for the customer-facing storefront experience.
Pages, API routes, SSR/SSG, image optimization
🚀
NestJS
v10
Progressive Node.js framework for the dedicated loyalty microservice — dependency injection, modules, guards, and interceptors.
Loyalty Service, DI container, module system, interceptors
🖥️
Node.js
v18+ LTS
JavaScript runtime powering all three services — async I/O, event-driven architecture, and npm ecosystem for rapid development.
V8 engine, async I/O, event loop, npm ecosystem
📘
TypeScript
v5.x (Strict)
Type-safe superset of JavaScript used across all services — interfaces for PDI models, DTOs, and shared contracts between layers.
Type checking, IDE support, PDI model interfaces, DTOs
🗃️
PostgreSQL
v14+
Relational database for Medusa commerce data — orders, products, customers. Loyalty sessions and store configs stored via TypeORM entities.
Connection pooling, query execution, transaction management
Redis
Cache & Sessions
In-memory data store for loyalty session caching, rate limiting PDI API calls, and circuit breaker state management.
Connection: redis:6379, session cache, rate limiter
🔄
TanStack Query
v5
Server state management for the storefront — automatic cache invalidation, optimistic updates for loyalty reward selection, and query deduplication.
API data fetching, infinite queries, optimistic updates
🎨
Tailwind CSS
v3
Utility-first CSS framework for storefront styling — responsive design, dark mode ready, and consistent design tokens across components.
Layout, typography, responsive breakpoints, JIT mode
🔌 PDI Conexxus Protocol Stack
📱
Storefront
React UI
Phone Entry
⚙️
Medusa API
REST Endpoints
/store/loyalty
🛡️
Loyalty Service
NestJS
Session Manager
🔐
OAuth2
client_credentials
Bearer Token
🏢
PDI Conexxus
REST API v1.1
OpenAPI 3.0.3
8
POST Endpoints
TLS 1.2+
Transport Security
JSON
Request/Response
< 2s
p95 Latency Target
Technology Version Layer Purpose Maturity
MedusaJS 1.x Backend Commerce Engine
Next.js 14 Frontend Storefront UI
NestJS 10 Microservice Loyalty Service
PostgreSQL 14+ Database Primary Store
TypeScript 5.x All Layers Type Safety
PDI Conexxus v1.1 External Loyalty Host API
TanStack Query v5 Frontend Server State
Tailwind CSS v3 Frontend Utility Styles
📦
Docker
Containerization
Container runtime for packaging and deploying all three services with consistent environments across dev, staging, and production.
Docker Compose, multi-stage builds, service orchestration
🔗
TypeORM
ORM Layer
Object-relational mapper providing entity definitions, database migrations, and query builder for both Medusa and Loyalty Service.
Entity definitions, migrations, query builder, relations
🔐
OAuth2
PDI Auth
Client credentials flow for authenticating with PDI Conexxus API. Bearer tokens with automatic refresh and secure credential storage.
Token generation, auto-refresh, credential management
🧪
Jest
Unit Testing
JavaScript testing framework for unit and integration tests across all services with snapshot testing and mock support.
Unit tests, integration tests, mocks, coverage reports
ESLint + Prettier
Code Quality
Static analysis and auto-formatting for consistent code style across all TypeScript services and React components.
Linting rules, auto-format, pre-commit hooks
📄
OpenAPI 3.0.3
API Spec
PDI Conexxus REST API specification defining all 8 POST endpoints, request/response schemas, and authentication requirements.
API documentation, schema validation, code generation

System Architecture

MedusaJS Backend
Headless commerce engine handling product catalog, inventory, orders, and core checkout logic. Integrates with Loyalty Service for reward computation and PDI for real-time member validation.
Next.js Storefront
Customer-facing application managing product browsing, cart operations, and checkout experience. Synchronizes loyalty session state and displays personalized rewards in real-time.
NestJS Loyalty Service
Dedicated microservice orchestrating PDI API interactions, managing loyalty calculations, session state, and reward tracking. Acts as the integration bridge between Medusa and PDI systems.
Integration Flow
End-to-end loyalty lifecycle — from phone number entry to points finalization
📱
1
Identify
Customer enters loyalty phone number at checkout
Storefront
⚙️
2
PDI Lookup
Medusa routes to Loyalty Service; validates member via PDI
Backend
🎁
3
Rewards
Instant rewards auto-applied; optional rewards displayed for selection
Service
🛒
4
Cart Eval
Cart re-evaluated with loyalty discounts; totals recalculated
Backend
5
Finalize
Order completes; deferred FinalizeRewards sent to PDI with actual items
PDI API
Data Synchronization Strategy
Real-time member data is cached in LoyaltySession. Circuit breaker prevents cascading failures if PDI is unavailable. Session state is ephemeral (cleared on order completion). Loyalty metadata is persisted in order records for audit and reconciliation purposes.

Service Status & Details

ACTIVE
MedusaJS Backend
Headless commerce engine processing catalog, inventory, orders, and checkout orchestration with Loyalty Service integration.
Endpoints: /admin/loyalty, /store/loyalty, /store/orders
Runtime: Node.js 18+
Database: PostgreSQL 14+
ACTIVE
Next.js Storefront
Customer-facing single-page application enabling product browsing, loyalty identification, reward selection, and checkout experience.
Framework: Next.js 14 (App Router)
Client State: React Context + TanStack Query
Styling: Tailwind CSS v3
PLANNING
Loyalty Service (NestJS)
Dedicated microservice managing PDI API integration, loyalty calculations, session state machine, and reward persistence.
Framework: NestJS 10
Authentication: OAuth2 Bearer tokens
State Machine: State-driven session lifecycle