A production-style API gateway in Python/FastAPI with API key authentication, per-key rate limiting, and structured request logging.
Live URL: https://gatekeeper-ccgq.onrender.com/docs
- API Key Authentication — Validates incoming requests via the
X-API-Keyheader against a cloud-hosted datastore and returns401 Unauthorizedfor invalid credentials. - Per-Key Token-Bucket Rate Limiting — Enforces traffic limits using configurable token-bucket parameters stored in the database.
- Resilient Async Proxy — Forwards authenticated traffic to upstream services with timeout protection and proper error handling.
- Structured Request Logging — Captures request metadata including route, status code, latency, and client IP for observability and auditing.
- Environment Isolation — Supports Local, CI, and Production environments through environment-variable based configuration.
- Framework: Python 3.12, FastAPI, Uvicorn
- ORM: SQLAlchemy 2.0
- Migrations: Alembic
- Database: Neon PostgreSQL
- Deployment: Docker, Render
- Testing: Pytest, GitHub Actions
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Health check |
| GET | /docs |
Swagger UI documentation |
| GET | /proxy |
Authenticated, rate-limited proxy endpoint |
[ Local Client / curl ] --- (HTTPS) ---> [ Render Container ]
|
(Auth & Logging)
v
[ Neon PostgreSQL ]
DATABASE_URL— PostgreSQL connection stringPORT— Container port (default:8000)
Create a .env file:
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/gatekeeper"
TEST_DATABASE_URL="postgresql://postgres:postgres@localhost:5432/gatekeeper_test"docker-compose up -dalembic upgrade headuvicorn app.main:app --reload --host 0.0.0.0 --port 8000pytest