# abhinav-code-cloud/mini-chatgpt architecture

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

- Interactive diagram: https://gitdiagram.com/abhinav-code-cloud/mini-chatgpt
- Repository: https://github.com/abhinav-code-cloud/mini-chatgpt

## Overview

MyBolt is a small conversational agent with a terminal interaction loop: a user message reaches the agent, which requests an LLM reply, saves the exchange, and returns the reply. A separate FastAPI WebSocket endpoint echoes received text with an acknowledgement; the shown code does not route WebSocket messages through the agent. The source excerpts establish these paths, but provide no evidence of shared state or integration between the two entry points.

Main entry points: [`agents/agent1/agent.py`](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/agents/agent1/agent.py) (Message Handler), [`main.py`](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/main.py) (Terminal Loop), [`llm.py`](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/llm.py) (LLM Client), [`memstore/memory.py`](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/memstore/memory.py) (Memory Writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_terminal["Terminal Agent"]
  node_main_loop["Terminal Loop<br/>[main.py]"]
  node_agent_handler["Message Handler<br/>[agent.py]"]
end

subgraph group_services["Agent Services"]
  node_llm_client["LLM Client<br/>[llm.py]"]
  node_memory_writer["Memory Writer<br/>[memory.py]"]
  node_memory_file[("Conversation Memory<br/>[memory.json]")]
end

subgraph group_websocket["WebSocket"]
  node_ws_gateway["WebSocket Endpoint<br/>[gateway.py]"]
end

node_terminal_user(("Terminal User"))
node_openai["OpenAI API"]
node_ws_client(("WebSocket Client"))

node_terminal_user -->|"enters message"| node_main_loop
node_main_loop -->|"calls handler"| node_agent_handler
node_agent_handler -->|"requests reply"| node_llm_client
node_llm_client -->|"calls chat API"| node_openai
node_agent_handler -->|"saves exchange"| node_memory_writer
node_memory_writer -->|"reads and writes"| node_memory_file
node_ws_client -->|"sends text"| node_ws_gateway
node_ws_gateway -->|"sends acknowledgement"| node_ws_client

click node_main_loop "https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/main.py"
click node_agent_handler "https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/agents/agent1/agent.py"
click node_llm_client "https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/llm.py"
click node_memory_writer "https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/memstore/memory.py"
click node_memory_file "https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/memstore/memory.json"
click node_ws_gateway "https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/gateway.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_main_loop,node_agent_handler,node_terminal_user,node_ws_client toneBlue
class node_llm_client,node_memory_writer,node_memory_file toneAmber
class node_ws_gateway,node_openai toneMint
```

## Components

### Terminal Agent

- [Terminal Loop](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/main.py): `main.py`
- [Message Handler](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/agents/agent1/agent.py): `agents/agent1/agent.py`

### Agent Services

- [LLM Client](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/llm.py): `llm.py`
- [Memory Writer](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/memstore/memory.py): `memstore/memory.py`
- [Conversation Memory](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/memstore/memory.json): `memstore/memory.json`

### WebSocket

- [WebSocket Endpoint](https://github.com/abhinav-code-cloud/mini-chatgpt/blob/main/gateway.py): `gateway.py`

### Other components

- **Terminal User**
- **OpenAI API**
- **WebSocket Client**

## Connections

- Terminal User → Terminal Loop: enters message (evidence: `main.py`)
- Terminal Loop → Message Handler: calls handler (evidence: `main.py`)
- Message Handler → LLM Client: requests reply (evidence: `agents/agent1/agent.py`)
- LLM Client → OpenAI API: calls chat API (evidence: `llm.py`)
- Message Handler → Memory Writer: saves exchange (evidence: `agents/agent1/agent.py`)
- Memory Writer → Conversation Memory: reads and writes (evidence: `memstore/memory.py`)
- WebSocket Client → WebSocket Endpoint: sends text (evidence: `gateway.py`)
- WebSocket Endpoint → WebSocket Client: sends acknowledgement (evidence: `gateway.py`)
