CASE STUDY · HYBRID AI ARCHITECTURE

Client & Ecosystem
Aroon AI · AWS ap-south-1
Services Provided
Systems Architecture & Full-Stack AI
Technology Core
FastAPI · Redis 7 · llama.cpp
Inference Host
Ubuntu ThinkPad (0 Open Ports)
< 25ms
P95 Gateway Routing Overhead

FastAPI on EC2 ARM64 with Caddy reverse proxy and atomic Redis token validation.

100%
On-Premises Data Sovereignty

Sensitive client prompts and responses are computed strictly on private local hardware.

0 Ports
Zero Open Inbound Attack Surface

Private Ubuntu ThinkPad server operates over outbound Cloudflare Tunnel sockets.

01 / The Challenge

Eliminating the Dilemma Between Cloud Invoices and Local Chaos

Running a local open-weights LLM is straightforward. Engineering an enterprise-grade developer gateway around that model — with zero data leakage, sub-25ms routing, and multi-tenant rate limiting — is the true systems challenge.

Public SaaS API Trap

Convenient setup, but recurring per-token SaaS subscriptions scale uncontrollably as concurrency grows, while sensitive internal data is perpetually transmitted across third-party infrastructure.

Unmetered Local Engine Chaos

Raw inference engines (Ollama, vLLM) lack developer portals, API key generation, SHA-256 validation, sliding-window rate limiters, and audit logging — crashing easily under concurrent production load.

02 / Systems Architecture

Three Strictly Decoupled Production Tiers

Engineered for strict separation of concerns between public identity management and secure private model computation:

TIER 01 · CLOUD INTERFACE

Developer Web Dashboard

Hosted on AWS Amplify with global CloudFront CDN edge distribution. Features Next.js 15 App Router, Google OAuth 2.0, API key generation, and real-time usage telemetry charts.

FrameworkNext.js 15 · React 19
HostingAWS Amplify + CloudFront
Domaindashboard.aroonkumar.me
TIER 02 · GATEWAY INGRESS

High-Throughput Gateway

Dockerized FastAPI container running on AWS EC2 ARM64 with Caddy reverse proxy. Enforces cryptographic SHA-256 API key verification, atomic Redis sliding-window quotas, and monthly token limits.

Gateway EngineFastAPI + Caddy Proxy
Cache & ThrottlingRedis 7 (Sliding Window)
Persistent StatePostgreSQL 15 (28 Tables)
TIER 03 · PRIVATE COMPUTATION

Edge Inference Engine

Physical Linux server operating on a dedicated Ubuntu ThinkPad. Multi-threaded AVX2 CPU inference via llama.cpp server, exposed strictly through an outbound Cloudflare Tunnel with zero open inbound ports.

HardwareLenovo ThinkPad (Ubuntu)
Runtimellama.cpp (AVX2 CPU)
Attack Surface0 Open Inbound Ports
03 / Verified Technology Stack

Production Engineering Tooling

Every tool in the stack was selected for sub-second execution, strict zero-trust security, and zero cloud subscription invoices:

Frontend Architecture

Next.js 15.1

App Router · React 19 · Server Actions

Hosted on AWS Amplify with CloudFront edge caching, powering dashboard.aroonkumar.me.

Gateway Ingress

FastAPI

Python 3.11 · 4 Uvicorn Workers

High-throughput async gateway on AWS EC2 ARM64 handling /v1/chat/completions and SSE streams.

Cloud Infrastructure

AWS EC2 & Amplify

ARM64 Graviton · ap-south-1

Dockerized container deployment with CI/CD pipeline, ECR registry, and global Amplify hosting.

Zero-Trust Ingress

Cloudflare Tunnel

HTTP/2 Tunnel · TLS 1.3 Termination

Persistent outbound multiplexed tunnel from ThinkPad to Edge with zero open public router ports.

Inference Engine

llama.cpp

AVX2 CPU · Qwen2.5-1.5B (GGUF)

Multi-threaded C++ inference server running locally on Ubuntu ThinkPad with real-time SSE chunks.

Relational Persistence

PostgreSQL 15

28 Models · 14 Migrations

Stores users, Argon2id passwords, SHA-256 API key hashes, quotas, and granular token telemetry.

Rate Limiting & Cache

Redis 7 In-Memory

Sliding Window · Lua Scripts

Atomic per-developer token rate limiting (10 req/min) to prevent inference hardware thrashing.

On-Premises Host

