Git Product home page Git Product logo

vis-lab's Introduction

MIT license Travis Build Status

Distributed Information Systems Laboratory aka vis-lab

Splitting a monolithic web shop application, running on a Tomcat into small domain-driven microservices with Spring Boot and Docker. This project is part of the masters course 'Distributed Information Systems' at the University of Applied Sciences (Karlsruhe).

Prerequisites

Starting

Legacy System

  • Start Docker daemon
  • Check out the project, export variables and simply run the script:
$ chmod +x run_legacy.sh
$ ./run_legacy.sh
  • Builds the web app war, packs it into a docker tomcat8 container, and sets the user tomcat with password admin for the Management Console at http://localhost:8888/
  • Inits the MySQL Database docker container with the db user defined in hibernate.cfg.xml
  • Sets up both containers and make the legacy webshop available under http://localhost:8888/EShop-1.0.0/

Microservice Architecture

  • Start Docker daemon
  • Check out the project and simply run the script:
# Build all microservices, create docker images and start them
$ ./run_microservices.sh
# for shutting down
$ ./shutdown_microservices.sh

Useful links

  • Eureka service registry: http://localhost:8761/
  • Zuul Gateway routes: http://localhost:8765/routes

Note: run e.g. curl -D- -X GET localhost:8765/category first, so hystrix produces stream data

  • Local Monitoring Dashboard for Composite: http://localhost:8084/hystrix -> enter url http://localhost:8765/hystrix.stream
  • Monitoring Dashboard Service: http://localhost:7979/hystrix
    • cat comp: http://categorycompositeservice:8080/hystrix.stream
    • gateway: http://api-gateway:8765/hystrix.stream

curl statements for testing:

  1. Obtain the access token and refresh token for the grand_type=password via one of the three methods:
  • curl -v -H "Authorization: Basic $(echo -n 'acme:acmesecret' | base64)" http://localhost:8765/uaa/oauth/token -d grant_type=password -d username=admin -d password=admin
  • curl -v -u acme:acmesecret http://localhost:8765/uaa/oauth/token -d grant_type=password -d username=admin -d password=admin
  • curl -v http://acme:acmesecret@localhost:8765/uaa/oauth/token -d grant_type=password -d username=admin -d password=admin
  1. Save the obtained access token in the ACCESS_TOKEN env var: export ACCESS_TOKEN=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODQ0ODExM...

  2. Perform requests

  • curl -v 'http://localhost:8765/category' -i -X GET -H 'Content-type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN"
  • curl -v 'http://localhost:8765/category' -i -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN" -d '{"name":"TestCategory"}'
  • curl -v 'http://localhost:8765/product' -i -X GET -H 'Content-type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN"
  • curl -v 'http://localhost:8765/product' -i -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN" -d '{"name":"NewProduct", "price":"1.00", "category":"1", "details":"fancy details"}'
  • curl -v 'http://localhost:8765/user/admin' -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN"
  • curl -v 'http://localhost:8765/user/register' -i -X POST -H 'Content-Type: application/json' -d '{"username":"jdoe", "firstname":"John", "lastname":"Doe", "password":"s3cr3t"}'

Debugging:

Check MySQL contents

  • Connect to container: docker exec -it <#containerId> bash
  • Connect to db: mysql -h localhost -D webshop -u webshopuser -p240b2c6d58ff2ce2f508b49f

API Documentation

The documentation of the services

  • CategoryService
  • ProductService
  • UserService is available at the api-gateway: http://localhost:8765/docs/api-guide.html

Notes

If you change the user and password of the MySQL database, you should run

$ docker-compose -f docker-compose-legacy.yml rm -v
$ rm -rf .data

Details can be found here

vis-lab's People

Contributors

mavogel avatar felixmohr avatar jinghualin avatar rudy-marquez avatar

Watchers

James Cloos avatar  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.