Powering the next-gen e-commerce experience for Kigalishopexpress.com โ seamless API orchestration, aggregated responses, and frontend optimization layer.
Version: 2.1.0
5007production (staging-ready)Node.js + Express2025-04-17Enabled for trusted originsRequest aggregation, response shaping, authentication delegation, and section-based property data orchestration for frontend clients (React/Next.js).
All endpoints are prefixed with /bff and designed specifically for the Kigalishopexpress frontend requirements. Each route returns optimized payloads, reducing client-side processing.
{
"status": "success",
"section": "new_arrivals",
"data": [
{ "id": "p101", "name": "Rwandan Coffee Beans", "price": 12.99, "image_url": "...", "seller": "Kigali Farmers Coop" },
{ "id": "p102", "name": "Handmade Agaseke Basket", "price": 24.50, "image_url": "...", "seller": "Women Craft Guild" }
],
"cached": false,
"timestamp": "2025-04-17T10:23:45Z"
}
Why BFF? The Backend For Frontend pattern isolates frontend-specific concerns. Instead of forcing generic APIs, our BFF tailors responses for web clients, reduces over-fetching, and improves performance.
1. Browser โ BFF (GET /bff/property/sections/new-arrivals)
2. BFF validates JWT token (if needed)
3. BFF concurrently calls:
- Product Service (new arrivals IDs)
- Image Service (product thumbnails)
- Rating Service (average reviews)
4. BFF aggregates data & reshapes into frontend-friendly schema
5. BFF caches response for 60 seconds (Redis)
6. Returns JSON payload to client
Current BFF runtime variables (simplified)
.env
# ============================================
# Kigalishopexpress BFF Environment Variables
# ============================================
# Server configuration
PORT=5007
NODE_ENV=production
# Upstream API Gateway endpoint
API_GATEWAY_URL=https://api.kigalishopexpress.com/gateway
# Redis connection for caching & sessions
REDIS_URL=redis://cache.kigalishopexpress:6379
# JWT secret for token verification (frontend tokens)
JWT_SECRET=your_super_secret_key_rotate_me
# Service timeouts (ms)
PRODUCT_SERVICE_TIMEOUT=2000
RECOMMENDATION_TIMEOUT=1500
# Feature flags
ENABLE_RESPONSE_COMPRESSION=true
CACHE_TTL_SECONDS=60
๐ Note: Multi-line comments in .env are not natively supported, but we prefix each line with # for readability โ this block documents all required keys.
/health endpoint returns detailed service status, connectivity to API Gateway, and Redis availability. Integrated with Prometheus metrics.