GithubHelp home page GithubHelp logo

customer-service's Introduction

Customer service

  • all APIs need private key
  • service exposes 5 APIs examples below
  • all events againts aggreagte are stored are in event store
  • the current state of the customer is stored in JPA store
  • both data storages are backed by H2 and can be changed to another storage provider with configuration chages

design choice

  • Axon with spring
  • CQRS everything is either a command or a query and never both
  • event driven ensuring loose coupling in application, on attaching event bus shared across application instances it will ease horizontal scaling of application

creating customer

request

curl -X POST \
  http://localhost:8083/create \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: abcdef12345' \
  -d '{
	"points":100
}'

response

0f93221c-adb5-4705-8033-22abe248e590

add points

request

curl -X PUT \
  http://localhost:8083/points/add \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: abcdef12345' \
  -d '{
	"id":"0f93221c-adb5-4705-8033-22abe248e590",
	"points":10
}'

deduct points

request

curl -X PUT \
  http://localhost:8083/points/deduct \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: abcdef12345' \
  -d '{
	"id":"0f93221c-adb5-4705-8033-22abe248e590",
	"points":10
}'

requesting all changes to customer

request

curl -X GET \
  http://localhost:8083/events/0f93221c-adb5-4705-8033-22abe248e590 \
  -H 'X-API-Key: abcdef12345'

response

[{
	"id": "0f93221c-adb5-4705-8033-22abe248e590",
	"points": 100,
	"message": "initialize customer points",
	"creationTime": "2019-02-07T11:45:10.447Z"
}, {
	"id": "0f93221c-adb5-4705-8033-22abe248e590",
	"points": 10,
	"message": "add points",
	"creationTime": "2019-02-07T11:45:45.214Z"
}, {
	"id": "0f93221c-adb5-4705-8033-22abe248e590",
	"points": 10,
	"message": "deducted points",
	"creationTime": "2019-02-07T11:45:53.583Z"
}]

requesting current balance of customer points

request

curl -X GET \
  http://localhost:8083/points/0f93221c-adb5-4705-8033-22abe248e590 \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: abcdef12345' \
  -d '{
	"id":"264372c6-4c4b-4151-9d90-f4796d0a5e33",
	"points":10
}'

response

100

customer-service's People

Watchers

 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.