# theonlyabdulhamid/chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/theonlyabdulhamid/chatbot
- Repository: https://github.com/theonlyabdulhamid/chatbot

## Overview

AI Support Assistant is a Python chat application with both an interactive CLI and a FastAPI chat endpoint. Users submit messages through either entry point; each delegates to the shared client, which sends them to Gemini, returns a reply, and persists conversation history in JSON. On startup, the client loads credentials and restores prior history for the chat session. The README describes the CLI workflow; the sampled `app.py` additionally exposes an HTTP API. The shared client is one file, so its distinct responsibilities share a source path.

Main entry points: [`api_client.py`](https://github.com/theonlyabdulhamid/chatbot/blob/main/api_client.py) (Chat client), [`main.py`](https://github.com/theonlyabdulhamid/chatbot/blob/main/main.py) (Interactive CLI), [`app.py`](https://github.com/theonlyabdulhamid/chatbot/blob/main/app.py) (Chat API), [`chat_history.json`](https://github.com/theonlyabdulhamid/chatbot/blob/main/chat_history.json) (JSON history)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entrypoints["User entry points"]
  node_cli["Interactive CLI<br/>[main.py]"]
  node_http_api["Chat API<br/>[app.py]"]
end

subgraph group_conversation["Conversation handling"]
  node_client["Chat client<br/>[api_client.py]"]
end

subgraph group_integrations["External services and state"]
  node_credential_setup["Credential setup<br/>[api_client.py]"]
  node_gemini["Gemini service"]
  node_history[("JSON history<br/>[chat_history.json]")]
end

node_cli_user(("CLI user"))
node_http_client(("HTTP client"))

node_cli_user -->|"enters messages"| node_cli
node_cli -->|"sends messages"| node_client
node_http_client -->|"posts messages"| node_http_api
node_http_api -->|"sends messages"| node_client
node_client -->|"loads credentials"| node_credential_setup
node_client -->|"loads and saves"| node_history
node_client -->|"sends chat requests"| node_gemini
node_gemini -->|"returns responses"| node_client

click node_cli "https://github.com/theonlyabdulhamid/chatbot/blob/main/main.py"
click node_http_api "https://github.com/theonlyabdulhamid/chatbot/blob/main/app.py"
click node_client "https://github.com/theonlyabdulhamid/chatbot/blob/main/api_client.py"
click node_credential_setup "https://github.com/theonlyabdulhamid/chatbot/blob/main/api_client.py"
click node_history "https://github.com/theonlyabdulhamid/chatbot/blob/main/chat_history.json"

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_cli,node_http_api,node_cli_user,node_http_client toneBlue
class node_client toneAmber
class node_credential_setup,node_gemini,node_history toneMint
```

## Components

### User entry points

- [Interactive CLI](https://github.com/theonlyabdulhamid/chatbot/blob/main/main.py): `main.py`
- [Chat API](https://github.com/theonlyabdulhamid/chatbot/blob/main/app.py): `app.py`

### Conversation handling

- [Chat client](https://github.com/theonlyabdulhamid/chatbot/blob/main/api_client.py): `api_client.py`

### External services and state

- [Credential setup](https://github.com/theonlyabdulhamid/chatbot/blob/main/api_client.py): `api_client.py`
- **Gemini service**
- [JSON history](https://github.com/theonlyabdulhamid/chatbot/blob/main/chat_history.json): `chat_history.json`

### Other components

- **CLI user**
- **HTTP client**

## Connections

- CLI user → Interactive CLI: enters messages (evidence: `main.py`)
- Interactive CLI → Chat client: sends messages (evidence: `main.py`)
- HTTP client → Chat API: posts messages (evidence: `app.py`)
- Chat API → Chat client: sends messages (evidence: `app.py`)
- Chat client → Credential setup: loads credentials (evidence: `api_client.py`)
- Chat client → JSON history: loads and saves (evidence: `api_client.py`)
- Chat client → Gemini service: sends chat requests (evidence: `api_client.py`)
- Gemini service → Chat client: returns responses (evidence: `api_client.py`)
