System Architecture
TruePortAI is a Defensible AI Gateway — an enterprise-grade, multi-tenant platform that sits between your applications and commercial LLM providers. It provides real-time governance, complete audit trails, ML-powered violation detection, and full data sovereignty.
C4 Level 1 — Context Diagram
C4 Level 2 — Container Diagram
Solution Repositories
Repository |
Technology |
Deployment |
Responsibility |
|---|---|---|---|
|
Python 3.11 · FastAPI · Uvicorn |
AWS Lambda (Zappa) |
Auth, RBAC, Billing, Mail, Config |
|
Python 3.11 · FastAPI · Uvicorn |
AWS Lambda (Zappa) |
AI Gateway Proxy, Key Mgmt, Usage Analytics API |
|
Python 3.11 · HuggingFace · Triton |
On-Premise / VPC GPU Node |
ML violation detection pipeline |
|
Angular 17+ |
AWS S3 + CloudFront |
AI Governance dashboard (SPA) |
|
Angular 17+ |
AWS S3 + CloudFront |
Platform admin dashboard (SPA) |
|
Next.js 14+ |
AWS S3 + CloudFront (Static Export) |
Public website + this documentation |
Implementation Stack
Layer |
Technology |
Purpose |
|---|---|---|
API Runtime |
Python 3.11 + FastAPI + Uvicorn |
Async REST APIs |
ASGI → Lambda |
Mangum (AWS Lambda adapter) |
Serverless hosting |
ODM (Async) |
Motor + Beanie |
MongoDB async driver |
Password Hashing |
Argon2-cffi |
Credential security |
Token Auth |
python-jose (HS256 JWT) |
Session management |
Proxy HTTP |
httpx (async) |
Upstream LLM forwarding |
Rate Limiting |
Redis (fixed-window) |
Per-key throttling |
Circuit Breaker |
Redis (state machine) |
Provider resilience |
Frontend |
Angular 17 + TailwindCSS |
Platform dashboards |
Public Site |
Next.js 14 + TailwindCSS |
Marketing + docs |
Database |
MongoDB Atlas (M10+) |
Operational data |
Storage |
AWS S3 / Azure Blob |
Audit log archive |
CDN |
AWS CloudFront |
Global edge delivery |
ML Inference |
NVIDIA Triton Inference Server |
GPU-accelerated models |
ML Models |
HuggingFace Transformers |
RoBERTa, DeBERTa, DistilBERT |
Key Workflows
1. AI Request Flow
2. Violation Detection Pipeline
3. Authentication & Tenant Selection Flow
Multi-Tenancy Architecture
TruePortAI uses a logical multi-tenancy model: all tenants share the same database cluster but are isolated via tenant_id fields and middleware-enforced scoping.
Tenant context resolution priority:
JWT
tidclaim (production flows)HTTP subdomain (e.g.,
acme.trueportai.com)X-Tenant-Slugheader (local/dev override)
Security Architecture
Reliability Patterns
Circuit Breaker State Machine
Provider Failover Strategy
Primary Provider → [Circuit Breaker] → Secondary Provider → [Circuit Breaker] → Error Response
Each provider has an independent circuit breaker key in Redis:
circuit_breaker:openai:statecircuit_breaker:anthropic:statecircuit_breaker:google:statecircuit_breaker:azure:state
Rate Limiting Algorithm
Fixed Window per API key per minute:
Redis Key: rate_limit:{api_key}:{YYYY-MM-DD-HH-MM}
Redis Ops: INCR → if count > limit → 429; else EXPIRE 60s