Skip to content

An interactive FastAPI-based chat system where users can chat with an AI summarizer assistant that automatically generates summaries of their input — similar to ChatGPT, but focused on summarization.

Notifications You must be signed in to change notification settings

Dhruvrana8/AI-Powered-Text-Summarizer-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 AI-Powered Chat Summarizer API

An interactive FastAPI-based chat system where users can chat with an AI summarizer assistant that automatically generates summaries of their input — similar to ChatGPT, but focused on summarization.


🚀 Features

  • 👤 User Management (register, login, authentication ready)
  • 💬 Chat Interface (each user can create multiple chat sessions)
  • 🧾 Message System (user ↔ assistant chat flow)
  • 🤖 AI Summarization (integrated Hugging Face transformer model)
  • Async & Fast (built with FastAPI and PostgreSQL)
  • 🔐 JWT Authentication Ready
  • 🧱 Modular Architecture (clean folder structure with routes, schemas, models)
  • 🐳 Docker Support (for easy deployment)

🏗️ Project Structure

.
├── .env
├── .gitignore
├── docker-compose.yml
├── Dockerfile
├── README.md
├── requirements.txt
└── src
    ├── init.py
    ├── api.py
    ├── auth
    │ ├── init.py
    │ ├── controller.py
    │ ├── models.py
    │ └── service.py
    ├── database
    │ ├── init.py
    │ └── core.py
    ├── entities
    │ ├── init.py
    │ ├── chats.py
    │ ├── message.py
    │ └── user.py
    ├── exceptions.py
    ├── logging.py
    ├── main.py
    ├── rate_limiter.py
    └── users
      ├── init.py
      ├── controller.py
      ├── models.py
      └── service.py

⚙️ Tech Stack

Layer Technology
Framework FastAPI
Database PostgreSQL
ORM SQLAlchemy
Model Hugging Face Transformers (Need to Decide)
Auth (optional) JWT with PyJWT / FastAPI Users
Deployment Docker + Uvicorn

🧩 Database Entities

🧍‍♂️ User Table

Field Type Description
id UUID Primary Key
email String Unique email
first_name String
last_name String
password_hash String
created_at DateTime

💬 Chat Table

Field Type Description
id UUID Primary Key
user_id UUID (FK → users.id) User who owns this chat
title String Chat title
summary String Summary of chat content
created_at DateTime Timestamp

📨 Message Table

Field Type Description
id UUID Primary Key
chat_id UUID (FK → chat.id) Chat reference
sender Enum('user', 'assistant') Who sent the message
content String Message text
created_at DateTime Timestamp

🧠 How It Works

  1. User registers or logs in.
  2. User creates a new chat.
  3. Each chat contains multiple messages between the user and the AI assistant.
  4. When the user sends a message:
    • It’s saved in the database.
    • FastAPI sends the content to a Hugging Face summarization model.
    • The model generates a summary and returns it as the assistant’s reply.
    • Both the user’s message and assistant’s response are stored in the DB.

🔥 API Endpoints

👤 User Routes

Method Endpoint Description Status
POST /users/register Register a new user Completed
POST /users/login Login user and return JWT token (optional) Completed
GET /users/me Get user details Completed

💬 Chat Routes

Method Endpoint Description Status
POST /chats/ Create a new chat Completed
GET /chats/{user_id} Get all chats for a user Completed
GET /chats/{chat_id} Get a single chat with messages Completed
DELETE /chats/{chat_id} Delete a chat (cascade deletes messages) Completed

📨 Message Routes

Method Endpoint Description
POST /messages/ Send a message to a chat (user message + AI summarizer reply)
GET /messages/{chat_id} Get all messages in a chat

🧰 Setup Instructions

1️⃣ Clone the Repository

git clone https://github.com/dhruvrana8/fastapi-ai-chat-summarizer.git
cd fastapi-ai-chat-summarizer

2️⃣ Create a Virtual Environment

python -m venv venv
source venv/bin/activate  # macOS/Linux
venv\Scripts\activate     # Windows

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Setup Database

DATABASE_URL=postgresql://user:password@localhost:5432/chat_db

Then create the tables:

python src/database/core.py

5️⃣ Run the App

uvicorn src.main:app --reload

About

An interactive FastAPI-based chat system where users can chat with an AI summarizer assistant that automatically generates summaries of their input — similar to ChatGPT, but focused on summarization.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published