# sarthakrastogi/enterprise-agent-system architecture

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

- Interactive diagram: https://gitdiagram.com/sarthakrastogi/enterprise-agent-system
- Repository: https://github.com/sarthakrastogi/enterprise-agent-system

## Overview

Enterprise Agent System is an AWS-hosted platform for company AI agents. The main workflow is signed-in user → Streamlit chat → shared AgentCore runtime, where the request is authenticated and an agent is built and run → governed gateway tools or other integrations → streamed response. Agent definitions, memory, safety, and observability are distinct supporting stages. The README documents infrastructure capabilities whose Terraform implementations were not excerpted; those nodes and links reflect README claims, not inspected Terraform internals.

Main entry points: [`eap/runtime/app.py`](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/app.py) (Runtime entrypoint), [`eap/runtime/builder.py`](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/builder.py) (Agent builder), [`infra/gateway.tf`](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/gateway.tf) (AgentCore Gateway), [`frontend/app.py`](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/frontend/app.py) (Chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Chat Experience"]
  node_chat_ui["Chat UI<br/>[app.py]"]
end

subgraph group_agent_runtime["Agent Runtime"]
  node_agent_definitions["Agent definitions"]
  node_agent_spec["Agent specification<br/>[spec.py]"]
  node_registry["Agent registry<br/>[registry.py]"]
  node_runtime_entry["Runtime entrypoint<br/>[app.py]"]
  node_runtime_config["Runtime configuration<br/>[config.py]"]
  node_identity["Caller identity<br/>[identity.py]"]
  node_agent_builder["Agent builder<br/>[builder.py]"]
  node_agent_tools["Tool adapters<br/>[tools.py]"]
end

subgraph group_tools["Tools and Governance"]
  node_gateway["AgentCore Gateway<br/>[gateway.tf]"]
  node_gateway_policy["Cedar tool policy<br/>[policy.tf]"]
  node_interceptor["Request interceptor<br/>[handler.py]"]
  node_knowledge_server["Knowledge MCP server<br/>[server.py]"]
  node_tickets_lambda["Ticket tools<br/>[handler.py]"]
  node_code_interpreter["Code interpreter<br/>[tools.py]"]
end

subgraph group_platform_services["Platform Services"]
  node_memory[("Conversation memory<br/>[memory.py]")]
  node_model_guardrail["Bedrock model and guardrail<br/>[guardrail.tf]"]
  node_auth["Cognito SSO and authorization<br/>[auth.tf]"]
  node_agent_memory_service[("AgentCore Memory<br/>[memory.tf]")]
  node_metrics["Agent metrics<br/>[metrics.py]"]
  node_observability["CloudWatch observability<br/>[observability.tf]"]
  node_online_evaluations["Online evaluations<br/>[evals.tf]"]
end

node_user(("Signed-in user"))
node_cloudwatch[("CloudWatch")]
node_external_model["Bedrock model service"]
node_agentcore_runtime["AgentCore Runtime"]

node_user -->|"asks"| node_chat_ui
node_chat_ui -->|"invokes with JWT"| node_agentcore_runtime
node_agentcore_runtime -->|"runs shared image"| node_runtime_entry
node_runtime_entry -->|"loads settings"| node_runtime_config
node_runtime_entry -->|"derives caller"| node_identity
node_runtime_entry -->|"loads agent"| node_registry
node_registry -->|"imports definitions"| node_agent_definitions
node_agent_definitions -->|"defines agents"| node_agent_spec
node_runtime_entry -->|"builds agent"| node_agent_builder
node_agent_builder -->|"loads tool adapters"| node_agent_tools
node_agent_builder -->|"recalls and checkpoints"| node_memory
node_runtime_entry -->|"stores completed turn"| node_memory
node_memory -->|"reads and writes"| node_agent_memory_service
node_agent_builder -->|"creates model client"| node_external_model
node_external_model -.->|"uses configured guardrail"| node_model_guardrail
node_agent_builder -->|"requests user tools"| node_gateway
node_agent_tools -->|"lists tools with JWT"| node_gateway
node_gateway -->|"checks permissions"| node_gateway_policy
node_gateway -->|"dispatches requests"| node_interceptor
node_gateway -->|"routes MCP calls"| node_knowledge_server
node_gateway -->|"routes tool calls"| node_tickets_lambda
node_agent_builder -->|"adds built-in tool"| node_code_interpreter
node_auth -->|"authorizes JWT"| node_agentcore_runtime
node_runtime_entry -->|"publishes turn metrics"| node_metrics
node_metrics -->|"publishes metrics"| node_cloudwatch
node_observability -->|"configures telemetry"| node_cloudwatch
node_online_evaluations -.->|"reports evaluations"| node_cloudwatch
node_agent_builder -->|"delegates to sub-agent"| node_agent_builder
node_runtime_entry -->|"streams response"| node_chat_ui

click node_chat_ui "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/frontend/app.py"
click node_agent_definitions "https://github.com/sarthakrastogi/enterprise-agent-system/tree/main/agents"
click node_agent_spec "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/spec.py"
click node_registry "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/registry.py"
click node_runtime_entry "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/app.py"
click node_runtime_config "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/config.py"
click node_identity "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/identity.py"
click node_agent_builder "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/builder.py"
click node_agent_tools "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/tools.py"
click node_memory "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/memory.py"
click node_model_guardrail "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/guardrail.tf"
click node_gateway "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/gateway.tf"
click node_gateway_policy "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/policy.tf"
click node_interceptor "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/lambdas/interceptor/handler.py"
click node_knowledge_server "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/mcp_servers/knowledge/server.py"
click node_tickets_lambda "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/lambdas/tickets/handler.py"
click node_code_interpreter "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/tools.py"
click node_auth "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/auth.tf"
click node_agent_memory_service "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/memory.tf"
click node_metrics "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/metrics.py"
click node_observability "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/observability.tf"
click node_online_evaluations "https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/evals.tf"

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_chat_ui,node_user toneBlue
class node_agent_definitions,node_agent_spec,node_registry,node_runtime_entry,node_runtime_config,node_identity,node_agent_builder,node_agent_tools,node_cloudwatch toneAmber
class node_gateway,node_gateway_policy,node_interceptor,node_knowledge_server,node_tickets_lambda,node_code_interpreter toneMint
class node_memory,node_model_guardrail,node_auth,node_agent_memory_service,node_metrics,node_observability,node_online_evaluations toneRose
class node_external_model,node_agentcore_runtime toneIndigo
```

## Components

### Chat Experience

- [Chat UI](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/frontend/app.py): `frontend/app.py`

### Agent Runtime

- [Agent definitions](https://github.com/sarthakrastogi/enterprise-agent-system/tree/main/agents): `agents`
- [Agent specification](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/spec.py): `eap/spec.py`
- [Agent registry](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/registry.py): `eap/registry.py`
- [Runtime entrypoint](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/app.py): `eap/runtime/app.py`
- [Runtime configuration](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/config.py): `eap/runtime/config.py`
- [Caller identity](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/identity.py): `eap/runtime/identity.py`
- [Agent builder](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/builder.py): `eap/runtime/builder.py`
- [Tool adapters](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/tools.py): `eap/runtime/tools.py`

### Tools and Governance

- [AgentCore Gateway](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/gateway.tf): `infra/gateway.tf`
- [Cedar tool policy](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/policy.tf): `infra/policy.tf`
- [Request interceptor](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/lambdas/interceptor/handler.py): `lambdas/interceptor/handler.py`
- [Knowledge MCP server](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/mcp_servers/knowledge/server.py): `mcp_servers/knowledge/server.py`
- [Ticket tools](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/lambdas/tickets/handler.py): `lambdas/tickets/handler.py`
- [Code interpreter](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/tools.py): `eap/runtime/tools.py`

### Platform Services

- [Conversation memory](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/memory.py): `eap/runtime/memory.py`
- [Bedrock model and guardrail](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/guardrail.tf): `infra/guardrail.tf`
- [Cognito SSO and authorization](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/auth.tf): `infra/auth.tf`
- [AgentCore Memory](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/memory.tf): `infra/memory.tf`
- [Agent metrics](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/eap/runtime/metrics.py): `eap/runtime/metrics.py`
- [CloudWatch observability](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/observability.tf): `infra/observability.tf`
- [Online evaluations](https://github.com/sarthakrastogi/enterprise-agent-system/blob/main/infra/evals.tf): `infra/evals.tf`

### Other components

- **Signed-in user**
- **CloudWatch**
- **Bedrock model service**
- **AgentCore Runtime**

## Connections

- Signed-in user → Chat UI: asks (evidence: `README.md`)
- Chat UI → AgentCore Runtime: invokes with JWT (evidence: `README.md`)
- AgentCore Runtime → Runtime entrypoint: runs shared image (evidence: `README.md`)
- Runtime entrypoint → Runtime configuration: loads settings (evidence: `eap/runtime/app.py`)
- Runtime entrypoint → Caller identity: derives caller (evidence: `eap/runtime/app.py`)
- Runtime entrypoint → Agent registry: loads agent (evidence: `eap/runtime/app.py`)
- Agent registry → Agent definitions: imports definitions (evidence: `eap/registry.py`)
- Agent definitions → Agent specification: defines agents (evidence: `agents/it_helpdesk.py`)
- Runtime entrypoint → Agent builder: builds agent (evidence: `eap/runtime/app.py`)
- Agent builder → Tool adapters: loads tool adapters (evidence: `eap/runtime/builder.py`)
- Agent builder → Conversation memory: recalls and checkpoints (evidence: `eap/runtime/builder.py`)
- Runtime entrypoint → Conversation memory: stores completed turn (evidence: `eap/runtime/app.py`)
- Conversation memory → AgentCore Memory: reads and writes (evidence: `README.md`)
- Agent builder → Bedrock model service: creates model client (evidence: `eap/runtime/builder.py`)
- Bedrock model service → Bedrock model and guardrail: uses configured guardrail (evidence: `README.md`)
- Agent builder → AgentCore Gateway: requests user tools (evidence: `eap/runtime/builder.py`)
- Tool adapters → AgentCore Gateway: lists tools with JWT (evidence: `eap/runtime/tools.py`)
- AgentCore Gateway → Cedar tool policy: checks permissions (evidence: `README.md`)
- AgentCore Gateway → Request interceptor: dispatches requests (evidence: `README.md`)
- AgentCore Gateway → Knowledge MCP server: routes MCP calls (evidence: `README.md`)
- AgentCore Gateway → Ticket tools: routes tool calls (evidence: `README.md`)
- Agent builder → Code interpreter: adds built-in tool (evidence: `eap/runtime/builder.py`)
- Cognito SSO and authorization → AgentCore Runtime: authorizes JWT (evidence: `README.md`)
- Runtime entrypoint → Agent metrics: publishes turn metrics (evidence: `eap/runtime/app.py`)
- Agent metrics → CloudWatch: publishes metrics (evidence: `eap/runtime/metrics.py`)
- CloudWatch observability → CloudWatch: configures telemetry (evidence: `README.md`)
- Online evaluations → CloudWatch: reports evaluations (evidence: `README.md`)
- Agent builder → Agent builder: delegates to sub-agent (evidence: `eap/runtime/builder.py`)
- Runtime entrypoint → Chat UI: streams response (evidence: `README.md`)
