Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Chatbot API

A simple AI chatbot backend built with FastAPI, Groq API, SQLAlchemy, and SQLite.

Python FastAPI SQLAlchemy SQLite License


** 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

Tech Stack

Technology Purpose
Python Programming Language
FastAPI Backend Framework
Groq API AI Response Generation
SQLAlchemy ORM
SQLite Database
Pydantic Data Validation
Uvicorn ASGI Server

📸 Screenshots

Chat Response

Chat Chat

Database

Database


Project Structure

Project Structure

Installation

Clone the repository

git clone https://github.com/Areesha643/AI-chatbot-fastapi.git

Move into the project folder

cd ai-chatbot-fastapi

Create a virtual environment

python -m venv venv

Activate the virtual environment

Windows

venv\Scripts\activate

Linux/macOS

source venv/bin/activate

Install dependencies

pip install -r requirements.txt

Create a .env file

GROQ_API_KEY=your_api_key

Run the server

uvicorn main:app --reload

Open the chatbot

http://127.0.0.1:8000

API Documentation (Swagger UI)

http://127.0.0.1:8000/docs

API Example

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?"
}

What I Learned

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

Future Improvements

  • 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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages