Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/19eb/microservices-base-kafka
Nodejs project on microservices using Apache Kafka as messaging queue
https://github.com/19eb/microservices-base-kafka
apache-kafka api backend kafka kafkajs microservice microservice-architecture microservices node nodejs rest rest-api restful
Last synced: 2 days ago
JSON representation
Nodejs project on microservices using Apache Kafka as messaging queue
- Host: GitHub
- URL: https://github.com/19eb/microservices-base-kafka
- Owner: 19EB
- License: mit
- Created: 2022-12-08T10:41:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2022-12-11T13:13:55.000Z (almost 2 years ago)
- Last Synced: 2024-03-22T10:29:47.482Z (8 months ago)
- Topics: apache-kafka, api, backend, kafka, kafkajs, microservice, microservice-architecture, microservices, node, nodejs, rest, rest-api, restful
- Language: TypeScript
- Homepage:
- Size: 55.7 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# microservices-base-kafka
Basic microservices project that includes a gateway (api-gateway) and 3 microservices (user/product/client) and a messaging queue
This variation utilizes Kafka as the messaging queue so if one microservice goes down, it will receive messages when it gets back up.
### Prerequisites
- Install [Node.js](https://nodejs.org/en/)
- Install [Apache Kafka](https://kafka.apache.org/) or run it in a docker container ([How to](https://www.baeldung.com/ops/kafka-docker-setup))
### Installing
- Clone the repository
```
git clone https://github.com/19EB/microservices-base
```
- Install dependencies on api-gateway
```
cd api-gatewaynpm install
```- Install dependencies on each microservice (user, product and client)
```
cd services/npm install
```
### Environment variables
This project uses the following environment variables:
##### api-gateway
```
# Port
PORT=8000# User service
USER_SERVICE_URL='http://localhost:8001'# Client service
CLIENT_SERVICE_URL='http://localhost:8002'# Product service
PRODUCT_SERVICE_URL='http://localhost:8003'
```
##### microservice
```
# Database
DB=''# Service port
PORT=8001# Apache Kafka configuration
KAFKA_BROKER='localhost:29092'
```### Running the project
- If you plan on using Docker for running Kafka, I have included "kafka" folder that contains the docker-compose file with zookeeper and kafka.
```
cd kafka
docker-compose up -d
```- Start each microservice from its own directory
Development mode
```
cd services/npm run dev
```Production mode
```
cd services/npm start
```
- Start the api-gateway
```
cd api-gatewaynpm start
or
npm run dev
```Navigate to `http://localhost:8000`
### Endpoints
The project has couple endpoints to ping each other and one normal endpoint.
`http://localhost:8000/user/list`
`http://localhost:8000/user/ping-client`
`http://localhost:8000/user/ping-product`
`http://localhost:8000/client/list`
`http://localhost:8000/client/ping-user`
`http://localhost:8000/client/ping-product`
`http://localhost:8000/product/list`
`http://localhost:8000/product/ping-user`
`http://localhost:8000/product/ping-client`
## License
This project is licensed under the MIT License