A complete chatbot solution with a LangGraph backend and React frontend. Chat with an AI powered by Groq's Llama model, manage multiple conversations, and upload PDFs for context.
ReactUI/
βββ Backend/
β βββ main.py - FastAPI server
β βββ index.py - LangGraph chatbot logic
β βββ .env - API keys and config
β βββ chatbot.db - SQLite conversation storage
βββ Frontend/
β βββ public/
β βββ src/
β βββ package.json
β βββ README.md - Frontend documentation
βββ run-all.bat - Start both servers
βββ run-backend.bat - Start only backend
βββ run-frontend.bat - Start only frontend
βββ SETUP_GUIDE.md - Detailed setup instructions
βββ README.md - This file
Double-click run-all.bat in the ReactUI folder. This will:
- Start the backend server on http://localhost:8000
- Install frontend dependencies (first time only)
- Start the frontend on http://localhost:3000
- Double-click
run-backend.bat- starts the API server - Then double-click
run-frontend.bat- starts the React app
Backend:
cd Backend
uvicorn main:app --reloadFrontend:
cd Frontend
npm install # First time only
npm start- π€ AI-powered chatbot using Groq's Llama 3.1 model
- π§΅ Multi-threaded conversations with SQLite persistence
- π PDF text extraction and processing
- π Streaming message responses
- β‘ CORS-enabled for React frontend
- π¬ Real-time chat interface
- π§΅ Conversation thread management
- π PDF upload with drag-and-drop
- π± Fully responsive design
- β¨ Beautiful gradient UI with smooth animations
- β¨οΈ Keyboard shortcuts (Shift+Enter for new line)
- FastAPI - Modern Python web framework
- LangGraph - Composable agent framework
- Langchain - LLM orchestration
- Groq - API for Llama 3.1 model
- SQLite - Persistent conversation storage
- pypdf - PDF text extraction
- React 18 - UI framework
- Axios - HTTP client
- CSS3 - Modern styling with gradients & animations
- Windows 10/11 (or WSL)
- Node.js 16+ (https://nodejs.org/)
- Python 3.8+ (https://www.python.org/)
- Groq API Key (free at https://console.groq.com/)
Create a .env file in the Backend folder with:
GROQ_API_KEY=your_api_key_here
Get your free API key from: https://console.groq.com/
Edit Frontend/src/App.js if your API runs on a different URL:
const API_BASE_URL = 'http://localhost:8000'; // Change if needed| Method | Endpoint | Description |
|---|---|---|
| GET | /threads |
Get all conversation threads |
| POST | /chat |
Send a message (params: thread_id, message) |
| POST | /upload-pdf |
Upload and extract PDF text |
- main.py - FastAPI app with routes for chat, threads, and PDF upload
- index.py - LangGraph chat node setup and thread management
- chatbot.db - SQLite database storing conversation history
- App.js - Main component handling state and API calls
- components/ChatWindow.js - Chat message display and input
- components/ThreadList.js - Thread sidebar
- components/PDFUpload.js - PDF upload widget
- Start the application using one of the methods above
- Type a message in the chat input box
- Press Enter or click Send to get a response
- Create new chat using the "+ New Chat" button
- Upload PDF by clicking the PDF button or dragging a file
- Switch conversations by clicking thread names in the sidebar
Enter- Send messageShift + Enter- New line in message- You can edit the code to add more shortcuts if needed
- Check Python is installed:
python --version - Install dependencies:
pip install -r requirements.txt - Verify Groq API key is set in .env file
- Check port 8000 is not in use
- Check Node.js is installed:
node --version - Delete node_modules:
rmdir /s Frontend\node_modules - Reinstall:
npm installin Frontend folder - Check port 3000 is not in use
- Ensure backend is running on http://localhost:8000
- Check CORS middleware is enabled in main.py (should be by default)
- Verify internet connection (API calls go to Groq)
- Check Groq API key is valid
- Check backend logs for errors
Conversations are stored in Backend/chatbot.db (SQLite):
- Automatically created on first run
- Stores message history per thread_id
- Can be deleted to reset all conversations
- Edit
Backend/index.pyorBackend/main.py - Server will auto-reload (uvicorn --reload)
- Refresh frontend in browser
- Edit files in
Frontend/src/ - Dev server auto-reloads
- Changes appear in browser immediately
- Set environment variable:
GROQ_API_KEY - Point to your API URL in frontend
- Update CORS allowed origins in main.py
- Update
API_BASE_URLin App.js to production URL - Run:
npm run build - Deploy the
build/folder
- Caching: Conversations are persisted in SQLite
- Streaming: Messages stream from Groq API for faster perceived response
- Responsive: React components re-render only when needed
- Lazy Loading: Import components as needed
- Never commit
.envfile with real API keys - The current setup has
CORS allow_origins=["*"]- restrict in production - Store sensitive API keys in environment variables only
- Use HTTPS in production
- User authentication
- Chat history export
- Dark mode toggle
- Message search
- Image upload support
- Text-to-speech
- Custom AI models selection
- Admin dashboard
- LangGraph Docs: https://langchain-ai.github.io/langgraph/
- FastAPI Docs: https://fastapi.tiangolo.com/
- React Docs: https://react.dev/
- Groq API: https://console.groq.com/
This project is open source and available under the MIT License.
Created with β€οΈ for seamless AI conversations
Happy Chatting! π
For detailed setup instructions, see SETUP_GUIDE.md