FastChat is a high-performance, real-time chat application that demonstrates the power of WebSockets and Redis for scalable messaging. Built with modern web technologies, it offers a seamless chatting experience that can easily scale to handle a large number of concurrent users.
- βοΈ Real-time messaging using WebSockets
- π₯ Live user
connection count
across multiple instances using Redis Pub/Sub - π Horizontally scalable architecture with multiple backend instances
- βοΈ Load balancing with Caddy as a reverse proxy
- π₯οΈ Sleek, responsive UI built with Next.js and Tailwind CSS
- π³ Dockerized for easy deployment and scaling
- β‘ Fastify: Fast and low overhead web framework
- π Socket.io: Real-time bidirectional event-based communication
- ποΈ Redis (Upstash): In-memory data structure store, used as a database, cache, and message broker
- π³ Docker & docker-compose: Containerization and multi-container Docker applications
- π Caddy: Open source web server with automatic HTTPS
Frontend π¨
- βοΈ Next.js: React framework for production-grade applications
- π Tailwind CSS: Utility-first CSS framework
- π Socket.io-client: Client-side library for real-time web applications
- Node.js (v18 or later)
- pnpm || yarn || npm
- Docker and docker-compose
- Redis instance (Upstash account)
- Make (usually pre-installed on most systems)
-
Clone the repository:
git clone https://github.com/mutasim77/fast-redis-chat.git cd fast-redis-chat
-
Set up environment variables:
-
Create a
.env
file in the server directory with:UPSTASH_REDIS_REST_URL=rediss://.....
Replace
...
with your actual Upstash Redis URL. -
Create a
run.sh
file in the server directory and populate it with:docker-compose down export UPSTASH_REDIS_REST_URL=rediss://... export CORS_ORIGIN=http://localhost:3000 # or your specific CORS origin docker-compose -p chat_project up -d --build
Replace
...
in the UPSTASH_REDIS_REST_URL with your actual Upstash Redis URL. -
Make sure to make the
run.sh
file executable by running:chmod +x run.sh
- Use the Makefile to install dependencies and run the application:
# Install dependencies for both client and server
make install
# Run both the backend and frontend
make run
# Or simply just run
make all
This will start the backend server using the
run.sh
script and the frontend development server.
Once you've run make run
or make all
:
- Open your browser and navigate to
http://localhost:3000
- Click Start Chatting
- Start sending messages in real-time!
To stop the application, press Ctrl+C in the terminal where you ran
make run
. To clean up the project (remove node_modules, etc.), you can run:
make clean
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with β€οΈ by Mutasim