# harshiit112/system_agent_01 architecture

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

- Interactive diagram: https://gitdiagram.com/harshiit112/system_agent_01
- Repository: https://github.com/harshiit112/system_agent_01

## Overview

TerrorGT is a browser-based, tool-using chat application. A user sends a message and thread/model selection through the browser UI; FastAPI records the user message, obtains the selected LangGraph agent, and streams tool activity and answer tokens back over SSE. The agent chooses direct responses or tools, including web search, document retrieval, memory, and live utilities. Document uploads follow a separate ingestion path into Chroma. SQLite stores conversation history and memory, while LangGraph checkpoints preserve agent state. The map follows the README and sampled source; unsampled UI details and integrations are represented only where documented.

Main entry points: [`app.py`](https://github.com/harshiit112/system_agent_01/blob/main/app.py) (FastAPI routes), [`tools.py`](https://github.com/harshiit112/system_agent_01/blob/main/tools.py) (Tool set), [`agent.py`](https://github.com/harshiit112/system_agent_01/blob/main/agent.py) (LangGraph agent), [`rag.py`](https://github.com/harshiit112/system_agent_01/blob/main/rag.py) (Document RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Browser interface"]
  node_ui["Chat UI<br/>[app.js]"]
  node_shell["Page shell<br/>[index.html]"]
end

subgraph group_service["Application service"]
  node_api["FastAPI routes<br/>[app.py]"]
end

subgraph group_agent["Agent and tools"]
  node_agent["LangGraph agent<br/>[agent.py]"]
  node_tools["Tool set<br/>[tools.py]"]
end

subgraph group_knowledge["Knowledge and state"]
  node_rag["Document RAG<br/>[rag.py]"]
  node_chroma[("Chroma vectors")]
  node_database[("Conversation and memory store<br/>[database.py]")]
  node_checkpoint[("Agent checkpoints")]
end

node_user(("User"))
node_models{{"LLM providers"}}
node_tavily{{"Tavily search"}}
node_weather{{"OpenWeather"}}
node_stocks{{"Alpha Vantage"}}
node_embeddings{{"Mistral embeddings"}}

node_user -->|"uses"| node_ui
node_ui -->|"sends requests"| node_api
node_api -->|"streams SSE"| node_ui
node_api -->|"renders page"| node_shell
node_api -->|"gets agent; streams"| node_agent
node_agent -->|"invokes selected model"| node_models
node_agent -->|"dispatches tool calls"| node_tools
node_api -->|"reads and writes chats"| node_database
node_api -->|"indexes uploads"| node_rag
node_api -->|"sets thread context"| node_tools
node_agent -->|"persists graph state"| node_checkpoint
node_tools -->|"searches web"| node_tavily
node_tools -->|"gets live weather"| node_weather
node_tools -->|"gets stock quotes"| node_stocks
node_tools -->|"retrieves documents"| node_rag
node_rag -->|"embeds chunks"| node_embeddings
node_rag -->|"indexes and searches"| node_chroma
node_tools -->|"saves and recalls memory"| node_database

click node_ui "https://github.com/harshiit112/system_agent_01/blob/main/templates/app.js"
click node_shell "https://github.com/harshiit112/system_agent_01/blob/main/templates/index.html"
click node_api "https://github.com/harshiit112/system_agent_01/blob/main/app.py"
click node_agent "https://github.com/harshiit112/system_agent_01/blob/main/agent.py"
click node_tools "https://github.com/harshiit112/system_agent_01/blob/main/tools.py"
click node_rag "https://github.com/harshiit112/system_agent_01/blob/main/rag.py"
click node_database "https://github.com/harshiit112/system_agent_01/blob/main/database.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_ui,node_shell,node_user toneBlue
class node_api toneAmber
class node_agent,node_tools toneMint
class node_rag,node_chroma,node_database,node_checkpoint toneRose
class node_models,node_tavily,node_weather,node_stocks,node_embeddings toneIndigo
```

## Components

### Browser interface

- [Chat UI](https://github.com/harshiit112/system_agent_01/blob/main/templates/app.js): `templates/app.js`
- [Page shell](https://github.com/harshiit112/system_agent_01/blob/main/templates/index.html): `templates/index.html`

### Application service

- [FastAPI routes](https://github.com/harshiit112/system_agent_01/blob/main/app.py): `app.py`

### Agent and tools

- [LangGraph agent](https://github.com/harshiit112/system_agent_01/blob/main/agent.py): `agent.py`
- [Tool set](https://github.com/harshiit112/system_agent_01/blob/main/tools.py): `tools.py`

### Knowledge and state

- [Document RAG](https://github.com/harshiit112/system_agent_01/blob/main/rag.py): `rag.py`
- **Chroma vectors**
- [Conversation and memory store](https://github.com/harshiit112/system_agent_01/blob/main/database.py): `database.py`
- **Agent checkpoints**

### Other components

- **User**
- **LLM providers**
- **Tavily search**
- **OpenWeather**
- **Alpha Vantage**
- **Mistral embeddings**

## Connections

- User → Chat UI: uses
- Chat UI → FastAPI routes: sends requests
- FastAPI routes → Chat UI: streams SSE
- FastAPI routes → Page shell: renders page
- FastAPI routes → LangGraph agent: gets agent; streams
- LangGraph agent → LLM providers: invokes selected model
- LangGraph agent → Tool set: dispatches tool calls
- FastAPI routes → Conversation and memory store: reads and writes chats
- FastAPI routes → Document RAG: indexes uploads
- FastAPI routes → Tool set: sets thread context
- LangGraph agent → Agent checkpoints: persists graph state
- Tool set → Tavily search: searches web
- Tool set → OpenWeather: gets live weather
- Tool set → Alpha Vantage: gets stock quotes
- Tool set → Document RAG: retrieves documents
- Document RAG → Mistral embeddings: embeds chunks
- Document RAG → Chroma vectors: indexes and searches
- Tool set → Conversation and memory store: saves and recalls memory
