** About the Project
This project is an AI chatbot backend developed to learn how modern AI applications are built.
The chatbot uses the Groq API to generate responses while FastAPI handles the backend API. Instead of storing chat history in a JSON file, conversations are saved in a SQLite database using SQLAlchemy, allowing the chatbot to remember previous messages within the same conversation.
The project includes a responsive web interface built with HTML, CSS, and JavaScript. Users can create conversations, continue previous chats, and interact with the AI through a modern chat interface.
** Features
- AI-powered chatbot
- Dynamic conversation memory
- Multiple conversations
- FastAPI backend
- SQLite database
- SQLAlchemy ORM
- Organized project structure (Routers, CRUD, Models, Schemas)
- Swagger UI for testing APIs
- Modern responsive web interface
- Conversation history sidebar
- Continue previous conversations
| Technology | Purpose |
|---|---|
| Python | Programming Language |
| FastAPI | Backend Framework |
| Groq API | AI Response Generation |
| SQLAlchemy | ORM |
| SQLite | Database |
| Pydantic | Data Validation |
| Uvicorn | ASGI Server |
Clone the repository
git clone https://github.com/Areesha643/AI-chatbot-fastapi.gitMove into the project folder
cd ai-chatbot-fastapiCreate a virtual environment
python -m venv venvActivate the virtual environment
Windows
venv\Scripts\activateLinux/macOS
source venv/bin/activateInstall dependencies
pip install -r requirements.txtCreate a .env file
GROQ_API_KEY=your_api_keyRun the server
uvicorn main:app --reloadOpen the chatbot
http://127.0.0.1:8000
API Documentation (Swagger UI)
http://127.0.0.1:8000/docs
Start a new conversation
{
"message": "Hello!"
}Example response
{
"conversation_id": 1,
"reply": "Hello! How can I help you today?"
}Continue the conversation
{
"conversation_id": 1,
"message": "What is my name?"
}This project helped me understand:
- Building REST APIs with FastAPI
- Integrating AI models using the Groq API
- SQLAlchemy ORM
- Database relationships
- CRUD operations
- Organizing backend projects
- Managing conversation memory
- Environment variables
- Clean backend architecture
- User authentication
- Message timestamps
- Delete conversations
- Docker support
- PostgreSQL integration
Author
Developed as a personal learning project while exploring AI integration and backend development with FastAPI.



