Skip to content

yshvrd/Production-Grade-API-Infrastructure-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Production Grade API Infrastructure Platform

A production-style API infrastructure platform that enforces rate limiting, idempotency, and asynchronous job execution in front of backend APIs.

demo.gif

what problem it solves

  • Protects core APIs from overload
  • Prevents duplicate requests
  • Offloads heavy work asynchronously

High level architecture

  • Client → platform-service → core-service
  • Platform Service:
    • Sync path (/orders)
    • Async path (/orders/process)
  • Redis → rate limiting + sync idempotency
  • PostgreSQL → async task state
  • RabbitMQ + Celery → background execution
  • Core Service → simulates real business API
  • Streamlit → monitoring UI

demo.gif demo.gif

Service responsibility and ownership

  1. Core Service — Execution Layer

    • Owns business logic
    • Executes orders
    • Stateless and unaware of infra concerns
  2. Platform Service — Policy & Control Layer

    • Enforces rate limits
    • Handles idempotency
    • Orchestrates async execution
    • Protects and shields core-service

Request flows

  • Sync flow (/orders)

    • Client sends request
    • Platform checks Redis idempotency
    • Rate limit enforced
    • Forwarded to core-service
    • Response returned immediately
  • Async flow (/orders/process)

    • Client sends request
    • Platform writes task to DB (QUEUED)
    • Task enqueued to Celery
    • Worker processes task
    • Core-service called
    • DB updated (SUCCESS / FAILED)
    • Client polls /tasks/{task_id}

API Endpoints

  • POST /orders
  • POST /orders/process
  • GET /tasks/{task_id}

Tech stack

  • FastAPI
  • Redis
  • PostgreSQL
  • Celery
  • RabbitMQ
  • Streamlit
  • Docker (coming next)

Run locally

  1. Clone the repo
git clone https://github.com/yshvrd/Production-Grade-API-Infrastructure-Platform

cd Production-Grade-API-Infrastructure-Platform
  1. Create and run a virtual environment
python3 -m venv .venv 

source .venv/bin/activate
  1. Install dependencies
pip install -r requirements.txt
  1. Start infrastructure services
brew install redis rabbitmq 

brew services start redis 

brew services start rabbitmq 
  1. Run database and create table
docker run --name platform-postgres \
  -e POSTGRES_USER=platform \
  -e POSTGRES_PASSWORD=platform \
  -e POSTGRES_DB=platform_db \
  -p 5432:5432 \
  -d postgres:16
cd backend/platform-service

python -m db.create_table

  1. start core-service
cd backend/core-service 

uvicorn app:app --port 8001
  1. Start platform-service
cd backend/platform-service

uvicorn app:app --port 8000
  1. Start celery worker
cd backend/platform-service

celery -A celery_app worker --loglevel=info
  1. Start frontend (UI)
cd frontend

streamlit run app.py
  1. Interact with the app
http://localhost:8501

Deployment Status(Planned)

  • Services are designed to be containerized independently
  • Dockerfiles exist for individual services (incomplete for production. When run individually, containers will start but will not be fully functional)
  • Full orchestration intentionally deferred

Limitations and Future Improvements

  • Authentication not implemented
  • Docker Compose deferred
  • No metrics dashboard
  • Async retries implemented, but no dead-letter queues
  • No distributed tracing (OpenTelemetry)
  • Secrets managed via env vars for simplicity

Screenshots

Screenshot-1 Screenshot-2 Screenshot-3 Screenshot-4 Screenshot-5 Screenshot-6

About

A production-style API infrastructure platform demonstrating rate limiting, idempotency, and async job execution in front of backend services

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors