# avibansal/chatbot-using-langgraph architecture

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

- Interactive diagram: https://gitdiagram.com/avibansal/chatbot-using-langgraph
- Repository: https://github.com/avibansal/chatbot-using-langgraph

## Overview

##### Project type and purpose
- This is a lightweight full-stack Python application delivered via Streamlit.
- Purpose: expose a conversational ChatBot (LangChain-powered) in a web UI, with optional external web search tooling (GROQ & TAVILY APIs).

##### File structure
- Top-level files only:
- Basic Chatbot.py – core chatbot logic without external tool
- ChatBot with Tool.py – extended chatbot with external web-search tool
- requirements.txt – Python dependencies (e.g., streamlit, langchain)
- .env – runtime configuration for API keys
- No separate “frontend” or “backend” folders; the Streamlit script handles both layers.

##### README for additional insights
- Key dependencies and runtime steps.
- Two modes: basic conversational agent vs. agent augmented with a “Web Search” tool.
- Uses environment variables (GROQ_API_KEY, TAVILY_API_KEY) to drive external tools.

##### Main components and their relationships
a. Streamlit UI
- Single-page app that captures user input and displays chatbot responses/visualizations.
b. ChatBot Core (LangChain)
- Orchestrates LLM calls, prompt templates, memory (if any), and tool invocation.
c. External Tool Integration
- GROQ API: fetch domain-specific data
- TAVILY API: perform external web searches
d. Configuration / Environment
- `.env` loader that injects API keys into the Python runtime.
e. Python Runtime & Dependencies
- Interpreter, LangChain, Streamlit, any HTTP clients.

Interactions:
- User → Streamlit UI → ChatBot Core → (optional) External Tool → LLM API → ChatBot Core → Streamlit UI → User

##### Architectural patterns & design principles
- Layered pattern: Presentation (Streamlit) → Application Logic (LangChain pipeline) → Infrastructure (External APIs).
- “Adapter” style for tool integration: ChatBot Core calls a unified interface for GROQ or TAVILY.
- Single-process deployment (Streamlit serves both front- and back-end).

2. Inside it or just to the right, place “ChatBot Core (LangChain)” (green).
- UI → Core: “user query”
- Core → LLM Provider: “prompt & context”
- Core → GROQ/TAVILY: “tool call” (annotate as only on Tool-enabled path)
- Core → UI: “response & visualization”
7. Two script entrypoints: “Basic Chatbot.py” directly wires UI→Core→UI; “ChatBot with Tool.py” wires UI→Core→External APIs→Core→UI.
8. Labels for technologies:

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "Presentation Layer"
        UI["Streamlit UI<br/>(Streamlit)"]:::frontend
    end

    subgraph "Application Logic"
        Core["LangChain ChatBot Core<br/>(LangChain, Python 3.x)"]:::logic
    end

    subgraph "Infrastructure / External Services"
        LLM["LLM Provider<br/>(e.g., OpenAI)"]:::service
        GROQ["GROQ API<br/>(HTTP/REST)"]:::service
        TAVILY["TAVILY API<br/>(HTTP/REST)"]:::service
    end

    %% Config and Documentation
    Config[".env / Config Loader"]:::config
    Requirements["requirements.txt"]:::doc
    README["README.md"]:::doc

    %% Data Flows
    UI -->|"user query"| Core
    Core -->|"prompt & context"| LLM
    Core -->|"tool call (Tool-enabled)"| GROQ
    Core -->|"tool call (Tool-enabled)"| TAVILY
    Core -->|"response & visualization"| UI
    Config -.->|"loads API keys"| Core

    %% Click Events
    click UI "https://github.com/avibansal/chatbot-using-langgraph/blob/main/Basic Chatbot.py"
    click UI "https://github.com/avibansal/chatbot-using-langgraph/blob/main/ChatBot with Tool.py"
    click Core "https://github.com/avibansal/chatbot-using-langgraph/blob/main/Basic Chatbot.py"
    click Core "https://github.com/avibansal/chatbot-using-langgraph/blob/main/ChatBot with Tool.py"
    click GROQ "https://github.com/avibansal/chatbot-using-langgraph/blob/main/ChatBot with Tool.py"
    click TAVILY "https://github.com/avibansal/chatbot-using-langgraph/blob/main/ChatBot with Tool.py"
    click Config "https://github.com/avibansal/chatbot-using-langgraph/blob/main/.gitignore"
    click Requirements "https://github.com/avibansal/chatbot-using-langgraph/blob/main/requirements.txt"
    click README "https://github.com/avibansal/chatbot-using-langgraph/blob/main/README.md"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366D6,color:#0366D6,stroke-width:2px;
    classDef logic fill:#DFFFE0,stroke:#2E8B57,color:#2E8B57,stroke-width:2px;
    classDef service fill:#F3E5FF,stroke:#6A0DAD,color:#6A0DAD,stroke-width:2px,shape:cylinder;
    classDef config fill:#EEEEEE,stroke:#666666,color:#666666,stroke-width:1px,stroke-dasharray: 5 5;
    classDef doc fill:#FFF5CC,stroke:#CC9900,color:#996600,stroke-width:1px;
```
