Gateway & Routing

The Gateway Service is the single entry point for all client traffic. Built with Express.js, it handles authentication, rate limiting, and proxying requests to the appropriate backend service.

Routing Table

Path PrefixTarget ServicePort
/api/tenantTenant Service:8001
/api/notificationNotification Service:8002
/api/cmsCMS Service:8003
/api/adminAdmin Service:8004
/api/mediaMedia Service:8005
/api/biBI Service:8006
/api/electronicElectronic Service:8007
/api/correspondenceCorrespondence Service:8008
/api/taskTask Service:8014
/api/searchSearch Service:8015
/api/identityIdentity Service:8016
/api/profileProfile Service:8017

Middleware Chain

Gateway Middleware Chain

Loading diagram...

Middleware Details

MiddlewarePurpose
HelmetHTTP security headers (XSS, HSTS, etc.)
CORSCross-origin request handling
Rate LimiterPer-tenant/per-user request throttling
JWT ValidationToken verification via Identity Service
Tenant ResolutionExtract and validate tenant context
Proxy ForwardRoute to target service via http-proxy-middleware

Service-to-Service (S2S) Forwarding

The Gateway also handles internal service-to-service authentication. When a service needs to call another, it can either:

  1. Direct HTTP — Service calls another service directly with S2S token
  2. Via Gateway — Requests routed through the gateway for consistent auth handling
Info

The Gateway maintains a Redis-backed session store for token caching and session management. JWT tokens are validated on every request.

Configuration

NameTypeDefaultDescription
PORTnumber80Gateway listening port
REDIS_HOSTstringlocalhostRedis host for session store
REDIS_PORTnumber6379Redis port
JWT_SECRETstring-JWT signing secret
RATE_LIMIT_MAXnumber100Max requests per window
RATE_LIMIT_WINDOWstring15mRate limit time window

Health Check

The Gateway exposes a health endpoint that checks connectivity to all downstream services:

GET
/health

Returns health status of the gateway and all downstream service connections