# chakradhar080/simple_chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/chakradhar080/simple_chatbot
- Repository: https://github.com/chakradhar080/simple_chatbot

## Overview

This is a multi-provider AI chatbot: users chat through a Streamlit interface, which posts messages to a FastAPI endpoint; the endpoint dispatches requests to OpenAI, Gemini, or Groq wrappers and returns a response. The interface keeps chat messages in session state. The README also describes environment-based API keys and provider extensibility. The frontend currently selects OpenAI explicitly, while the backend supports all three providers. Connections are limited to relationships shown in the excerpts or documented in the README.

Main entry points: [`backend/main.py`](https://github.com/chakradhar080/simple_chatbot/blob/main/backend/main.py) (Chat endpoint), [`.env`](https://github.com/chakradhar080/simple_chatbot/blob/main/.env) (API key configuration), [`frontend/streamlit_app.py`](https://github.com/chakradhar080/simple_chatbot/blob/main/frontend/streamlit_app.py) (Chat interface), [`backend/bots.py`](https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py) (OpenAI wrapper)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat interface"]
  node_streamlit["Chat interface<br/>[streamlit_app.py]"]
  node_session[("Session messages<br/>[streamlit_app.py]")]
end

subgraph group_api["Chat API"]
  node_fastapi["Chat endpoint<br/>[main.py]"]
end

subgraph group_providers["AI providers"]
  node_openai_bot["OpenAI wrapper<br/>[bots.py]"]
  node_gemini_bot["Gemini wrapper<br/>[bots.py]"]
  node_groq_bot["Groq wrapper<br/>[bots.py]"]
end

node_user(("User"))
node_openai_service{{"OpenAI API"}}
node_gemini_service{{"Gemini API"}}
node_groq_service{{"Groq API"}}
node_env_keys["API key configuration<br/>[.env]"]

node_user -->|"sends prompt"| node_streamlit
node_streamlit -->|"updates history"| node_session
node_streamlit -->|"posts message"| node_fastapi
node_fastapi -->|"dispatches OpenAI"| node_openai_bot
node_fastapi -->|"dispatches Gemini"| node_gemini_bot
node_fastapi -->|"dispatches Groq"| node_groq_bot
node_openai_bot -->|"requests completion"| node_openai_service
node_gemini_bot -->|"generates content"| node_gemini_service
node_groq_bot -->|"requests completion"| node_groq_service
node_env_keys -->|"provides key"| node_openai_bot
node_env_keys -->|"provides key"| node_gemini_bot
node_env_keys -->|"provides key"| node_groq_bot

click node_streamlit "https://github.com/chakradhar080/simple_chatbot/blob/main/frontend/streamlit_app.py"
click node_session "https://github.com/chakradhar080/simple_chatbot/blob/main/frontend/streamlit_app.py"
click node_fastapi "https://github.com/chakradhar080/simple_chatbot/blob/main/backend/main.py"
click node_openai_bot "https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py"
click node_gemini_bot "https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py"
click node_groq_bot "https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py"
click node_env_keys "https://github.com/chakradhar080/simple_chatbot/blob/main/.env"

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_streamlit,node_session,node_user toneBlue
class node_fastapi toneAmber
class node_openai_bot,node_gemini_bot,node_groq_bot,node_openai_service,node_gemini_service,node_groq_service,node_env_keys toneMint
```

## Components

### Chat interface

- [Chat interface](https://github.com/chakradhar080/simple_chatbot/blob/main/frontend/streamlit_app.py): `frontend/streamlit_app.py`
- [Session messages](https://github.com/chakradhar080/simple_chatbot/blob/main/frontend/streamlit_app.py): `frontend/streamlit_app.py`

### Chat API

- [Chat endpoint](https://github.com/chakradhar080/simple_chatbot/blob/main/backend/main.py): `backend/main.py`

### AI providers

- [OpenAI wrapper](https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py): `backend/bots.py`
- [Gemini wrapper](https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py): `backend/bots.py`
- [Groq wrapper](https://github.com/chakradhar080/simple_chatbot/blob/main/backend/bots.py): `backend/bots.py`

### Other components

- **User**
- **OpenAI API**
- **Gemini API**
- **Groq API**
- [API key configuration](https://github.com/chakradhar080/simple_chatbot/blob/main/.env): `.env`

## Connections

- User → Chat interface: sends prompt (evidence: `README.md`)
- Chat interface → Session messages: updates history (evidence: `frontend/streamlit_app.py`)
- Chat interface → Chat endpoint: posts message (evidence: `frontend/streamlit_app.py`)
- Chat endpoint → OpenAI wrapper: dispatches OpenAI (evidence: `backend/main.py`)
- Chat endpoint → Gemini wrapper: dispatches Gemini (evidence: `backend/main.py`)
- Chat endpoint → Groq wrapper: dispatches Groq (evidence: `backend/main.py`)
- OpenAI wrapper → OpenAI API: requests completion (evidence: `backend/bots.py`)
- Gemini wrapper → Gemini API: generates content (evidence: `backend/bots.py`)
- Groq wrapper → Groq API: requests completion (evidence: `backend/bots.py`)
- API key configuration → OpenAI wrapper: provides key (evidence: `backend/bots.py`)
- API key configuration → Gemini wrapper: provides key (evidence: `backend/bots.py`)
- API key configuration → Groq wrapper: provides key (evidence: `backend/bots.py`)
