# mehta-amit-codes/agentic-guardrails architecture

> Architecture diagram of the GitHub repository mehta-amit-codes/agentic-guardrails, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mehta-amit-codes/agentic-guardrails
- Repository: https://github.com/mehta-amit-codes/agentic-guardrails

## Overview

This is a reference ReAct agent service with a Streamlit monitoring interface. A user submits a task through the UI or API; the agent reasons with Grok, selects tools, applies guardrails and budget limits, records traces, and returns a final or partial result. Separate capabilities support run-history browsing, replay, and adversarial guardrail checks. The README documents the module layout and relationships, but the supplied file tree contains only README.md and no source excerpts, so repository-node paths are left null and the graph follows documented behavior only.

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_ui["Streamlit UI"]
  node_api["FastAPI"]
end

subgraph group_runtime["Agent runtime"]
  node_agent["ReAct agent"]
  node_tools["Tool dispatcher"]
  node_calculator["Calculator"]
  node_search["Web search"]
  node_final["Final answer tool"]
end

subgraph group_safety["Guardrails and limits"]
  node_injection["Injection scanning"]
  node_schema["Output validation"]
  node_pii["PII redaction"]
  node_budget["Budget and breaker"]
end

subgraph group_operations["Trace and evaluation"]
  node_replay["Replay service"]
  node_redteam["Red-team suite"]
  node_tracing["Trace service"]
  node_db[("SQLite trace store")]
end

node_user(("User"))
node_grok["Grok API"]
node_duckduckgo["DuckDuckGo API"]

node_user -->|"submits tasks"| node_ui
node_user -->|"calls endpoints"| node_api
node_ui -->|"calls API"| node_api
node_api -->|"runs task"| node_agent
node_agent -->|"requests reasoning"| node_grok
node_agent -->|"dispatches calls"| node_tools
node_tools -->|"dispatches calculation"| node_calculator
node_tools -->|"dispatches search"| node_search
node_tools -->|"dispatches answer"| node_final
node_search -->|"queries"| node_duckduckgo
node_agent -->|"scans arguments and output"| node_injection
node_agent -->|"validates tool output"| node_schema
node_agent -->|"redacts output"| node_pii
node_agent -->|"records usage and checks limits"| node_budget
node_agent -->|"records spans"| node_tracing
node_tracing -->|"stores runs and spans"| node_db
node_api -->|"reads run history"| node_tracing
node_api -->|"starts replay"| node_replay
node_replay -->|"reruns task"| node_agent
node_api -->|"starts adversarial checks"| node_redteam
node_redteam -->|"runs test tasks"| node_agent
node_ui -->|"requests trace data"| node_api

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_ui,node_api,node_user toneBlue
class node_agent,node_tools,node_calculator,node_search,node_final toneAmber
class node_injection,node_schema,node_pii,node_budget,node_grok,node_duckduckgo toneMint
class node_replay,node_redteam,node_tracing,node_db toneRose
```

## Components

### User interfaces

- **Streamlit UI**
- **FastAPI**

### Agent runtime

- **ReAct agent**
- **Tool dispatcher**
- **Calculator**
- **Web search**
- **Final answer tool**

### Guardrails and limits

- **Injection scanning**
- **Output validation**
- **PII redaction**
- **Budget and breaker**

### Trace and evaluation

- **Replay service**
- **Red-team suite**
- **Trace service**
- **SQLite trace store**

### Other components

- **User**
- **Grok API**
- **DuckDuckGo API**

## Connections

- User → Streamlit UI: submits tasks
- User → FastAPI: calls endpoints
- Streamlit UI → FastAPI: calls API
- FastAPI → ReAct agent: runs task
- ReAct agent → Grok API: requests reasoning
- ReAct agent → Tool dispatcher: dispatches calls
- Tool dispatcher → Calculator: dispatches calculation
- Tool dispatcher → Web search: dispatches search
- Tool dispatcher → Final answer tool: dispatches answer
- Web search → DuckDuckGo API: queries
- ReAct agent → Injection scanning: scans arguments and output
- ReAct agent → Output validation: validates tool output
- ReAct agent → PII redaction: redacts output
- ReAct agent → Budget and breaker: records usage and checks limits
- ReAct agent → Trace service: records spans
- Trace service → SQLite trace store: stores runs and spans
- FastAPI → Trace service: reads run history
- FastAPI → Replay service: starts replay
- Replay service → ReAct agent: reruns task
- FastAPI → Red-team suite: starts adversarial checks
- Red-team suite → ReAct agent: runs test tasks
- Streamlit UI → FastAPI: requests trace data
