Coder Social home page Coder Social logo

stalluri1 / microservices-jwt-zuul-kafka-docker Goto Github PK

View Code? Open in Web Editor NEW
1.0 0.0 2.0 39 KB

This repository helps beginners to get started with microservices , which has auth service which provides jwt token and api gateway to have jwt valdiation and to route the api requests.All this setup is dockerized as well.

Java 98.55% Dockerfile 0.20% Shell 1.25%
kafka docker microservices jwt-authentication authservice zuul eureka-server

microservices-jwt-zuul-kafka-docker's Introduction

Microservices-JWT-Zuul-Kafka-docker

This repository would help beginners understand how to start with simple microservices having an api gateway and registering all your microservices in eureka-server and dockerize of all it.

In this project we have
Auth Service which does users signup and signin
Users Service which provides apis to fetch all user details and details of any specific user who is signed up using Auth service.
Products Service which has got list of products users can order.(These products are hardcoded for now).
Orders Service which helps users to order for the products.
Invoices Service which gives out users invoice for the ordered prodcuts.
Zuul Service which serves as api gateway for all the above mentioned services.
EurekaServer which registers all our services.

Role Of Kafka
To send users information who registered via Auth Service to Users Service.
To send orders information placed via Orders Service to Invoices Service.

Databases
We use postgres:9.5 image.
Auth Service - authservicedb
Orders Service - orders
Invoices Service - invoices

How To Run?
Every microservice has got docker-maven-plugin in their pom. Reach the folder of each microservice and run
mvn clean install docker:build
Above command creates a dockerfile in the respecitve target folder of that service and the relative path of dockerfile is used in docker-compose.
Now cd into the docker folder in the repository here and run below commands.
sudo docker-compose build
sudo docker-compose -f docker-compose.yml up
Now you should be able to see all the services up and running

How To Use?
We need to get the ip of the docker container which is running Zuul api gateway
List all docker containers.
sudo docker container ps
Check for the id of the container which is runnig zuul image and inspect it to get the ip.
sudo docker inspect
Let the ip of the api gateway be ip_gateway.
Register an user - (POST) http://ip_gateway:8082/api/auth/users/signup
Payload
{ "name":"John", "username":"joe", "email":"[email protected]", "password":"qwedsa" }
Response
{ "usernameOrEmail":"[email protected]", "password":"qwedsa" }
Login of an user - (POST) http://ip_gateway:8082/api/auth/signin
Payload
{ "usernameOrEmail":"[email protected]", "password":"qwedsa" }
Response
{ "accessToken": "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNTQwMTI5NjI4LCJleHAiOjE1NDA3MzQ0Mjh9.fvwXFjTV7YlbkLItFg- kAVfXpW9ciwfM3Lgy2UIKdJNWFcuRFQPW6NKQz_xJ1YaLgpAdq-VRojMuQ6SIXiVHkA", "tokenType": "Bearer" }
To Access Any Apis Of Other Services We Should Be Using Above Obtained AccessToken
For example Authorization header would be
Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiaWF0IjoxNTQwMTI5NjI4LCJleHAiOjE1NDA3MzQ0Mjh9.fvwXFjTV7YlbkLItFg- kAVfXpW9ciwfM3Lgy2UIKdJNWFcuRFQPW6NKQz_xJ1YaLgpAdq-VRojMuQ6SIXiVHkA
Get all Products - (GET) http://ip_gateway:8082/products
Get all Users - (GET) http://ip_gateway:8082/users
Get user details of user with userId 1 - (GET) http://ip_gateway:8082/users?userId=1
Create order for an user with userId 1 - (POST)http://ip_gateway:8082/order?userId=1&productname=product3&price=1000
You can use any of the products obtained from above get all products api to place an order.
Get all orders of an user with userId 1 - (GET) http://ip_gateway:8082/orders?userId=1
Get all invoices of an user with userId 1 - (GET) http://ip_gateway:8082/invoices?userId=1

microservices-jwt-zuul-kafka-docker's People

Contributors

stalluri1 avatar stallurii avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.