Skip to content

Project designed to practice communication between microservices using Kafka

License

Notifications You must be signed in to change notification settings

Renan04lima/e-commerce-microservice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


ECOMMERCE MICROSERVICE

License ECOMMERCE MICROSERVICE

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

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

(back to top)

Built With

(back to top)

Checklist Features

  • 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

Getting Started

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.

Prerequisites

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

Installation

  1. Clone the repo
 git clone https://github.com/Renan04lima/e-commerce-microservice-kafka.git
  1. Run containers
 docker-compose up -d
  1. Create topics RECEIVE_ORDER, PAID_ORDER and BILLED_ORDER
 docker-compose exec kafka bash
 usr/bin/kafka-topics --create --topic <name_of_topic> --bootstrap-server localhost:9092
  1. Configure the User Pool, see more on https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-identity-pools.html
  2. Inicialize auth microservice
cd auth
npm i && sls deploy

(back to top)

Usage

  1. Start each microservice order, payment and billing, run on different terminal session
 cd <microservice_folder>
 node src/index.js
  1. Register and/or login to the auth microservice
  2. 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
    }'
  1. To see each topic consumer event of RECEIVE_ORDER, PAID_ORDER and BILLED_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

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License.

(back to top)

Contact

Gmail Badge

Linkedin Badge

(back to top)