Skip to content

RouterV2

Publisher Platform Intelligent Request Router & Content Delivery Engine

Service Type: Kubernetes Microservice
Technology: Node.js (JavaScript)
Runtime: Node.js Container
Last Updated: 2025-07-01


📋 Overview

RouterV2 is the core intelligent routing and content delivery engine for the Publisher platform. It serves as the central orchestrator that processes incoming requests, makes intelligent routing decisions, manages campaigns, handles content delivery, and coordinates with multiple external services. The service features a sophisticated multi-stage pipeline architecture with parallel processing capabilities.

Key Features

  • Intelligent Request Routing: Advanced decision-making engine for request routing
  • Multi-Stage Pipeline: Sophisticated 10-stage processing pipeline with parallel execution
  • Campaign Management: Dynamic campaign selection and experience type determination
  • Content Delivery: Comprehensive content management and delivery system
  • Cache Integration: Multi-layer caching with Redis and document cache
  • Decision Engine: External decision handler integration for complex routing logic
  • Session Management: Advanced session tracking and state management
  • Overflow Handling: Intelligent traffic overflow and redirect management

🛠 Technology Stack

Component Technology
Language JavaScript (Node.js)
Runtime Node.js Container
Framework Custom Pipeline Architecture
Database Azure Cosmos DB
Caching Redis, Document Cache
Rules Engine JSON Rules Engine
Template Engine Mustache
Validation AJV JSON Schema
Container Docker
Orchestration Kubernetes

🏗 Architecture

Service Architecture

  • Deployment Pattern: Kubernetes Deployment with HTTP Service
  • Processing Model: Multi-stage pipeline with parallel execution
  • Caching Strategy: Multi-layer caching (Redis, Document Cache, Content Cache)
  • Decision Making: External decision handler integration
  • Content Management: Dynamic content generation and delivery
  • Session Management: Persistent session state with Redis

System Flow

graph TD
    A[HTTP Request] --> B[RouterV2 Service]
    B --> C[Pipeline Initialization]
    C --> D[Parallel Processing Engine]
    D --> E[Stage 1: Input Preparation]
    E --> F[Stage 2: Redirect Checks]
    F --> G[Stage 3: External Dependencies]
    G --> H[Stage 4: Data Processing]
    H --> I[Stage 5: Decision Making]
    I --> J[Stage 6: Overflow Handling]
    J --> K[Stage 7: Content Generation]
    K --> L[Stage 8: Response Creation]
    L --> M[Stage 9: Response Saving]
    M --> N[Stage 10: Verbose Response]
    N --> O[HTTP Response]

📚 Documentation Structure

This service is complex enough to warrant detailed documentation across multiple files:

Core Documentation

  • README.md - This overview and getting started guide
  • Architecture.md - Detailed system architecture and design patterns
  • Pipeline.md - Complete pipeline stage documentation
  • API.md - Comprehensive API documentation and examples

Technical Documentation

Operational Documentation

🔄 Quick Start

Basic Request Flow

sequenceDiagram
    participant Client
    participant Router as RouterV2
    participant Cache as Redis Cache
    participant Decision as Decision Engine
    participant Content as Content Service

    Client->>Router: HTTP Request
    Router->>Router: Initialize Pipeline
    Router->>Cache: Check Session Cache
    Cache-->>Router: Session Data
    Router->>Decision: Make Routing Decision
    Decision-->>Router: Routing Response
    Router->>Content: Get Content
    Content-->>Router: Content Data
    Router-->>Client: HTTP Response

Key Processing Stages

  1. S00 Initialize - Request setup and validation
  2. S01 Prepare Input - Query string and header processing
  3. S02 Check Redirect - Redirect logic and permanent redirects
  4. S03 Load External Dependencies - Campaign and brand data loading
  5. S04 Process Data - Data processing and transformation
  6. S05 Make Decision - Intelligent routing decisions
  7. S06 Check Overflow - Traffic overflow handling
  8. S07 Get Content - Content generation and retrieval
  9. S08 Create Response - Response formatting
  10. S09 Save Response - Response persistence
  11. S10 Verbose Response - Debug and verbose output

📡 API Overview

Primary Endpoints

  • GET /: Main routing endpoint with query parameter processing
  • POST /: Form submission and POST data handling
  • GET /live: Health check endpoint
  • GET /ready: Readiness probe endpoint
  • POST /postresponse: Post-response processing

Request Processing

RouterV2 handles multiple request types: - Landing Page Requests: Dynamic landing page generation - Form Requests: Form processing and submission handling - Widget Requests: Widget content delivery - Ad Requests: Advertisement content serving - Redirect Requests: Intelligent redirect handling

For detailed API documentation, see API.md.

⚙️ Configuration

RouterV2 uses a sophisticated configuration system with environment-specific settings:

// Basic configuration structure
{
  "decisionHandlerUrl": "https://decision-service/api",
  "cacheSettings": {
    "redis": { /* Redis configuration */ },
    "documentCache": { /* Document cache settings */ }
  },
  "pipeline": {
    "parallelProcessing": true,
    "timeouts": { /* Stage timeouts */ }
  }
}

For complete configuration documentation, see Configuration.md.

🚀 Deployment

Kubernetes Deployment

# Apply Kubernetes manifests
kubectl apply -f k8s/

# Check deployment status
kubectl get pods -l app=routerv2

# View logs
kubectl logs -l app=routerv2 -f

For detailed deployment procedures, see Deployment.md.

📊 Monitoring

Key Metrics

  • Pipeline execution time per stage
  • Cache hit/miss ratios
  • Decision engine response times
  • Content delivery performance
  • Error rates by stage

For comprehensive monitoring setup, see Monitoring.md.

🔧 Troubleshooting

Common Issues

  • Pipeline stage failures
  • Cache connectivity issues
  • Decision engine timeouts
  • Content delivery errors

For detailed troubleshooting procedures, see Troubleshooting.md.

🤝 Dependencies

Internal Dependencies

  • Decision Handler Service: External decision making
  • Document Cache Service: Configuration and data caching
  • Content Management Service: Content delivery
  • Campaign Management: Campaign data and configuration

External Dependencies

  • Redis: Session and data caching
  • Azure Cosmos DB: Data persistence
  • External Decision Engine: Routing decision logic

NPM Dependencies

  • json-rules-engine: Business rules processing
  • mustache: Template rendering
  • ajv: JSON schema validation
  • @redis/client: Redis integration
  • axios: HTTP client for external services

📖 Next Steps

  1. Read the Architecture Guide - Understand the system design
  2. Explore the Pipeline Documentation - Learn about processing stages
  3. Review API Documentation - Understand request/response patterns
  4. Configure Your Environment - Set up for development

This documentation was created through manual code analysis of the RouterV2 microservice codebase.