Building ecommerce services
This is a working draft of specification for Ecommerce system build by microservices. The system has been working round some underlying features during 7 days in rush, but overall I did epxress my idea about how to build ecommerce system with high traffic and easy to expand horizontally. As well as loose couple and high cohesion of interaction between services.
Make sure you already installed Docker and Docker Compose on your machine.
Navigate to microservices folder
RUN docker-compose up -d
At first time, it will take time to build containers and other involving.
After all services are up, we need to create databases.
RUN docker-compose exec product-service sequelize-cli db:create --config config/database.json
RUN docker-compose exec product-service sequelize-cli db:migrate --config config/database.json
RUN docker-compose exec product-service sequelize-cli db:seed:all --config config/database.json
RUN docker-compose exec order-service sequelize-cli db:create --config config/database.json
RUN docker-compose exec order-service sequelize-cli db:migrate --config config/database.json
-
Product Service: 8080
-
Order Service: 8081
-
RabbitMQ: 15672
We can also access to rabbit browser to see whether message has been queued by enter address http://localhost:15672/ with username and password are guest Great! We have finished some stuff, let's go and play around.
Let me know a product catalog and its products with id equal 1:
curl -X POST "http://localhost:8080/graphql" \
-H "Content-Type: application/json" \
-d '{"query": "{catalog(id:1){name,description,products{name}}}"}'
Or I need to create an order:
curl -X POST "http://localhost:8081/graphql" \
-H "Content-Type: application/json" \
-d '{"query": "mutation {createOrder(total:100, status: PENDING,customer_account_id:1,orderlines:[{price:45,quantity:1,discount:0,unit:\"kg\",subtotal:45, product_description_id:1}]){total,status,orderlines{price,discount,unit,quantity}}}"}'
- Singleton
- Proxy pattern
- Node.js
- Docker && Docker Compose
- RabbitMQ
- GraphQL
- Mysql
- Run
docker-compose exec product-service npm test
- express-graphql
- graphql-scalars
- mysql2
- sequelize
- mocha
- grafana
- prometheus
- rabbitmq
- mysql
- Product Catalog
- Order Manager
I'm a software engineer, please contact me via email: khoa.zamioza@gmail.com or Linkedin https://www.linkedin.com/in/khoa-nguyen-software-engineer feel free to ask me.