How hassameh7543/langgraph_chatbot works
Project Type and Purpose
• This is a lightweight full-stack conversational AI app.
• Frontend: Streamlit UI for chat threads, animations, downloads
• Backend: Python logic (LangGraph + Groq LLM integration)
• Persistence: SQLite database for chat history (chatbot.db)
File Structure
• Top-level:
• chatbot_frontend.py – Streamlit UI
• chatbot_backend.py – business logic & threading
• chatbot.db – SQLite persistence
• README.md, .gitignore
• No separate “src” folder: frontend and backend live at top level
• Single database file implies an embedded data layer
Key Insights from README
• Multi-threaded conversations tracked by thread_id
• Persistent memory via SQLite checkpoints
• Streamed AI responses with typing animation
• Downloadable transcript feature
Main Components
a. Frontend (Streamlit App)
• User input, chat UI, buttons (new thread, download transcript)
• Displays streaming responses and animations
b. Backend Logic
• Thread management (thread_id generation)
• LangGraph orchestrator + ChatGroq client
• Streams tokens back to UI
• Writes/reads from SQLite
c. Database
• SQLite file ‘chatbot.db’
• Tables: threads, messages
d. External AI Service
• Groq LLM endpoint (openai/gpt-oss-120b)
Relationships and Data Flows
• User → Frontend: enters message, selects thread
• Frontend → Backend: HTTP/RPC call or local function invocation
• Backend ↔ Database:
– Write new message
– Fetch existing history
• Backend → Groq LLM API: send prompt, stream response
• Groq LLM → Backend → Frontend: streaming tokens
• Frontend → User: render streamed response
Architectural Patterns & Design Principles
• Layered architecture: Presentation (UI) → Business (chat logic) → Data (SQLite)
• Single-process multi-threading for thread isolation
• Streaming data pipeline for real-time UX
• Simple persistence (no external DB server)
Final Recommendations
• Break out the App into two sub-components: Frontend & Backend
• Detail interactions: thread creation, message storage, token streaming
• Keep it simple but capture every moving part: UI, business logic, data, external service
• Review with stakeholders to ensure no component is missed