API GatewayOverview

DVĀRA (द्वार) — Avyay Unified API Gateway

द्वार (DVĀRA) — Sanskrit for “gateway” or “door”

DVĀRA is the unified API gateway for all Avyay AI products. It provides a single endpoint with authentication, rate limiting, and usage tracking for MĀRGA, RAKṢĀ, and DevOps RAG.

Architecture

                    ┌──────────────┐
                    │   Clients    │
                    └──────┬───────┘

                    ┌──────▼───────┐
                    │   DVĀRA      │
                    │   Gateway    │
                    │   :9000      │
                    └──────┬───────┘

          ┌────────────────┼────────────────┐
          │                │                │
   ┌──────▼──────┐ ┌──────▼──────┐ ┌───────▼──────┐
   │   MĀRGA     │ │   RAKṢĀ    │ │  DevOps RAG  │
   │  LLM Router │ │  Scanner   │ │  Knowledge   │
   │   :8080     │ │   :8080    │ │    :8080     │
   └─────────────┘ └─────────────┘ └──────────────┘

Features

  • Unified Authentication: Single API key for all services via X-API-Key header or Bearer token
  • Rate Limiting: Per-key and global rate limits to prevent abuse
  • Usage Tracking: Monitor API usage by service and key with /v1/gateway/usage
  • Health Aggregation: Single /health endpoint checks all backend services
  • Service Routing: Automatic request routing to the correct backend

Quick Start

docker pull ghcr.io/gaurav21/avyay-gateway:latest
 
docker run -p 9000:9000 \
  -e MARGA_URL=http://marga:8080 \
  -e RAKSHA_URL=http://raksha:8080 \
  -e DEVOPS_RAG_URL=http://devops-rag:8080 \
  ghcr.io/gaurav21/avyay-gateway:latest

Endpoints

MethodPathServiceDescription
GET/GatewayGateway info and registered services
GET/healthGatewayHealth check for all services
GET/v1/gateway/usageGatewayUsage statistics (admin)
POST/v1/marga/chat/completionsMĀRGAChat completions via LLM Router
GET/v1/marga/metricsMĀRGARouter metrics (Prometheus format)
GET/v1/marga/usageMĀRGAMĀRGA usage statistics
POST/v1/raksha/scan/uploadRAKṢĀUpload code for scanning
POST/v1/raksha/scan/githubRAKṢĀScan GitHub repository
GET/v1/raksha/scan/{"{id}"}RAKṢĀGet scan results
POST/v1/devops-rag/askDevOps RAGAsk a DevOps question
GET/v1/devops-rag/statsDevOps RAGIndex statistics

Authentication

All requests (except / and /health) require authentication:

# Using X-API-Key header
curl -H "X-API-Key: your-api-key" http://localhost:9000/v1/marga/chat/completions
 
# Using Bearer token
curl -H "Authorization: Bearer your-api-key" http://localhost:9000/v1/marga/chat/completions

Example: Chat Completion via Gateway

curl -X POST http://localhost:9000/v1/marga/chat/completions \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Hello from DVĀRA!"}]
  }'

Example: Security Scan via Gateway

curl -X POST http://localhost:9000/v1/raksha/scan/github \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{"url": "https://github.com/your-org/your-repo"}'

Example: DevOps Question via Gateway

curl -X POST http://localhost:9000/v1/devops-rag/ask \
  -H "Content-Type: application/json" \
  -H "X-API-Key: your-api-key" \
  -d '{"question": "How do I fix CrashLoopBackOff?"}'