# sarvajithsankar/tenet-ai architecture

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

- Interactive diagram: https://gitdiagram.com/sarvajithsankar/tenet-ai
- Repository: https://github.com/sarvajithsankar/tenet-ai

## Overview

TENET AI is defensive middleware for LLM applications: a plugin submits prompts for security analysis, after which requests can be blocked, sanitized, flagged, or allowed and activity is exposed to a SOC dashboard. The README documents heuristic, ML, and behavioral detection, policy actions, Redis event queuing, and analyst feedback; sampled service code confirms ingestion, analyzer endpoints, Redis-backed event handling, tenant security, and dashboard API reads. Behavioral analysis, policy handling, and feedback are documented capabilities, but their implementation was not sampled.

Main entry points: [`services/analyzer/app.py`](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/app.py) (Analyzer API), [`services/ingest/app.py`](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/ingest/app.py) (Ingest API), [`dashboard/src/App.tsx`](https://github.com/sarvajithsankar/tenet-ai/blob/main/dashboard/src/App.tsx) (Dashboard App), [`tenet_plugin/client.py`](https://github.com/sarvajithsankar/tenet-ai/blob/main/tenet_plugin/client.py) (Security Plugin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["LLM Integration"]
  node_plugin["Security Plugin<br/>[client.py]"]
  node_ingest["Ingest API<br/>[app.py]"]
end

subgraph group_detection["Detection Services"]
  node_analyzer["Analyzer API<br/>[app.py]"]
  node_heuristics["Heuristic Detection<br/>[app.py]"]
  node_mlmodel["Phishing Model<br/>[phishing_model.py]"]
  node_behavior["Behavioral Analysis"]
  node_policy["Policy Actions"]
end

subgraph group_operations["Security Operations"]
  node_tenant["Tenant Security<br/>[tenant_security.py]"]
  node_eventstore["Redis Event Queue<br/>[app.py]"]
  node_metrics["Prometheus Metrics<br/>[metrics.py]"]
end

subgraph group_dashboard["SOC Dashboard"]
  node_dashboard["Dashboard App<br/>[App.tsx]"]
  node_aggregation["Chart Aggregations"]
  node_charts["SOC Charts"]
end

node_application(("LLM Application"))
node_llm["LLM Provider"]
node_analyst(("Security Analyst"))

node_application -->|"secures calls"| node_plugin
node_plugin -->|"submits prompts"| node_ingest
node_ingest -->|"authenticates tenants"| node_tenant
node_ingest -->|"requests analysis"| node_analyzer
node_analyzer -->|"checks patterns"| node_heuristics
node_analyzer -.->|"scores prompts"| node_mlmodel
node_analyzer -.->|"analyzes behavior"| node_behavior
node_analyzer -.->|"selects actions"| node_policy
node_policy -->|"forwards allowed"| node_llm
node_ingest -->|"stores events"| node_eventstore
node_analyzer -->|"updates events"| node_eventstore
node_ingest -->|"records requests"| node_metrics
node_analyzer -->|"records requests"| node_metrics
node_dashboard -->|"fetches events"| node_ingest
node_dashboard -->|"checks health"| node_analyzer
node_dashboard -->|"aggregates events"| node_aggregation
node_aggregation -.->|"provides chart data"| node_charts
node_analyst -->|"reviews alerts"| node_dashboard
node_analyst -.->|"provides feedback"| node_behavior

click node_plugin "https://github.com/sarvajithsankar/tenet-ai/blob/main/tenet_plugin/client.py"
click node_ingest "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/ingest/app.py"
click node_tenant "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/security/tenant_security.py"
click node_analyzer "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/app.py"
click node_heuristics "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/app.py"
click node_mlmodel "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/model/phishing_model.py"
click node_behavior "https://github.com/sarvajithsankar/tenet-ai/tree/main/services/analyzer"
click node_policy "https://github.com/sarvajithsankar/tenet-ai/tree/main/services"
click node_eventstore "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/ingest/app.py"
click node_metrics "https://github.com/sarvajithsankar/tenet-ai/blob/main/services/utils/metrics.py"
click node_dashboard "https://github.com/sarvajithsankar/tenet-ai/blob/main/dashboard/src/App.tsx"
click node_aggregation "https://github.com/sarvajithsankar/tenet-ai/blob/main/dashboard/src/utils/chartAggregations.ts"
click node_charts "https://github.com/sarvajithsankar/tenet-ai/tree/main/dashboard/src/components/charts"

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_plugin,node_ingest toneBlue
class node_analyzer,node_heuristics,node_mlmodel,node_behavior,node_policy toneAmber
class node_tenant,node_eventstore,node_metrics toneMint
class node_dashboard,node_aggregation,node_charts toneRose
class node_application,node_llm,node_analyst toneIndigo
```

## Components

### LLM Integration

- [Security Plugin](https://github.com/sarvajithsankar/tenet-ai/blob/main/tenet_plugin/client.py): `tenet_plugin/client.py`
- [Ingest API](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/ingest/app.py): `services/ingest/app.py`

### Detection Services

- [Analyzer API](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/app.py): `services/analyzer/app.py`
- [Heuristic Detection](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/app.py): `services/analyzer/app.py`
- [Phishing Model](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/analyzer/model/phishing_model.py): `services/analyzer/model/phishing_model.py`
- [Behavioral Analysis](https://github.com/sarvajithsankar/tenet-ai/tree/main/services/analyzer): `services/analyzer`
- [Policy Actions](https://github.com/sarvajithsankar/tenet-ai/tree/main/services): `services`

### Security Operations

- [Tenant Security](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/security/tenant_security.py): `services/security/tenant_security.py`
- [Redis Event Queue](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/ingest/app.py): `services/ingest/app.py`
- [Prometheus Metrics](https://github.com/sarvajithsankar/tenet-ai/blob/main/services/utils/metrics.py): `services/utils/metrics.py`

### SOC Dashboard

- [Dashboard App](https://github.com/sarvajithsankar/tenet-ai/blob/main/dashboard/src/App.tsx): `dashboard/src/App.tsx`
- [Chart Aggregations](https://github.com/sarvajithsankar/tenet-ai/blob/main/dashboard/src/utils/chartAggregations.ts): `dashboard/src/utils/chartAggregations.ts`
- [SOC Charts](https://github.com/sarvajithsankar/tenet-ai/tree/main/dashboard/src/components/charts): `dashboard/src/components/charts`

### Other components

- **LLM Application**
- **LLM Provider**
- **Security Analyst**

## Connections

- LLM Application → Security Plugin: secures calls
- Security Plugin → Ingest API: submits prompts
- Ingest API → Tenant Security: authenticates tenants (evidence: `services/ingest/app.py`)
- Ingest API → Analyzer API: requests analysis
- Analyzer API → Heuristic Detection: checks patterns (evidence: `services/analyzer/app.py`)
- Analyzer API → Phishing Model: scores prompts
- Analyzer API → Behavioral Analysis: analyzes behavior
- Analyzer API → Policy Actions: selects actions (evidence: `services/analyzer/app.py`)
- Policy Actions → LLM Provider: forwards allowed
- Ingest API → Redis Event Queue: stores events (evidence: `services/ingest/app.py`)
- Analyzer API → Redis Event Queue: updates events (evidence: `services/analyzer/app.py`)
- Ingest API → Prometheus Metrics: records requests (evidence: `services/ingest/app.py`)
- Analyzer API → Prometheus Metrics: records requests (evidence: `services/analyzer/app.py`)
- Dashboard App → Ingest API: fetches events (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Analyzer API: checks health (evidence: `dashboard/src/App.tsx`)
- Dashboard App → Chart Aggregations: aggregates events (evidence: `dashboard/src/App.tsx`)
- Chart Aggregations → SOC Charts: provides chart data (evidence: `dashboard/src/components/charts/DetectionsOverTimeChart.tsx`)
- Security Analyst → Dashboard App: reviews alerts
- Security Analyst → Behavioral Analysis: provides feedback
