# shashivardan-jarpati/askgenie-ai-chatbot architecture

> Architecture diagram of the GitHub repository shashivardan-jarpati/askgenie-ai-chatbot, 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/shashivardan-jarpati/askgenie-ai-chatbot
- Repository: https://github.com/shashivardan-jarpati/askgenie-ai-chatbot

## Overview

AskGenie is a single-file Streamlit chatbot: a user message enters the chat UI, commands are handled directly, and other messages are combined with session history and sent to a locally loaded Phi-3 model. The generated text is cleaned, displayed, and retained in session state. The README also documents adjustable generation settings, GPU/CPU fallback, and graceful loading/inference errors. The excerpts omit parts of chatbot.py, so relationships beyond those explicitly shown or described in the README are documented rather than independently verified.

Main entry points: [`chatbot.py`](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py) (Streamlit chat UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Chat interface"]
  node_chat_ui["Streamlit chat UI<br/>[chatbot.py]"]
  node_settings["Generation settings<br/>[chatbot.py]"]
  node_output["Displayed reply<br/>[chatbot.py]"]
end

subgraph group_conversation["Conversation logic"]
  node_session[("Session history<br/>[chatbot.py]")]
  node_intent["Intent detection<br/>[chatbot.py]"]
  node_commands["Command replies<br/>[chatbot.py]"]
  node_prompt["Prompt builder<br/>[chatbot.py]"]
  node_response_cleaner["Response cleaning<br/>[chatbot.py]"]
end

subgraph group_inference["Local inference"]
  node_model_loader["Model loader<br/>[chatbot.py]"]
  node_phi["Phi-3 inference<br/>[chatbot.py]"]
end

node_user(("User"))

node_user -->|"submits message"| node_chat_ui
node_chat_ui -->|"checks intent"| node_intent
node_intent -->|"dispatches command"| node_commands
node_chat_ui -->|"reads history"| node_session
node_chat_ui -->|"updates history"| node_session
node_chat_ui -->|"builds prompt"| node_prompt
node_prompt -->|"uses history"| node_session
node_chat_ui -->|"loads model"| node_model_loader
node_chat_ui -->|"configures generation"| node_settings
node_chat_ui -->|"runs inference"| node_phi
node_prompt -->|"provides prompt"| node_phi
node_settings -->|"sets parameters"| node_phi
node_phi -->|"returns generated text"| node_response_cleaner
node_response_cleaner -->|"formats reply"| node_output
node_commands -->|"provides reply"| node_output
node_output -->|"preserves conversation"| node_session

click node_chat_ui "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_settings "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_session "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_intent "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_commands "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_prompt "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_model_loader "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_phi "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_response_cleaner "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py"
click node_output "https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.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_chat_ui,node_settings,node_output,node_user toneBlue
class node_session,node_intent,node_commands,node_prompt,node_response_cleaner toneAmber
class node_model_loader,node_phi toneMint
```

## Components

### Chat interface

- [Streamlit chat UI](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Generation settings](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Displayed reply](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`

### Conversation logic

- [Session history](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Intent detection](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Command replies](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Prompt builder](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Response cleaning](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`

### Local inference

- [Model loader](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`
- [Phi-3 inference](https://github.com/shashivardan-jarpati/askgenie-ai-chatbot/blob/main/chatbot.py): `chatbot.py`

### Other components

- **User**

## Connections

- User → Streamlit chat UI: submits message (evidence: `README.md`)
- Streamlit chat UI → Intent detection: checks intent (evidence: `README.md`)
- Intent detection → Command replies: dispatches command (evidence: `README.md`)
- Streamlit chat UI → Session history: reads history (evidence: `README.md`)
- Streamlit chat UI → Session history: updates history (evidence: `chatbot.py`)
- Streamlit chat UI → Prompt builder: builds prompt (evidence: `chatbot.py`)
- Prompt builder → Session history: uses history (evidence: `README.md`)
- Streamlit chat UI → Model loader: loads model (evidence: `chatbot.py`)
- Streamlit chat UI → Generation settings: configures generation (evidence: `README.md`)
- Streamlit chat UI → Phi-3 inference: runs inference (evidence: `chatbot.py`)
- Prompt builder → Phi-3 inference: provides prompt (evidence: `README.md`)
- Generation settings → Phi-3 inference: sets parameters (evidence: `README.md`)
- Phi-3 inference → Response cleaning: returns generated text (evidence: `chatbot.py`)
- Response cleaning → Displayed reply: formats reply (evidence: `chatbot.py`)
- Command replies → Displayed reply: provides reply (evidence: `README.md`)
- Displayed reply → Session history: preserves conversation (evidence: `README.md`)