Ubuntu Linux

Lenovo ThinkPad · systemd

Physical dedicated edge server with UFW firewall, memory/swap tuning, and managed services.

Containerization

Docker Container

ECR ARM64 Image · Linux

Hermetic container bundling FastAPI and dependencies for predictable, reproducible cloud hosting.

Backend Language

Python 3.11

AsyncIO · typing · pydantic

Core runtime executing gateway logic, request validation, cryptographic hashing, and DB pooling.

Type Safety

TypeScript

Strict Mode · ESLint 9

Guarantees end-to-end type safety across the entire dashboard portal, API models, and UI state.

Edge Reverse Proxy

Caddy Server

Automatic TLS · Keep-Alive Pools

Reverse proxy on EC2 handling HTTP/2 TLS handshake, upstream routing, and connection buffering.

04 / Production Blueprint

Verified Production Topology Blueprint

Inspect the complete 2,400px architecture diagram covering AWS Cloud, Cloudflare Edge, and On-Premises ThinkPad inference:

Aroon AI Platform Production Topology Diagram
Click to Zoom & Pan Full Diagram
05 / Developer Experience

Interactive Code Workbench

Drop-in compatibility with the official OpenAI SDK, pure Python urllib, Node.js fetch, and terminal cURL:

EC2 ARM64 · 200 OK
# 1. Python (Official OpenAI SDK — Drop-in Base URL)
from openai import OpenAI

# ⚠️ Point base_url to Aroon AI Gateway (Zero data leaves private host)
client = OpenAI(
    api_key="aroon_sk_YOUR_API_KEY",
    base_url="https://api.aroonkumar.me/v1",
)

# Streaming Completion (Real-time Word-by-Word SSE Generation)
stream = client.chat.completions.create(
    model="aroonai-3.1-pro",
    messages=[
        {"role": "system", "content": "You are a concise, helpful engineering assistant."},
        {"role": "user", "content": "Explain hybrid cloud AI gateway architecture."}
    ],
    stream=True,
    temperature=0.7,
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
print()
Automated Test Suite
8 / 8 Checks PASS
Validated via automated test harness
Active LLM Runtime
aroonai-3.1-pro
Qwen2.5-1.5B-Instruct-GGUF · llama.cpp
Security & Ingress
0 Open Inbound Ports
Encrypted Cloudflare tunnel socket
06 / Execution Flow

10-Step End-to-End Request Journey

Click any step to trace the journey of an AI chat completion from client dispatch to streamed tokens:

STEP 01HTTPS · TLS 1.3

Client Bearer Request

Client sends HTTP POST to /v1/chat/completions with Bearer aroon_sk_... API key.

STEP 02Cloudflare Edge

Cloudflare Edge Defense

Cloudflare terminates TLS, handles DDoS scrubbing, and enforces edge WAF inspection.

STEP 03PostgreSQL 15

Cryptographic SHA-256 Auth

FastAPI gateway computes SHA-256 hash of API key and performs single-query Postgres lookup.

STEP 04Redis 7 In-Memory

Atomic Redis Rate Limiting

Atomic Redis Lua scripts verify sliding-window quota (10 req/min) to prevent CPU queue thrashing.

STEP 05Quota Enforcer

Monthly Token Quota Check

Gateway checks developer prompt + completion token consumption against monthly tier cap.

STEP 06Zero Open Ports

Outbound Tunnel Dispatch

Request proxied over persistent outbound HTTP/2 Cloudflare Tunnel with zero open router ports.

STEP 07Ubuntu Server

Local Host Ingress (:8080)

Local cloudflared daemon receives packet and forwards strictly to http://127.0.0.1:8080.

STEP 08llama.cpp

AVX2 CPU Engine Inference

llama.cpp server executes quantized Qwen2.5-1.5B weights using multi-threaded AVX2 instructions.

STEP 09Audit Trail

Database Telemetry Logging

Latency (ms), prompt tokens, completion tokens, and client IP asynchronously logged to PostgreSQL.

STEP 10Live SSE Stream

Real-time SSE Streaming

Client receives token-by-token Server-Sent Events (SSE) with standard [DONE] termination flag.

PRODUCTION BLUEPRINT READY
100% Sovereign On-Premises

Want to deploy private, sovereign AI infrastructure?

We design and deploy self-hosted developer gateways with OpenAI SDK drop-in compatibility, zero cloud token bills, and complete on-premises data sovereignty.

Back to All Selected Work