A production-ready conversational AI chatbot built with LangGraph, Groq LLM, and Streamlit β featuring persistent multi-thread memory, real-time streaming, auto-generated chat titles, and a clean ChatGPT-style interface.
πππ APP IS LIVE ON THE INTERNET!
URLs:
- Frontend β https://webot-frontend.onrender.com/
- Backend docs β https://webot-u9b2.onrender.com/docs
- About the Project
- How It Works
- Features
- Tech Stack
- Architecture
- Project Structure
- Getting Started
- Environment Variables
- Usage
- Roadmap
- Contributing
Webot is a full-featured AI chatbot application that goes beyond a basic LLM wrapper. It manages multiple independent conversation threads, each with its own persistent memory stored in a local SQLite database β so your chats survive page refreshes and app restarts.
The backend is powered by LangGraph, a state machine framework that structures the conversation flow as a compiled graph. This makes the architecture scalable, inspectable, and easy to extend with new nodes (tools, RAG, agents, etc.).
On the frontend, Streamlit delivers a clean, responsive chat UI with sidebar thread management, real-time streaming responses, token tracking, and chat export β all in a single Python file.
User Message
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββ
β LangGraph Graph β
β β
β START βββΊ chat_node βββΊ END β
β β
β chat_node: β
β 1. Attach system prompt β
β 2. Trim messages to last 4000 tokens β
β 3. Invoke Groq LLM β
β 4. Log token usage β
β 5. Return AI response β
ββββββββββββββββ¬ββββββββββββββββββββββββββββ
β
βΌ
SQLite Checkpointer
(persists state per thread_id)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Streamlit App β
β β
β Sidebar Main Chat β
β βββββββββ βββββββββ β
β β New Chat Chat messages rendered β
β β¬οΈ Export Chat st.chat_input box β
β Thread list st.write_stream() β
β βΆ Active thread (real-time streaming) β
β βοΈ Rename β
β ποΈ Delete β
β Token counter β
β Thread ID display β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Each conversation is identified by a UUID thread ID. LangGraph's SqliteSaver checkpointer stores the full message history per thread, so switching between conversations loads the exact prior context.
- π¬ Multi-thread conversations β create, switch, rename, and delete independent chat sessions
- π§ Persistent memory β chats are saved to SQLite and survive restarts
- β‘ Real-time streaming β responses stream token-by-token like ChatGPT
- π·οΈ Auto-generated titles β first message automatically generates a smart thread title via LLM
- βοΈ Rename & delete threads β full conversation management from the sidebar
- β¬οΈ Export chat β download any conversation as a
.txtfile - βοΈ Context trimming β automatically trims to last 4,000 tokens to prevent cost blowup
- π Multilingual β responds in whatever language the user writes in
- π Token tracking β live session token count displayed in sidebar
- π Secure config β API key loaded from
.env, never hardcoded
| Layer | Technology | Purpose |
|---|---|---|
| LLM | Groq β llama-3.1-8b-instant |
Ultra-fast chat inference |
| Orchestration | LangGraph | State machine graph for conversation flow |
| Memory | LangGraph SqliteSaver | Persistent per-thread checkpointing |
| Database | SQLite (chatbot.db) |
Local storage for chat history |
| Frontend | Streamlit | Full chat UI with sidebar |
| LLM Client | LangChain Groq | Groq API wrapper |
| Language | Python 3.10+ | Core language |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Streamlit Frontend β
β app.py β
β β
β Session State: β
β β’ message_history β current thread messages β
β β’ chat_threads β list of all thread metadata β
β β’ thread_id β active UUID thread β
β β’ total_tokens β running token estimate β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β chatbot.stream() / chatbot.get_state()
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LangGraph Backend β
β Backend.py β
β β
β StateGraph(ChatState) β
β START βββΊ chat_node βββΊ END β
β β
β chat_node: β
β β’ System prompt injection β
β β’ trim_messages (last 4000 tokens) β
β β’ llm.invoke() β
β β’ Token usage logging β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββ
β read / write per thread_id
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SQLite Checkpointer β
β chatbot.db β
β β
β Stores full message state per thread_id β
β Enables conversation persistence & resumption β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Groq API β
β llama-3.1-8b-instant β
β temp: 0.7 | max_tokens: 1024 | retries: 3 β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Webot/
β
βββ Backend.py # LangGraph graph, LLM setup, SQLite checkpointer
βββ app.py # Streamlit frontend β full chat UI
β
βββ chatbot.db # SQLite database (auto-created on first run)
β
βββ .env # API keys β never commit this
βββ .env.example # Safe template to share
βββ requirements.txt # Python dependencies
βββ .gitignore
βββ README.md
- Python 3.10+
- A free Groq API key
git clone https://github.com/cookieshop02/Webot.git
cd Webotpython -m venv venv
# macOS / Linux
source venv/bin/activate
# Windows
venv\Scripts\activatepip install -r requirements.txtcp .env.example .envEdit .env and add your Groq API key.
streamlit run app.pyOpen http://localhost:8501 β and start chatting! π
The SQLite database (
chatbot.db) is created automatically on first run. No setup needed.
# Required
GROQ_API_KEY=your_groq_api_key_here
# Optional β defaults to ./chatbot.db
DB_PATH=./chatbot.dbGet your free Groq API key at console.groq.com.
β οΈ Never commit your.envfile. It is already listed in.gitignore.
Commit this as .env.example:
GROQ_API_KEY=
DB_PATH=./chatbot.dbOnce the app is running at http://localhost:8501:
| Action | How |
|---|---|
| Start a new chat | Click β New Chat in the sidebar |
| Ask a question | Type in the chat box and press Enter |
| Switch conversations | Click any thread in the sidebar |
| Rename a thread | Click βοΈ next to the thread name |
| Delete a thread | Click ποΈ next to the thread name |
| Export a chat | Click β¬οΈ Export Chat in the sidebar |
| View token usage | Check the bottom of the sidebar |
Chats are automatically saved β close and reopen the app and your conversations will still be there.
- Added JWT authentication (register, login, protected routes)
- Added Docker support β run entire app with one command
- Migrated checkpointer to PostgreSQL
v3 β Migrated to PostgreSQL
- Added FastAPI layer as backend API
- Frontend now communicates via REST API
- Separated concerns β frontend, routes, schemas
- Initial release
- Streamlit frontend directly connected to LangGraph
Contributions are welcome!
# 1. Fork the repo
# 2. Create a feature branch
git checkout -b feature/your-feature-name
# 3. Commit your changes
git commit -m "Add: your feature description"
# 4. Push and open a Pull Request
git push origin feature/your-feature-nameThis project is licensed under the MIT License.
Built with β€οΈ by cookieshop02