# osmanuygar/telveguard architecture

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

- Interactive diagram: https://gitdiagram.com/osmanuygar/telveguard
- Repository: https://github.com/osmanuygar/telveguard

## Overview

Telveguard is an on-premises security gateway for enterprise LLM use. Its primary workflow accepts compatible model requests, identifies the caller and destination, scans content and attachments, applies policy, then blocks, masks, or forwards the request; it protects the response before returning it. Audit and administration capabilities provide visibility and compliance reporting. The graph also includes the documented browser, coding-agent, and MCP integrations. Some gateway internals and extension wiring were not excerpted, so their undocumented links are omitted.

Main entry points: [`gateway/app/main.py`](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/main.py) (LLM proxy), [`packages/telveguard-core/telveguard_core/pii/engine.py`](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/pii/engine.py) (PII and secret scan), [`gateway/app/audit.py`](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/audit.py) (Audit events), [`gateway/app/xray.py`](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/xray.py) (AI usage X-ray)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gateway["Gateway protection"]
  node_gateway_api["LLM proxy<br/>[main.py]"]
  node_api_formats["API formats<br/>[formats.py]"]
  node_identity["Identity checks<br/>[auth.py]"]
  node_attachments["Attachment scanning<br/>[attachments.py]"]
  node_providers["Model providers<br/>[providers.py]"]
end

subgraph group_core["Detection and policy"]
  node_pii["PII and secret scan<br/>[engine.py]"]
  node_recognizers["Turkish recognizers<br/>[tr_recognizers.py]"]
  node_injection["Injection detection<br/>[injection.py]"]
  node_dictionary["Organization dictionary<br/>[dictionary.py]"]
  node_policy["Policy engine<br/>[policy.py]"]
end

subgraph group_visibility["Audit and compliance"]
  node_audit["Audit events<br/>[audit.py]"]
  node_clickhouse[("ClickHouse")]
  node_xray["AI usage X-ray<br/>[xray.py]"]
  node_compliance["Compliance reports<br/>[compliance.py]"]
  node_poc["POC reports<br/>[poc_report.py]"]
  node_subjects["Data subject requests<br/>[subjects.py]"]
end

subgraph group_integrations["User integrations"]
  node_extension["Shadow AI extension<br/>[content.js]"]
  node_extension_detectors["Browser detectors<br/>[detectors.js]"]
  node_agent_hooks["Coding-agent hooks<br/>[hooks.py]"]
  node_agent_client["Gateway client<br/>[client.py]"]
  node_mcp["ContextForge plugin<br/>[plugin.py]"]
end

subgraph group_operations["Operations"]
  node_metrics["Prometheus metrics<br/>[metrics.py]"]
  node_quota["Usage quotas<br/>[quota.py]"]
  node_notifications["Notifications<br/>[notify.py]"]
end

node_client(("LLM client"))
node_model(("Upstream model"))
node_browser(("User browser"))
node_agent_user(("Developer"))
node_mcp_host(("MCP host"))
node_admin(("Administrator"))
node_notification_service(("Slack / Teams / SIEM"))

node_client -->|"sends request"| node_gateway_api
node_gateway_api -->|"parses formats"| node_api_formats
node_gateway_api -->|"checks identity"| node_identity
node_gateway_api -->|"scans attachments"| node_attachments
node_gateway_api -->|"scans content"| node_pii
node_pii -->|"uses recognizers"| node_recognizers
node_gateway_api -->|"checks injection"| node_injection
node_gateway_api -.->|"checks terms"| node_dictionary
node_gateway_api -->|"evaluates policy"| node_policy
node_gateway_api -->|"selects provider"| node_providers
node_gateway_api -->|"forwards request"| node_model
node_model -->|"returns response"| node_gateway_api
node_gateway_api -->|"returns protected response"| node_client
node_gateway_api -->|"records event"| node_audit
node_audit -->|"writes events"| node_clickhouse
node_admin -->|"requests administration"| node_gateway_api
node_gateway_api -->|"serves usage data"| node_xray
node_xray -->|"queries events"| node_clickhouse
node_gateway_api -->|"serves compliance reports"| node_compliance
node_gateway_api -->|"serves POC report"| node_poc
node_gateway_api -->|"serves subject lookup"| node_subjects
node_gateway_api -->|"exposes metrics"| node_metrics
node_gateway_api -.->|"enforces quotas"| node_quota
node_gateway_api -.->|"triggers alerts"| node_notifications
node_notifications -->|"sends alerts"| node_notification_service
node_browser -->|"pastes content"| node_extension
node_extension -.->|"checks content"| node_extension_detectors
node_agent_user -->|"uses coding assistant"| node_agent_hooks
node_agent_hooks -->|"requests verdict"| node_agent_client
node_agent_client -->|"checks event"| node_gateway_api
node_mcp_host -->|"dispatches tools"| node_mcp
node_mcp -.->|"uses gateway protection"| node_gateway_api

