Complex E2E Example with Gateway API
This example demonstrates a complete end-to-end setup of the Gateway API with various features including data access control, caching, and PII data handling.
Components
- Gateway API: REST API service with customer order endpoints
- PostgreSQL: Main database storing order and customer data
- Jaeger: Distributed tracing system for monitoring
- Presidio: Service for PII data anonymization
Features Demonstrated
- REST API endpoints for customer orders
- LRU caching with TTL
- API key authentication
- Row-level security using Lua scripts
- PII data removal
- OpenTelemetry integration with Jaeger
- Star schema data model for order analytics
Prerequisites
- Docker
- Docker Compose
Getting Started
-
Start all services:
Terminal window docker-compose up -d -
Services will be available at:
- Gateway API: http://localhost:8182
- Jaeger UI: http://localhost:16686
- PostgreSQL: localhost:5432
- Presidio: http://localhost:5001
API Endpoints
1. Search Customer Orders
GET /customer/{customer_key}/ordersQuery parameters:
start_date(optional): Filter orders from this dateend_date(optional): Filter orders until this datemin_total(optional): Minimum order totalmax_total(optional): Maximum order totallimit(optional, default: 50): Number of resultsoffset(optional, default: 0): Pagination offset
2. Get Order Details
GET /customer/{customer_key}/order/{payment_key}Security Features
-
API Key Authentication:
- Header:
x-api-key - Available keys:
all_methods: Access to all endpointsonly_orders: Limited to order-related endpoints
- Header:
-
Row-Level Security:
- Validates user access using
X-User-IDheader - Ensures users can only access their own data
- Validates user access using
-
PII Protection:
- Automatically removes sensitive information from
addressfields
- Automatically removes sensitive information from
Database Schema
The database follows a star schema design with:
- Fact table:
fact_table(order transactions) - Dimension tables:
payment_dim: Payment informationcustomer_dim: Customer detailsitem_dim: Product informationstore_dim: Store locationstime_dim: Time-based dimensions
Configuration Files
docker-compose.yml: Service orchestrationgateway.yaml: Gateway API configurationconnection.yaml: Database connection settingsinit.sql: Database initialization script
Data Loading
Sample data is automatically loaded during initialization from CSV files mounted in the PostgreSQL container.