# aniketchand/trust architecture

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

- Interactive diagram: https://gitdiagram.com/aniketchand/trust
- Repository: https://github.com/aniketchand/trust

## Overview

AgentTrust mediates AI-agent tool requests through a deterministic security gateway, then permits controlled execution against protected resources and records decisions for audit and incident review. Operators use a React dashboard to manage agents, tools, policies, delegations, provenance, monitoring, and compliance. The README documents these capabilities; sampled source confirms gateway-to-policy, audit, and tool dispatch, plus the dashboard’s API client. Some route internals and console implementations were not sampled, so those links rely on README statements or are omitted.

Main entry points: [`backend/app/services/gateway_service.py`](https://github.com/aniketchand/trust/blob/main/backend/app/services/gateway_service.py) (Execution Gateway), [`backend/app/api/v1`](https://github.com/aniketchand/trust/tree/main/backend/app/api/v1) (API Routes), [`backend/app/services/policy_engine.py`](https://github.com/aniketchand/trust/blob/main/backend/app/services/policy_engine.py) (Policy Engine), [`frontend/src/services/api.client.ts`](https://github.com/aniketchand/trust/blob/main/frontend/src/services/api.client.ts) (API Client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and Dashboard"]
  node_app["FastAPI Application<br/>[main.py]"]
  node_routes["API Routes"]
  node_dashboard["Security Dashboard"]
  node_agent_console["Agent Console<br/>[AgentsTab.tsx]"]
  node_client["API Client<br/>[api.client.ts]"]
  node_agent_runner["Autonomous Agent Runner<br/>[agent_exec.py]"]
end

subgraph group_security["Identity and Enforcement"]
  node_identity["Agent Identity<br/>[agent_service.py]"]
  node_credentials["Credential Security<br/>[security.py]"]
  node_gateway["Execution Gateway<br/>[gateway_service.py]"]
  node_policy["Policy Engine<br/>[policy_engine.py]"]
  node_dlp["Data Leakage Prevention<br/>[dlp_service.py]"]
  node_injection["Injection Defense"]
end

subgraph group_execution["Tool Execution"]
  node_registry["Tool Registry<br/>[tool_registry.py]"]
  node_adapters["Protected Tool Adapters"]
end

subgraph group_governance["Governance and Evidence"]
  node_delegation["Delegation Controls"]
  node_provenance["Data Provenance<br/>[provenance.py]"]
  node_audit["Audit and Incidents<br/>[audit_service.py]"]
  node_monitoring["Monitoring and Overview<br/>[overview.py]"]
end

subgraph group_state["Platform State"]
  node_database[("Relational Database<br/>[database.py]")]
end

node_agents(("AI Agents"))
node_operators(("Security Operators"))
node_opa["Open Policy Agent"]
node_resources["Protected Resources"]

node_agents -->|"request execution"| node_gateway
node_gateway -->|"evaluate access"| node_policy
node_gateway -->|"check leakage"| node_dlp
node_gateway -->|"inspect prompts"| node_injection
node_gateway -.->|"verify delegation"| node_delegation
node_gateway -->|"resolve tool"| node_registry
node_gateway -->|"record outcome"| node_audit
node_gateway -->|"execute allowed action"| node_adapters
node_adapters -->|"access protected resource"| node_resources
node_registry -->|"register implementations"| node_adapters
node_policy -->|"query optionally"| node_opa
node_policy -->|"read permissions"| node_database
node_identity -->|"hash credentials"| node_credentials
node_operators -->|"manage security"| node_dashboard
node_dashboard -.->|"request platform data"| node_client
node_agent_console -->|"provision and revoke"| node_client
node_client -->|"call REST endpoints"| node_routes
node_routes -.->|"dispatch execution"| node_gateway
node_routes -.->|"manage agents"| node_identity
node_routes -.->|"manage grants"| node_delegation
node_routes -.->|"serve lineage"| node_provenance
node_routes -.->|"serve audit records"| node_audit
node_routes -.->|"manage policies"| node_policy
node_agent_runner -->|"intercept workflow actions"| node_gateway
node_app -->|"mount routes"| node_routes
node_app -->|"initialize tables"| node_database
node_monitoring -.->|"aggregate telemetry"| node_database

click node_app "https://github.com/aniketchand/trust/blob/main/backend/app/main.py"
click node_routes "https://github.com/aniketchand/trust/tree/main/backend/app/api/v1"
click node_dashboard "https://github.com/aniketchand/trust/tree/main/frontend/src/components/tabs"
click node_agent_console "https://github.com/aniketchand/trust/blob/main/frontend/src/components/tabs/AgentsTab.tsx"
click node_client "https://github.com/aniketchand/trust/blob/main/frontend/src/services/api.client.ts"
click node_identity "https://github.com/aniketchand/trust/blob/main/backend/app/services/agent_service.py"
click node_credentials "https://github.com/aniketchand/trust/blob/main/backend/app/core/security.py"
click node_gateway "https://github.com/aniketchand/trust/blob/main/backend/app/services/gateway_service.py"
click node_policy "https://github.com/aniketchand/trust/blob/main/backend/app/services/policy_engine.py"
click node_dlp "https://github.com/aniketchand/trust/blob/main/backend/app/services/dlp_service.py"
click node_injection "https://github.com/aniketchand/trust/blob/main/backend/app/services/prompt_injection_service.py"
click node_delegation "https://github.com/aniketchand/trust/blob/main/backend/app/services/delegation_service.py"
click node_provenance "https://github.com/aniketchand/trust/blob/main/backend/app/api/v1/provenance.py"
click node_audit "https://github.com/aniketchand/trust/blob/main/backend/app/services/audit_service.py"
click node_monitoring "https://github.com/aniketchand/trust/blob/main/backend/app/api/v1/overview.py"
click node_registry "https://github.com/aniketchand/trust/blob/main/backend/app/services/tool_registry.py"
click node_adapters "https://github.com/aniketchand/trust/tree/main/backend/app/tools"
click node_database "https://github.com/aniketchand/trust/blob/main/backend/app/core/database.py"
click node_agent_runner "https://github.com/aniketchand/trust/blob/main/backend/app/api/v1/agent_exec.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_app,node_routes,node_dashboard,node_agent_console,node_client,node_agent_runner toneBlue
class node_identity,node_credentials,node_gateway,node_policy,node_dlp,node_injection toneAmber
class node_registry,node_adapters toneMint
class node_delegation,node_provenance,node_audit,node_monitoring toneRose
class node_database,node_agents,node_operators,node_opa,node_resources toneIndigo
```

## Components

### Entry and Dashboard

- [FastAPI Application](https://github.com/aniketchand/trust/blob/main/backend/app/main.py): `backend/app/main.py`
- [API Routes](https://github.com/aniketchand/trust/tree/main/backend/app/api/v1): `backend/app/api/v1`
- [Security Dashboard](https://github.com/aniketchand/trust/tree/main/frontend/src/components/tabs): `frontend/src/components/tabs`
- [Agent Console](https://github.com/aniketchand/trust/blob/main/frontend/src/components/tabs/AgentsTab.tsx): `frontend/src/components/tabs/AgentsTab.tsx`
- [API Client](https://github.com/aniketchand/trust/blob/main/frontend/src/services/api.client.ts): `frontend/src/services/api.client.ts`
- [Autonomous Agent Runner](https://github.com/aniketchand/trust/blob/main/backend/app/api/v1/agent_exec.py): `backend/app/api/v1/agent_exec.py`

### Identity and Enforcement

- [Agent Identity](https://github.com/aniketchand/trust/blob/main/backend/app/services/agent_service.py): `backend/app/services/agent_service.py`
- [Credential Security](https://github.com/aniketchand/trust/blob/main/backend/app/core/security.py): `backend/app/core/security.py`
- [Execution Gateway](https://github.com/aniketchand/trust/blob/main/backend/app/services/gateway_service.py): `backend/app/services/gateway_service.py`
- [Policy Engine](https://github.com/aniketchand/trust/blob/main/backend/app/services/policy_engine.py): `backend/app/services/policy_engine.py`
- [Data Leakage Prevention](https://github.com/aniketchand/trust/blob/main/backend/app/services/dlp_service.py): `backend/app/services/dlp_service.py`
- [Injection Defense](https://github.com/aniketchand/trust/blob/main/backend/app/services/prompt_injection_service.py): `backend/app/services/prompt_injection_service.py`

### Tool Execution

- [Tool Registry](https://github.com/aniketchand/trust/blob/main/backend/app/services/tool_registry.py): `backend/app/services/tool_registry.py`
- [Protected Tool Adapters](https://github.com/aniketchand/trust/tree/main/backend/app/tools): `backend/app/tools`

### Governance and Evidence

- [Delegation Controls](https://github.com/aniketchand/trust/blob/main/backend/app/services/delegation_service.py): `backend/app/services/delegation_service.py`
- [Data Provenance](https://github.com/aniketchand/trust/blob/main/backend/app/api/v1/provenance.py): `backend/app/api/v1/provenance.py`
- [Audit and Incidents](https://github.com/aniketchand/trust/blob/main/backend/app/services/audit_service.py): `backend/app/services/audit_service.py`
- [Monitoring and Overview](https://github.com/aniketchand/trust/blob/main/backend/app/api/v1/overview.py): `backend/app/api/v1/overview.py`

### Platform State

- [Relational Database](https://github.com/aniketchand/trust/blob/main/backend/app/core/database.py): `backend/app/core/database.py`

### Other components

- **AI Agents**
- **Security Operators**
- **Open Policy Agent**
- **Protected Resources**

## Connections

- AI Agents → Execution Gateway: request execution (evidence: `README.md`)
- Execution Gateway → Policy Engine: evaluate access (evidence: `backend/app/services/gateway_service.py`)
- Execution Gateway → Data Leakage Prevention: check leakage (evidence: `backend/app/services/gateway_service.py`)
- Execution Gateway → Injection Defense: inspect prompts (evidence: `backend/app/services/gateway_service.py`)
- Execution Gateway → Delegation Controls: verify delegation
- Execution Gateway → Tool Registry: resolve tool (evidence: `backend/app/services/gateway_service.py`)
- Execution Gateway → Audit and Incidents: record outcome (evidence: `backend/app/services/gateway_service.py`)
- Execution Gateway → Protected Tool Adapters: execute allowed action (evidence: `backend/app/services/gateway_service.py`)
- Protected Tool Adapters → Protected Resources: access protected resource (evidence: `README.md`)
- Tool Registry → Protected Tool Adapters: register implementations (evidence: `backend/app/services/tool_registry.py`)
- Policy Engine → Open Policy Agent: query optionally (evidence: `backend/app/services/policy_engine.py`)
- Policy Engine → Relational Database: read permissions (evidence: `backend/app/services/policy_engine.py`)
- Agent Identity → Credential Security: hash credentials (evidence: `backend/app/services/agent_service.py`)
- Security Operators → Security Dashboard: manage security (evidence: `README.md`)
- Security Dashboard → API Client: request platform data (evidence: `frontend/src/components/tabs/AgentsTab.tsx`)
- Agent Console → API Client: provision and revoke (evidence: `frontend/src/components/tabs/AgentsTab.tsx`)
- API Client → API Routes: call REST endpoints (evidence: `README.md`)
- API Routes → Execution Gateway: dispatch execution (evidence: `backend/app/api/v1/agent_exec.py`)
- API Routes → Agent Identity: manage agents
- API Routes → Delegation Controls: manage grants
- API Routes → Data Provenance: serve lineage (evidence: `backend/app/api/v1/router.py`)
- API Routes → Audit and Incidents: serve audit records
- API Routes → Policy Engine: manage policies
- Autonomous Agent Runner → Execution Gateway: intercept workflow actions (evidence: `backend/app/api/v1/agent_exec.py`)
- FastAPI Application → API Routes: mount routes (evidence: `backend/app/main.py`)
- FastAPI Application → Relational Database: initialize tables (evidence: `backend/app/main.py`)
- Monitoring and Overview → Relational Database: aggregate telemetry
