Docs/Platform/Architecture

Architecture

A deep-dive into the GovernanceAI microservices topology, request lifecycle, and deployment model.

Advanced7 min readUpdated June 2026
GatewayPolicyRiskDLPAudit

GovernanceAI is built as a collection of focused microservices. Each service has a single responsibility and is independently deployable. The API gateway is the only component exposed to the public internet.

Request lifecycle

Every request passes through the following stages. All enforcement steps run in parallel after the gateway receives the request — there is no waterfall.

API Gateway :8000
Policy Engine
Risk Scorer
DLP Scanner
│ merge decisions │
ALLOW → Model
BLOCK → Reject
WARN → Allow + Log
Parallel evaluation architecture — policy, risk, and DLP run concurrently, not sequentially

Services

API Gateway

FastAPI application on port 8000. Responsible for authentication, rate limiting, request validation, and orchestrating parallel enforcement calls. The gateway is stateless — all state lives in Redis and PostgreSQL.

Policy Engine

Evaluates the request against the active security profile rules: RBAC permissions, topic allow/block lists, custom regex, and time-based restrictions. Returns a policy_decision of allow, block, or warn.

Risk Scorer

ML-based classifier that scores the prompt across five risk dimensions: prompt injection, jailbreak attempt, toxicity, PII exposure, and competitive intelligence. Returns a composite risk_score between 0.0 and 1.0.

DLP Scanner

Regex-based data loss prevention scanner with 30+ built-in patterns. Detects API keys, private keys, credit card numbers, SSNs, email addresses, and custom patterns. Can redact or block on match.

Decision Engine

Merges the three parallel decisions into a single final verdict using configurable priority rules. Policy blocks always override risk warnings. High risk scores can escalate warn to block.

Data layer

PostgreSQL stores organizations, projects, API keys, security profiles, and audit records. All writes are atomic and include soft deletes.

Redis stores rate limit counters, session cache, and hot configuration (security profiles are cached for 30 seconds to avoid database reads on every request).

No data sent to modelsGovernanceAI evaluates prompts locally before forwarding. If a request is blocked, the prompt is never sent to the LLM provider. Only allowed requests are forwarded.

Multi-tenancy

Every database row carries an org_id. Row-level security policies in PostgreSQL enforce tenant isolation. API keys are scoped to a single project within a single organization — cross-tenant access is architecturally impossible.

Related documentation