# mokshsharma2006/post-quantum-intelligent-api-gateway architecture

> Architecture diagram of the GitHub repository mokshsharma2006/post-quantum-intelligent-api-gateway, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mokshsharma2006/post-quantum-intelligent-api-gateway
- Repository: https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway

## Overview

This is a post-quantum, AI-assisted API security gateway. Its principal workflow is client request filtering and sanitization, asynchronous AI analysis, rate limiting, and backend proxying; the gateway also provides PQC demonstrations and security telemetry for a dashboard. The graph preserves documented capabilities, but some subsystems and runtime links are described only in the README; those relationships are cited there rather than presented as source-verified calls.

Main entry points: [`gateway/src/main.cpp`](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp) (HTTP Gateway), [`ai/security_engine.py`](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/ai/security_engine.py) (Security Analyzer), [`gateway/include/rate_limiter.hpp`](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/rate_limiter.hpp) (Rate Limiter), [`gateway/include/zmq_client.hpp`](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/zmq_client.hpp) (ZeroMQ Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway Security"]
  node_gateway_core["HTTP Gateway<br/>[main.cpp]"]
  node_blocklist["AI Blocklist<br/>[ai_enforcement.hpp]"]
  node_prefilter["Payload Pre-filter<br/>[main.cpp]"]
  node_sanitizer["Request Sanitizer<br/>[main.cpp]"]
  node_rate_limiter["Rate Limiter<br/>[rate_limiter.hpp]"]
  node_token_bucket["Token Bucket<br/>[token_bucket.hpp]"]
  node_pqc["PQC Manager<br/>[pqc_manager.cpp]"]
  node_zmq["ZeroMQ Client<br/>[zmq_client.hpp]"]
  node_receiver["AI Decision Receiver"]
  node_ai_enforcement["AI Enforcement State<br/>[ai_enforcement.cpp]"]
end

subgraph group_analysis["Threat Analysis"]
  node_ai_engine["Security Analyzer<br/>[security_engine.py]"]
  node_classifier["Gemini Classifier<br/>[llm_classifier.py]"]
end

subgraph group_services["Backend Services"]
  node_backend["Backend API<br/>[app.py]"]
end

subgraph group_visibility["Monitoring"]
  node_metrics["Request Metrics"]
  node_event_log[("Security Event Log")]
  node_telemetry["Telemetry Endpoints<br/>[main.cpp]"]
  node_dashboard["Security Dashboard<br/>[index.html]"]
end

node_client(("API Client"))
node_gemini["Google Gemini"]

node_client -->|"sends requests"| node_gateway_core
node_gateway_core -->|"checks client"| node_blocklist
node_gateway_core -->|"filters payload"| node_prefilter
node_gateway_core -->|"sanitizes request"| node_sanitizer
node_gateway_core -->|"sends event"| node_zmq
node_zmq -->|"sends metadata"| node_ai_engine
node_ai_engine -->|"requests analysis"| node_classifier
node_classifier -.->|"analyzes request"| node_gemini
node_ai_engine -->|"returns decisions"| node_receiver
node_receiver -->|"records decisions"| node_ai_enforcement
node_gateway_core -->|"checks request"| node_rate_limiter
node_rate_limiter -->|"uses bucket"| node_token_bucket
node_gateway_core -->|"proxies request"| node_backend
node_gateway_core -->|"serves PQC endpoints"| node_pqc
node_gateway_core -.->|"records traffic"| node_metrics
node_gateway_core -.->|"records events"| node_event_log
node_gateway_core -->|"serves telemetry"| node_telemetry
node_telemetry -->|"provides data"| node_dashboard

click node_gateway_core "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp"
click node_blocklist "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/ai_enforcement.hpp"
click node_prefilter "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp"
click node_sanitizer "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp"
click node_rate_limiter "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/rate_limiter.hpp"
click node_token_bucket "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/token_bucket.hpp"
click node_pqc "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/pqc_manager.cpp"
click node_zmq "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/zmq_client.hpp"
click node_receiver "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/ai_decision_receiver.cpp"
click node_ai_enforcement "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/ai_enforcement.cpp"
click node_ai_engine "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/ai/security_engine.py"
click node_classifier "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/ai/llm_classifier.py"
click node_backend "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/backend/app.py"
click node_metrics "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/security_metrics.hpp"
click node_event_log "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/security_event_log.hpp"
click node_telemetry "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp"
click node_dashboard "https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/dashboard/index.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_gateway_core,node_blocklist,node_prefilter,node_sanitizer,node_rate_limiter,node_token_bucket,node_pqc,node_zmq,node_receiver,node_ai_enforcement,node_client toneBlue
class node_ai_engine,node_classifier toneAmber
class node_backend toneMint
class node_metrics,node_event_log,node_telemetry,node_dashboard toneRose
class node_gemini toneIndigo
```

## Components

### Gateway Security

- [HTTP Gateway](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp): `gateway/src/main.cpp`
- [AI Blocklist](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/ai_enforcement.hpp): `gateway/include/ai_enforcement.hpp`
- [Payload Pre-filter](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp): `gateway/src/main.cpp`
- [Request Sanitizer](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp): `gateway/src/main.cpp`
- [Rate Limiter](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/rate_limiter.hpp): `gateway/include/rate_limiter.hpp`
- [Token Bucket](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/token_bucket.hpp): `gateway/include/token_bucket.hpp`
- [PQC Manager](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/pqc_manager.cpp): `gateway/src/pqc_manager.cpp`
- [ZeroMQ Client](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/zmq_client.hpp): `gateway/include/zmq_client.hpp`
- [AI Decision Receiver](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/ai_decision_receiver.cpp): `gateway/src/ai_decision_receiver.cpp`
- [AI Enforcement State](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/ai_enforcement.cpp): `gateway/src/ai_enforcement.cpp`

### Threat Analysis

- [Security Analyzer](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/ai/security_engine.py): `ai/security_engine.py`
- [Gemini Classifier](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/ai/llm_classifier.py): `ai/llm_classifier.py`

### Backend Services

- [Backend API](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/backend/app.py): `backend/app.py`

### Monitoring

- [Request Metrics](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/security_metrics.hpp): `gateway/include/security_metrics.hpp`
- [Security Event Log](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/include/security_event_log.hpp): `gateway/include/security_event_log.hpp`
- [Telemetry Endpoints](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/gateway/src/main.cpp): `gateway/src/main.cpp`
- [Security Dashboard](https://github.com/mokshsharma2006/post-quantum-intelligent-api-gateway/blob/main/dashboard/index.html): `dashboard/index.html`

### Other components

- **API Client**
- **Google Gemini**

## Connections

- API Client → HTTP Gateway: sends requests (evidence: `README.md`)
- HTTP Gateway → AI Blocklist: checks client (evidence: `README.md`)
- HTTP Gateway → Payload Pre-filter: filters payload (evidence: `README.md`)
- HTTP Gateway → Request Sanitizer: sanitizes request (evidence: `gateway/src/main.cpp`)
- HTTP Gateway → ZeroMQ Client: sends event (evidence: `gateway/src/main.cpp`)
- ZeroMQ Client → Security Analyzer: sends metadata (evidence: `README.md`)
- Security Analyzer → Gemini Classifier: requests analysis (evidence: `ai/security_engine.py`)
- Gemini Classifier → Google Gemini: analyzes request (evidence: `ai/llm_classifier.py`)
- Security Analyzer → AI Decision Receiver: returns decisions (evidence: `README.md`)
- AI Decision Receiver → AI Enforcement State: records decisions (evidence: `gateway/src/ai_decision_receiver.cpp`)
- HTTP Gateway → Rate Limiter: checks request (evidence: `gateway/src/main.cpp`)
- Rate Limiter → Token Bucket: uses bucket (evidence: `gateway/include/rate_limiter.hpp`)
- HTTP Gateway → Backend API: proxies request (evidence: `README.md`)
- HTTP Gateway → PQC Manager: serves PQC endpoints (evidence: `gateway/src/main.cpp`)
- HTTP Gateway → Request Metrics: records traffic (evidence: `gateway/src/main.cpp`)
- HTTP Gateway → Security Event Log: records events (evidence: `gateway/src/main.cpp`)
- HTTP Gateway → Telemetry Endpoints: serves telemetry (evidence: `gateway/src/main.cpp`)
- Telemetry Endpoints → Security Dashboard: provides data (evidence: `README.md`)
