Kafka Chat is a distributed chat application built using Kafka, FastAPI, and React. It supports real-time messaging, user authentication, and scalable architecture for handling multiple chat rooms and global communication.
- Consumer Service: Handles WebSocket connections and consumes messages from Kafka topics.
- Producer Service: Sends messages to Kafka topics.
- Services Module: Manages data repositories, models, and migration scripts.
- React Application: Provides a user interface for interacting with the Kafka Chat system.
- Python 3.9 or higher
- Node.js 16 or higher
- Kafka server running and accessible
- MongoDB server running and accessible
-
Clone the Repository:
git clone <repository-url> cd kafka-chat
-
Set Up Backend Services:
- Navigate to each backend service folder (
back/consumer,back/producer,back/services) and follow their respective README.md instructions.
- Navigate to each backend service folder (
-
Set Up Frontend:
- Navigate to
frontand follow the README.md instructions.
- Navigate to
-
Start Kafka and MongoDB: Ensure Kafka and MongoDB servers are running.
-
Start Backend Services:
- Run the consumer, producer, and services modules as described in their README.md files.
-
Start Frontend:
- Run the React application using
npm start.
- Run the React application using
-
Access the Application:
- Open http://localhost:3000 in your browser.
To simplify the setup and deployment of the Kafka Chat project, Docker is used to containerize all services. Follow these steps to run the project using Docker:
- Ensure Docker and Docker Compose are installed on your system.
- Verify that Docker is running.
-
Clone the Repository:
git clone <repository-url> cd kafka-chat
-
Build and Start the Containers:
- Run the following command in the root directory of the project (where
docker-compose.ymlis located):docker-compose up --build
- This command will build Docker images for all services (frontend, backend consumer, backend producer, and services) and start the containers.
- Run the following command in the root directory of the project (where
-
Verify the Containers are Running:
- Use the following command to check the status of the containers:
docker ps
- Ensure all required containers (frontend, consumer, producer, services, Kafka, MongoDB) are running.
- Use the following command to check the status of the containers:
-
Access the Application:
- Frontend: Open http://localhost:3000 in your browser.
- Backend Consumer: API available at http://localhost:8001.
- Backend Producer: API available at http://localhost:8000.
-
Stop the Containers:
- To stop all running containers, use:
docker-compose down
- To stop all running containers, use:
- The
docker-compose.ymlfile defines the services, networks, and volumes required for the project. - Ensure that Kafka and MongoDB services are properly configured and running within the Docker environment.
- Logs for each service can be viewed using:
Replace
docker-compose logs -f <service-name>
<service-name>with the name of the service (e.g.,consumer,producer,frontend,services).
Contributions are welcome! Please fork the repository and submit a pull request.
This project is licensed under the MIT License.