click node_gateway_api "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/main.py"
click node_api_formats "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/formats.py"
click node_identity "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/auth.py"
click node_attachments "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/attachments.py"
click node_providers "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/providers.py"
click node_pii "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/pii/engine.py"
click node_recognizers "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/pii/tr_recognizers.py"
click node_injection "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/detectors/injection.py"
click node_dictionary "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/dictionary.py"
click node_policy "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/policy.py"
click node_audit "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/audit.py"
click node_xray "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/xray.py"
click node_compliance "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/compliance.py"
click node_poc "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/poc_report.py"
click node_subjects "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/subjects.py"
click node_metrics "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/metrics.py"
click node_quota "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/quota.py"
click node_notifications "https://github.com/osmanuygar/telveguard/blob/main/gateway/app/notify.py"
click node_extension "https://github.com/osmanuygar/telveguard/blob/main/extension/src/content.js"
click node_extension_detectors "https://github.com/osmanuygar/telveguard/blob/main/extension/src/detectors.js"
click node_agent_hooks "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-agent/telveguard_agent/hooks.py"
click node_agent_client "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-agent/telveguard_agent/client.py"
click node_mcp "https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-contextforge/telveguard_contextforge/plugin.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_api,node_api_formats,node_identity,node_attachments,node_providers,node_client,node_browser toneBlue
class node_pii,node_recognizers,node_injection,node_dictionary,node_policy toneAmber
class node_audit,node_clickhouse,node_xray,node_compliance,node_poc,node_subjects toneMint
class node_extension,node_extension_detectors,node_agent_hooks,node_agent_client,node_mcp toneRose
class node_metrics,node_quota,node_notifications,node_model,node_agent_user,node_mcp_host,node_admin,node_notification_service toneIndigo
```

## Components

### Gateway protection

- [LLM proxy](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/main.py): `gateway/app/main.py`
- [API formats](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/formats.py): `gateway/app/formats.py`
- [Identity checks](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/auth.py): `gateway/app/auth.py`
- [Attachment scanning](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/attachments.py): `gateway/app/attachments.py`
- [Model providers](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/providers.py): `gateway/app/providers.py`

### Detection and policy

- [PII and secret scan](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/pii/engine.py): `packages/telveguard-core/telveguard_core/pii/engine.py`
- [Turkish recognizers](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/pii/tr_recognizers.py): `packages/telveguard-core/telveguard_core/pii/tr_recognizers.py`
- [Injection detection](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/detectors/injection.py): `packages/telveguard-core/telveguard_core/detectors/injection.py`
- [Organization dictionary](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/dictionary.py): `gateway/app/dictionary.py`
- [Policy engine](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-core/telveguard_core/policy.py): `packages/telveguard-core/telveguard_core/policy.py`

### Audit and compliance

- [Audit events](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/audit.py): `gateway/app/audit.py`
- **ClickHouse**
- [AI usage X-ray](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/xray.py): `gateway/app/xray.py`
- [Compliance reports](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/compliance.py): `gateway/app/compliance.py`
- [POC reports](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/poc_report.py): `gateway/app/poc_report.py`
- [Data subject requests](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/subjects.py): `gateway/app/subjects.py`

### User integrations

- [Shadow AI extension](https://github.com/osmanuygar/telveguard/blob/main/extension/src/content.js): `extension/src/content.js`
- [Browser detectors](https://github.com/osmanuygar/telveguard/blob/main/extension/src/detectors.js): `extension/src/detectors.js`
- [Coding-agent hooks](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-agent/telveguard_agent/hooks.py): `packages/telveguard-agent/telveguard_agent/hooks.py`
- [Gateway client](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-agent/telveguard_agent/client.py): `packages/telveguard-agent/telveguard_agent/client.py`
- [ContextForge plugin](https://github.com/osmanuygar/telveguard/blob/main/packages/telveguard-contextforge/telveguard_contextforge/plugin.py): `packages/telveguard-contextforge/telveguard_contextforge/plugin.py`

### Operations

- [Prometheus metrics](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/metrics.py): `gateway/app/metrics.py`
- [Usage quotas](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/quota.py): `gateway/app/quota.py`
- [Notifications](https://github.com/osmanuygar/telveguard/blob/main/gateway/app/notify.py): `gateway/app/notify.py`

### Other components

- **LLM client**
- **Upstream model**
- **User browser**
- **Developer**
- **MCP host**
- **Administrator**
- **Slack / Teams / SIEM**

## Connections

- LLM client → LLM proxy: sends request (evidence: `README.md`)
- LLM proxy → API formats: parses formats (evidence: `gateway/app/main.py`)
- LLM proxy → Identity checks: checks identity (evidence: `README.md`)
- LLM proxy → Attachment scanning: scans attachments (evidence: `gateway/app/main.py`)
- LLM proxy → PII and secret scan: scans content (evidence: `README.md`)
- PII and secret scan → Turkish recognizers: uses recognizers (evidence: `packages/telveguard-core/telveguard_core/pii/engine.py`)
- LLM proxy → Injection detection: checks injection (evidence: `README.md`)
- LLM proxy → Organization dictionary: checks terms (evidence: `gateway/app/main.py`)
- LLM proxy → Policy engine: evaluates policy (evidence: `README.md`)
- LLM proxy → Model providers: selects provider (evidence: `README.md`)
- LLM proxy → Upstream model: forwards request (evidence: `README.md`)
- Upstream model → LLM proxy: returns response (evidence: `README.md`)
- LLM proxy → LLM client: returns protected response (evidence: `README.md`)
- LLM proxy → Audit events: records event (evidence: `gateway/app/main.py`)
- Audit events → ClickHouse: writes events (evidence: `README.md`)
- Administrator → LLM proxy: requests administration (evidence: `gateway/app/main.py`)
- LLM proxy → AI usage X-ray: serves usage data (evidence: `gateway/app/main.py`)
- AI usage X-ray → ClickHouse: queries events (evidence: `gateway/app/xray.py`)
- LLM proxy → Compliance reports: serves compliance reports (evidence: `gateway/app/main.py`)
- LLM proxy → POC reports: serves POC report (evidence: `gateway/app/main.py`)
- LLM proxy → Data subject requests: serves subject lookup (evidence: `README.md`)
- LLM proxy → Prometheus metrics: exposes metrics (evidence: `gateway/app/main.py`)
- LLM proxy → Usage quotas: enforces quotas (evidence: `gateway/app/main.py`)
- LLM proxy → Notifications: triggers alerts (evidence: `gateway/app/main.py`)
- Notifications → Slack / Teams / SIEM: sends alerts (evidence: `README.md`)
- User browser → Shadow AI extension: pastes content (evidence: `README.md`)
- Shadow AI extension → Browser detectors: checks content
- Developer → Coding-agent hooks: uses coding assistant (evidence: `README.md`)
- Coding-agent hooks → Gateway client: requests verdict (evidence: `packages/telveguard-agent/telveguard_agent/hooks.py`)
- Gateway client → LLM proxy: checks event (evidence: `README.md`)
- MCP host → ContextForge plugin: dispatches tools (evidence: `README.md`)
- ContextForge plugin → LLM proxy: uses gateway protection
