# occludra/gateway architecture

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

- Interactive diagram: https://gitdiagram.com/occludra/gateway
- Repository: https://github.com/occludra/gateway

## Overview

Occludra is a self-hosted AI security gateway with a Python SDK. An application sends an OpenAI-compatible chat request; the gateway authenticates it, resolves provider/model settings, scans messages for sensitive data and injection patterns, then blocks or redacts before forwarding to an LLM provider. The README documents the Presidio service as the gateway’s PII scanning backend. The graph focuses on these self-hosted runtime capabilities; managed-cloud features are documented but not represented in this repository tree. Some internal DLP and response details are unsampled, so their connections are limited to documented relationships.

Main entry points: [`proxy-api/app/routers/proxy.py`](https://github.com/occludra/gateway/blob/main/proxy-api/app/routers/proxy.py) (Chat Handler), [`proxy-api/app/main.py`](https://github.com/occludra/gateway/blob/main/proxy-api/app/main.py) (Gateway App), [`presidio/app/main.py`](https://github.com/occludra/gateway/blob/main/presidio/app/main.py) (Presidio Service), [`sdk/python/aisg/client.py`](https://github.com/occludra/gateway/blob/main/sdk/python/aisg/client.py) (SDK Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway API"]
  node_gateway_app["Gateway App<br/>[main.py]"]
  node_proxy_handler["Chat Handler<br/>[proxy.py]"]
  node_auth["API Key Auth<br/>[auth.py]"]
  node_gateway_config["Gateway Config<br/>[config.py]"]
  node_request_models["API Models<br/>[models.py]"]
  node_health["Health Route<br/>[health.py]"]
  node_request_logs["Request Logging<br/>[log_utils.py]"]
end

subgraph group_safety["Safety Scanning"]
  node_dlp["DLP Client<br/>[dlp.py]"]
  node_presidio_api["Presidio Service<br/>[main.py]"]
  node_recognizers["Custom Recognizers<br/>[recognizers.py]"]
  node_presidio_models["Scan Models<br/>[models.py]"]
  node_post_processor["Anonymization<br/>[post_processor.py]"]
end

subgraph group_upstream["Provider Routing"]
  node_provider_router["Provider Routing<br/>[providers.py]"]
  node_llm_provider["LLM Provider"]
end

subgraph group_sdk["Python SDK"]
  node_sdk_client["SDK Client<br/>[client.py]"]
  node_sdk_models["Typed Responses<br/>[models.py]"]
  node_sdk_errors["SDK Errors<br/>[exceptions.py]"]
end

node_application(("Client Application"))

node_application -->|"sends requests"| node_gateway_app
node_gateway_app -->|"routes requests"| node_proxy_handler
node_gateway_app -->|"registers route"| node_health
node_gateway_app -->|"configures logging"| node_request_logs
node_proxy_handler -->|"authenticates"| node_auth
node_proxy_handler -->|"loads settings"| node_gateway_config
node_proxy_handler -->|"validates request"| node_request_models
node_proxy_handler -->|"scans messages"| node_dlp
node_dlp -->|"requests scan"| node_presidio_api
node_presidio_api -->|"builds analyzer"| node_recognizers
node_presidio_api -->|"uses scan models"| node_presidio_models
node_presidio_api -->|"uses anonymizer"| node_post_processor
node_proxy_handler -->|"forwards completion"| node_provider_router
node_provider_router -->|"calls upstream"| node_llm_provider
node_application -.->|"uses SDK"| node_sdk_client
node_sdk_client -->|"calls API"| node_gateway_app
node_sdk_client -->|"parses responses"| node_sdk_models
node_sdk_client -->|"raises errors"| node_sdk_errors

click node_gateway_app "https://github.com/occludra/gateway/blob/main/proxy-api/app/main.py"
click node_proxy_handler "https://github.com/occludra/gateway/blob/main/proxy-api/app/routers/proxy.py"
click node_auth "https://github.com/occludra/gateway/blob/main/proxy-api/app/auth.py"
click node_gateway_config "https://github.com/occludra/gateway/blob/main/proxy-api/app/config.py"
click node_request_models "https://github.com/occludra/gateway/blob/main/proxy-api/app/models.py"
click node_health "https://github.com/occludra/gateway/blob/main/proxy-api/app/routers/health.py"
click node_request_logs "https://github.com/occludra/gateway/blob/main/proxy-api/app/log_utils.py"
click node_dlp "https://github.com/occludra/gateway/blob/main/proxy-api/app/dlp.py"
click node_presidio_api "https://github.com/occludra/gateway/blob/main/presidio/app/main.py"
click node_recognizers "https://github.com/occludra/gateway/blob/main/presidio/app/recognizers.py"
click node_presidio_models "https://github.com/occludra/gateway/blob/main/presidio/app/models.py"
click node_post_processor "https://github.com/occludra/gateway/blob/main/presidio/app/post_processor.py"
click node_provider_router "https://github.com/occludra/gateway/blob/main/proxy-api/app/providers.py"
click node_sdk_client "https://github.com/occludra/gateway/blob/main/sdk/python/aisg/client.py"
click node_sdk_models "https://github.com/occludra/gateway/blob/main/sdk/python/aisg/models.py"
click node_sdk_errors "https://github.com/occludra/gateway/blob/main/sdk/python/aisg/exceptions.py"

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_app,node_proxy_handler,node_auth,node_gateway_config,node_request_models,node_health,node_request_logs,node_application toneBlue
class node_dlp,node_presidio_api,node_recognizers,node_presidio_models,node_post_processor toneAmber
class node_provider_router,node_llm_provider toneMint
class node_sdk_client,node_sdk_models,node_sdk_errors toneRose
```

## Components

### Gateway API

- [Gateway App](https://github.com/occludra/gateway/blob/main/proxy-api/app/main.py): `proxy-api/app/main.py`
- [Chat Handler](https://github.com/occludra/gateway/blob/main/proxy-api/app/routers/proxy.py): `proxy-api/app/routers/proxy.py`
- [API Key Auth](https://github.com/occludra/gateway/blob/main/proxy-api/app/auth.py): `proxy-api/app/auth.py`
- [Gateway Config](https://github.com/occludra/gateway/blob/main/proxy-api/app/config.py): `proxy-api/app/config.py`
- [API Models](https://github.com/occludra/gateway/blob/main/proxy-api/app/models.py): `proxy-api/app/models.py`
- [Health Route](https://github.com/occludra/gateway/blob/main/proxy-api/app/routers/health.py): `proxy-api/app/routers/health.py`
- [Request Logging](https://github.com/occludra/gateway/blob/main/proxy-api/app/log_utils.py): `proxy-api/app/log_utils.py`

### Safety Scanning

- [DLP Client](https://github.com/occludra/gateway/blob/main/proxy-api/app/dlp.py): `proxy-api/app/dlp.py`
- [Presidio Service](https://github.com/occludra/gateway/blob/main/presidio/app/main.py): `presidio/app/main.py`
- [Custom Recognizers](https://github.com/occludra/gateway/blob/main/presidio/app/recognizers.py): `presidio/app/recognizers.py`
- [Scan Models](https://github.com/occludra/gateway/blob/main/presidio/app/models.py): `presidio/app/models.py`
- [Anonymization](https://github.com/occludra/gateway/blob/main/presidio/app/post_processor.py): `presidio/app/post_processor.py`

### Provider Routing

- [Provider Routing](https://github.com/occludra/gateway/blob/main/proxy-api/app/providers.py): `proxy-api/app/providers.py`
- **LLM Provider**

### Python SDK

- [SDK Client](https://github.com/occludra/gateway/blob/main/sdk/python/aisg/client.py): `sdk/python/aisg/client.py`
- [Typed Responses](https://github.com/occludra/gateway/blob/main/sdk/python/aisg/models.py): `sdk/python/aisg/models.py`
- [SDK Errors](https://github.com/occludra/gateway/blob/main/sdk/python/aisg/exceptions.py): `sdk/python/aisg/exceptions.py`

### Other components

- **Client Application**

## Connections

- Client Application → Gateway App: sends requests (evidence: `README.md`)
- Gateway App → Chat Handler: routes requests (evidence: `proxy-api/app/main.py`)
- Gateway App → Health Route: registers route (evidence: `proxy-api/app/main.py`)
- Gateway App → Request Logging: configures logging (evidence: `proxy-api/app/main.py`)
- Chat Handler → API Key Auth: authenticates (evidence: `proxy-api/app/routers/proxy.py`)
- Chat Handler → Gateway Config: loads settings (evidence: `proxy-api/app/routers/proxy.py`)
- Chat Handler → API Models: validates request (evidence: `proxy-api/app/routers/proxy.py`)
- Chat Handler → DLP Client: scans messages (evidence: `proxy-api/app/routers/proxy.py`)
- DLP Client → Presidio Service: requests scan (evidence: `README.md`)
- Presidio Service → Custom Recognizers: builds analyzer (evidence: `presidio/app/main.py`)
- Presidio Service → Scan Models: uses scan models (evidence: `presidio/app/main.py`)
- Presidio Service → Anonymization: uses anonymizer (evidence: `presidio/app/main.py`)
- Chat Handler → Provider Routing: forwards completion (evidence: `proxy-api/app/routers/proxy.py`)
- Provider Routing → LLM Provider: calls upstream (evidence: `README.md`)
- Client Application → SDK Client: uses SDK (evidence: `README.md`)
- SDK Client → Gateway App: calls API (evidence: `README.md`)
- SDK Client → Typed Responses: parses responses (evidence: `sdk/python/aisg/client.py`)
- SDK Client → SDK Errors: raises errors (evidence: `sdk/python/aisg/client.py`)
