Code Monkey home page Code Monkey logo

ecommerce-microservices-spring-reactive-webflux's Introduction

Ecommerce Microservices Architecture

A complete ecommerce demo Implement based on Microservice Architecture Pattern using Spring Boot, Spring Cloud, Spring WebFlux, Postgresdb and Docker.

Abstract

In this project I didn't built independent microservices But i implemented microservices share the same database Why? Because I want to use database tools like ACID transactions, joins, bulk files imports, ... instead of network overhead for interprocess communication between microservices. I worked in a large project implemented based on microservices architecture we have a set of independent services and I used Spring Cloud Open Feign for inter-process communication (Which uses client side load balancer ribbon)

I'm planning to implement another version from project with independent microservices and communicate via feign.

I have split services into two types system and logical services.

Features

Secured, Authorized and Paginated endpoints.

Functional services

Authentication Service

Authorization Server for all other services which grants OAuth2 tokens for the backend resource services. All other secured services must set jwk uri for endpoint implemented on this service.

   security:
     oauth2:
       resourceserver:
         jwt:
           jwk-set-uri: ${JWKS_URL}

Endpoints

Method Path Description User authenticated
GET /.well-known/jwks System endpoint to get JSON Web Key Set (JWKS) is a set of keys containing the public keys that should be used to verify JWT token
POST /user/merchant Register new merchant account (with merchant role)
POST /user/client Register new client account (with client role)
GET /user Get current login user information ×

Product Service

Manage products information and inventory Endpoints

Method Path Description User authenticated Role
GET /list?page={page}&pageSize={pageSize} Get all products x any
GET /list/merchant?page={page}&pageSize={pageSize} Get products created by merchant x merchant,admin
POST /save Create new product x merchant
PUT /save Update existing product x merchant
GET /list/available?page={page}&pageSize={pageSize} Get available products with inventory > 0 × any
GET /list/not-available?page={page}&pageSize={pageSize} Get available products with inventory = 0 × any

Order Service

Manage products information and inventory Endpoints

Method Path Description User authenticated Role
GET /list/user?page={page}&pageSize={pageSize} Get login user orders x any
GET /{orderId} Get order by id x any
POST /save Create new order x client
PUT /save Update existing order x client

System Services

Core service to implement Netflix OSS design architecture and Services token security

Config Service

Provides configuration for all other services (centralize configuration for all services).
Details: Spring Cloud Config

Discovery Service

It allows automatic detection of network locations for service instances, which could have dynamically assigned addresses because of auto-scaling, failures and upgrades (Every service register in this service after running).
Details: Spring Cloud Netflix
Eureka server url: http://localhost:2222/

Gateway Service

Provide a proxy (routing) and client side load balancing via ribbon You can deploy multiple services for the same service and gateway will load balancing between them ( Simple scalability ) Details: Spring Cloud Gateway

Migration Service

Migrations service handle changes on database tables using flyway
To apply change on database please create file in this folder ecommerce-microservices/storage/migration/src/main/resources/flyway/migrations in this structure *__*.sql then apply this command

cd ecommerce-microservices/storage/migration # change it to your path
mvn clean package
docker-compose build
docker-compose up migration

Monitoring

Not completed require implement turbine service and any broker service (rabbitmq) But you can access start page from http://localhost:8000/hystrix

Run Project

Install maven and docker

mvn clean install 
docker-compse build
docker-compse up

# on the first run or after update sql migration on migration service
docker-compose up migration

Probably you got issues because docker caching refresh docker images by:

docker rm $(docker ps -a -q) -f
docker volume prune

Endpoints Documentations

Endpoints Docs

Contributions are welcome!

greatly appreciate your help. Feel free to suggest and implement improvements.

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.