https://github.com/minhajul/nodejs-kafka
This project demonstrates a basic Node.js application integrating with Apache Kafka using Docker.
https://github.com/minhajul/nodejs-kafka
docker-compose kafka nodejs
Last synced: about 2 months ago
JSON representation
This project demonstrates a basic Node.js application integrating with Apache Kafka using Docker.
- Host: GitHub
- URL: https://github.com/minhajul/nodejs-kafka
- Owner: minhajul
- Created: 2025-06-22T06:34:48.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-29T17:06:50.000Z (about 1 year ago)
- Last Synced: 2025-06-29T18:21:02.285Z (about 1 year ago)
- Topics: docker-compose, kafka, nodejs
- Language: JavaScript
- Homepage:
- Size: 66.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Kafka Node.js App with Docker
This project demonstrates a basic Node.js application integrating with Apache Kafka using Docker.
## Prerequisites
- Docker and Docker Compose
- Node.js and npm
## Setup and Run
1. **Clone the repository:**
```bash
git clone https://github.com/minhajul/nodejs-kafka
cd nodejs-kafka
```
2. **Start Kafka, Zookeeper and Kafka UI using Docker Compose:**
To spin up the required Kafka infrastructure using Docker Compose, run:
```bash
docker-compose up -d
```
This command will start the following services in detached mode:
- **Zookeeper** – Coordinates and manages Kafka brokers
- **Kafka** – The distributed event streaming platform
- **Kafka UI** – A web-based user interface to inspect topics, messages, and consumers
You can access Kafka UI at: http://localhost:3000 (or your configured port)
3. **Install Node.js dependencies:**
```bash
npm install
```
4. **Run the server:**
```bash
npm run dev
```
This will launch the Express application and expose two API routes for producing events to Kafka topics:
| Endpoint | Description | Kafka Topic |
|---------------------------| ------------------------ | --------------- |
| `GET /api/create-order` | Produces an order event | `order-topic` |
| `GET /api/create-payment` | Produces a payment event | `payment-topic` |
Each endpoint sends a structured message to its corresponding Kafka topic using KafkaJS.
5. **Run the Kafka consumer (in a separate terminal):**
```bash
npm run start:consumers
```
This will start consuming order and payment from the `order-topic` and `payment-topic` and log them to the console.
### Made with ❤️ by [[minhajul](https://github.com/minhajul)]