This is a real-time chat application built with FastAPI, SQLAlchemy, and WebSockets. It supports user authentication, private messaging, group chats, and message encryption.
- User authentication (signup and login)
- Real-time private messaging
- Group chats
- Message encryption
- Persistent message storage with SQLAlchemy
- Python 3.10
- Docker (for deployment)
- AWS CLI (for deployment)
git clone https://github.com/yousafbinfarrukh/fastapi-chat-server.git
cd fastapi-chat-server
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
pip install -r requirements.txt
Generate encryption key and secret key using generate_encryption_key.py
and generate_secret_key.py
:
Create a .env
file in the root directory and add the following environment variables:
SECRET_KEY=your_jwt_secret_key
ENCRYPTION_KEY=your_generated_encryption_key
Run the following command to create the database tables:
python -m app.main
uvicorn app.main:app --reload
docker build -t chat-api .
docker run -it -p 8000:8000 chat-api
- POST /signup: Register a new user
- POST /login: Login a user
- /ws: WebSocket endpoint for real-time chat
- POST /create_group: Create a new group
- POST /join_group: Join a group
- POST /leave_group: Leave a group
This project is licensed under the MIT License.