Production-Grade API Gateway

Production-Grade API Gateway

Built a production-grade API Gateway from scratch with Node.js, TypeScript, and Redis, featuring a custom Trie-based router, Koa-style middleware pipeline, and Redis Lua-script rate limiting (Sliding Window and Token Bucket) with ETag response caching. Implemented a streaming reverse proxy using native Node.js HTTP streams and a self-healing Circuit Breaker, exposing Prometheus-compatible metrics for latency, throughput, and cache hit ratio.

Tech Stack

Node.jsTypeScriptRedisKoa MiddlewarePrometheusDocker

Key Features

  • Custom Trie-based Router & Koa-style Middleware Pipeline.
  • Redis Lua-script Rate Limiting implementing Sliding Window and Token Bucket algorithms.
  • ETag Response Caching for high-frequency microservice queries.
  • Streaming Reverse Proxy using native Node.js HTTP streams.
  • Self-Healing Circuit Breaker preventing cascading microservice failures.
  • Prometheus-compatible metrics endpoint for real-time latency, throughput, and cache hit ratio tracking.

Architecture & System Design

Rate-Limited Node.js API Gateway Architecture
Rate-Limited Node.js API Gateway Architecture