VICE//DEV
BACK TO ALL MISSIONSSTACK: FastAPI · React 19 · SQLAlchemy · PostgreSQL · Docker Compose
AI Privacy Gateway dashboard screenshot showing policy modes, detected PII categories, and sanitized audit logs
CASE STUDY BRIEF // MISSION 01⚡ FUNCTIONAL · 18/18 PASS

AI PRIVACY GATEWAY — ARCHITECTURE & EVIDENCE BRIEF

REQUEST PROCESSING PIPELINE (POST /v1/chat/completions)

  1. 1. CLIENT APPOpenAI SDK / cURL
  2. 2. AUTH + RATESHA-256 + Sliding Window
  3. 3. PII + POLICYNIK / NPWP / 5 Modes
  4. 4. EPHEMERAL VAULTRequest-Scoped Map
  5. 5. PROVIDER + AUDITOllama / OpenAI / Mock

01 // PROBLEM

Teams sending prompts to external LLM APIs risk leaking customer PII, Indonesian NIK/NPWP numbers, credit cards, and secret tokens. Existing cloud DLP proxies force teams to trust another third-party SaaS.

02 // SOLUTION

Built a self-hostable OpenAI-compatible FastAPI proxy and React 19 management console intercepting POST /v1/chat/completions with 5 policy modes (Redact, Block, Allow, Redact & Restore, Strict Privacy).

03 // TECHNICAL ARCHITECTURE

FastAPI middleware handles constant-time SHA-256 API key auth, sliding-window rate limits, and payload bounds before routing through deterministic PII recognizers, an ephemeral request-scoped restoration map, provider adapters (OpenAI-compatible, local Ollama, offline Mock), and sanitized SQLAlchemy audit records.

04 // INDIVIDUAL CONTRIBUTIONS

Independently developed with AI coding-agent assistance; Daniel authored architecture boundaries, Indonesian NIK/NPWP recognizer rules, policy enforcement flow, and test harnesses.

05 // DESIGN DECISIONS

Kept the restoration mapping strictly in memory per request rather than persisting raw PII tokens to PostgreSQL/SQLite, ensuring audit logs record entity categories and timing without storing original secrets.

06 // SECURITY CONSIDERATIONS & CAVEATS

Implemented constant-time SHA-256 API key lookup and private-IP/loopback/metadata SSRF checks on provider URLs. Technical caveats: request-time DNS rebinding defense is not present in the URL validator, and default Compose secrets are intended for local development only.

07 // TEST EVIDENCE

Verified 18 backend pytest cases (test_ssrf_and_api.py, redaction, health/readiness, mock chat) and frontend npm run build (npm run lint completed with 6 warnings). Not yet deployed to a live production cluster.

08 // CHALLENGES & TRADE-OFFS

Deterministic regex/checksum recognizers (Luhn, 16-digit NIK date/province checks) deliver predictable low-latency masking without extra LLM calls, trading off contextual NER recall on unstructured prose.

09 // REPOSITORY: https://github.com/0xyz-exe/ai-privacy-gateway · APACHE 2.0