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.
- 👤 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)
.
├── .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
| 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 |
| Field | Type | Description |
|---|---|---|
| id | UUID | Primary Key |
| String | Unique email | |
| first_name | String | |
| last_name | String | |
| password_hash | String | |
| created_at | DateTime |
| 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 |
| 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 |
- User registers or logs in.
- User creates a new chat.
- Each chat contains multiple messages between the user and the AI assistant.
- 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.
| 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 |
| 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 |
| 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 |
git clone https://github.com/dhruvrana8/fastapi-ai-chat-summarizer.git
cd fastapi-ai-chat-summarizerpython -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windowspip install -r requirements.txtDATABASE_URL=postgresql://user:password@localhost:5432/chat_dbThen create the tables:
python src/database/core.py5️⃣ Run the App
uvicorn src.main:app --reload