Table of Contents
This project simulates a simple e-commerce microservice, using Kafka to carry out the communication between the order, payment, and billing services and use AWS Cognito for authentication
-
Version 1.0.0
- Should have a microservice responsible for orders
- Should have a microservice responsible for payment
- Should have a microservice responsible for billing
- Microservices must communicate using Apache Kafka
-
Version 2.0.0
- Should have a microservice responsible for authentication
- Should be possible register a user using AWS Cognito
- Should be possible to do login using AWS Cognito
- Should have authentication to access POST /orders
This is an example of how you may give instructions on setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
- docker and docker compose
- NPM
- Serverless Framework
- AWS Cognito
- Clone the repo
git clone https://github.com/Renan04lima/e-commerce-microservice-kafka.git
- Run containers
docker-compose up -d
- Create topics
RECEIVE_ORDER
,PAID_ORDER
andBILLED_ORDER
docker-compose exec kafka bash
usr/bin/kafka-topics --create --topic <name_of_topic> --bootstrap-server localhost:9092
- Configure the User Pool, see more on https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html
- Inicialize auth microservice
cd auth
npm i && sls deploy
- Start each microservice
order
,payment
andbilling
, run on different terminal session
cd <microservice_folder>
node src/index.js
- Register and/or login to the auth microservice
- Send request
curl --request POST \
--url http://localhost:3001/orders \
--header 'Authorization: Bearer <ID_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"product_name": "book",
"price": 49.99
}'
- To see each topic consumer event of
RECEIVE_ORDER
,PAID_ORDER
andBILLED_ORDER
, run on different terminal session
docker-compose exec kafka bash
usr/bin/kafka-console-consumer --topic <name_of_topic> --from-beginning --bootstrap-server localhost:9092
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License.