Skip to content

Basic Implementation of event-driven-micro services with saga patterns.

License

Notifications You must be signed in to change notification settings

Dovakiin0/microservices-saga-grpc-nodejs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Ask Me Anything ! Generic badge

Microservices-Saga-Nodejs-gRPC

A basic implementation of microservices with event based system to create saga architecture.
Currently, this has no UI and you can only test it with postman or any alternative.
Postgres is used for database.

First fork this repository
or clone directly with HTTPS

git clone https://github.com/Dovakiin0/microservices-saga-grpc-nodejs.git

or SSH

git clone git@github.com:Dovakiin0/microservices-saga-grpc-nodejs.git

Fill in the environment variable for your respective postgres details inside docker-compose.yml.
Currently for two services two postges database are used in port 5433, 5434

Go inside each service then run

npm install

for migration, cd to auth_service and todo_service then run

npx sequelize-cli db:migrate

Alternately (preferable),

docker exec -it <container_id_of_service> bash

npx sequelize-cli db:migrate

To start:

docker-compose up -d

To stop:

docker-compose down

Routes are as follows:

POST /auth/register - create User
POST /auth/login - login for generating JWT token
PUT /auth/update/:id - update username for a user

POST /v1/todo - create a Todo (Requires token)
GET /v1/todo - Get the list of TODO
PUT /v1/todo/:id - update a TODO

All services runs independently.
Client_service acts as a API gateway for communicating with two services.

EVENTS

RabbbitMq is used for event management. Only one event is published and subscribed throughout this app.
when you change your username, auth_service throws an event called USERNAME_CHANGE_EVENT and it is subscribed by the todo_service which then changes all the username in its respective TODOs.


Feel free to tweak the code according to your needs, and don't feel hesitated to open any issue or advice me any improvements. I'll be sure to respond to you actively.

About

Basic Implementation of event-driven-micro services with saga patterns.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published