This repository contains the Data Plane for GatewayOS. It is a highly optimized, low-latency API Gateway built with Node.js and Express. It sits in front of your microservices, intercepts incoming traffic, and executes a rigorous middleware pipeline before securely proxying the request upstream.
Note: This proxy relies on configurations set by the GatewayOS Admin Dashboard.
Every request passing through GatewayOS is subjected to a synchronous, strictly-ordered pipeline. If a request fails any stage, it is immediately rejected without wasting upstream resources.
- Route Matching: Scans the Postgres database (via Prisma) to find the configured upstream destination for the incoming
PathandMethod. - Rate Limiter: Connects to Redis to execute a Sliding Window algorithm. Enforces strict
X requests per Y secondslimits based on IP or Headers. - Auth Enforcer: Cryptographically verifies JWT signatures or hashes incoming API Keys against the database. Injects user identity headers (
X-Gateway-User-Id) into the request. - Circuit Breaker: Checks Redis for the health state of the upstream service (
CLOSED,OPEN,HALF_OPEN). Instantly trips and returns503 Service Unavailableif the upstream is experiencing a high failure rate, protecting it from catastrophic overload. - Payload Transformer: Mutates the request on the fly. Strips sensitive PII from JSON bodies, injects security headers, or rewrites URL paths before forwarding.
- Upstream Proxy: Forwards the sanitized request to the final destination, measures the exact latency, and logs the response payload size.
This proxy is designed for raw throughput. By utilizing a persistent ioredis TCP connection and intelligent database indexing, the Gateway maintains sub-millisecond processing overhead per request. It is capable of handling heavy concurrent traffic and correctly tripping circuit breakers under simulated DDoS or upstream outage scenarios.
- Runtime: Node.js
- Server: Express.js
- Database Client: Prisma (Neon Postgres)
- Caching / State:
ioredis(TCP connection for maximum throughput)
1. Clone the repository
git clone [https://github.com/yourusername/gatewayos-backend.git](https://github.com/yourusername/gatewayos-backend.git)
cd gatewayos-backend
npm install2. Configure Environment Variables
Create a .env file in the root directory. Note: Ensure this connects to the exact same database and Redis instance as your Frontend Control Plane.
# Database & Cache
DATABASE_URL="postgresql://..."
REDIS_URL="redis://..." # Use the standard Redis URL, not the REST URL used in the frontend3. Sync Prisma Client
npx prisma generate4. Run the Proxy
npm run devThe Gateway will start listening on http://localhost:3001. Send traffic to this port, and configure your routing rules in the Next.js Admin Dashboard!
Clinton Phillips
- Portfolio: clintondevlab.netlify.app
- LinkedIn: in/clinton-phillips-316a42250
- X / Twitter: @phillips464