A modern, real-time chat application built with React, FastAPI, and WebSocket technology. Features user authentication, real-time messaging, and online user tracking.
- Real-time messaging with WebSocket connections
- User authentication using custom JWT
- Online user tracking and user list
- Responsive design with modern UI
- System messages for user join/leave notifications
- React 19 - Modern React with hooks
- Vite - Fast build tool and dev server
- JWT - Authentication and user management
- FastAPI - Modern Python web framework
- SQLAlchemy - Database ORM
- PostgreSQL - Primary database
- Redis - Caching and session management
- WebSocket - Real-time bidirectional communication
- Alembic - Database migrations
- fastapi-limiter - Rate limiting backed by Redis
- Docker and Docker Compose installed
- JWT for authentication
-
Clone the repository
git clone https://github.com/mikhailofff/simple-chat-fastapi.git cd simple-chat-fastapi -
Set up environment variables
Copy the example environment files and configure them:
cp backend/src/.env.example backend/src/.env
Then edit
.envfile with your actual values. -
Start the application
docker compose up --build
-
Access the application
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
docker compose downsimple-chat-fastapi/
βββ backend/
β βββ src/
β β βββ app.py # FastAPI application (lifespan, middleware, routers)
β β βββ routes/ # API routes (e.g., chat endpoints, WebSocket)
β β βββ database/ # DB engine, sessions, CRUD helpers, models
β β β βββ models/ # SQLAlchemy models
β β βββ core/ # Core utilities (e.g., Redis client)
β β βββ schemas/ # Pydantic schemas
β β βββ dependencies.py # FastAPI dependencies (auth helpers, etc.)
β β βββ config.py # Settings and config
β β βββ utils.py # JWT utilities and helpers
β β βββ .env.example # Environment variables template
β β βββ .env # Your environment variables (not in git)
β βββ migrations/ # Alembic migration scripts
β βββ logging_config.ini # Centralized Python logging configuration
β βββ server.py # ASGI app export; loads logging config
β βββ Dockerfile # Backend container
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ hooks/ # Custom React hooks
β βββ package.json # Node.js dependencies
β βββ Dockerfile # Frontend container
βββ docker-compose.yaml # Multi-container setup
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -m 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Happy Chatting! π