- Purpose: All requests from the outside world pass through the API Gateway. This provides a single entry point and eliminates the need for each microservice to be exposed directly to the internet.
- Usage: It receives incoming requests and routes them to the correct microservice. For example, a
/customersrequest is routed to the Customer service,/productsto the Product service, and/ordersto the Order service.
- Purpose: Manages customer information.
- Usage: Stores customer data in a MongoDB database. Operations such as creating and updating customer records are handled by this service.
- Purpose: Manages product information.
- Usage: Stores product data in a MongoDB database. Operations like adding, updating, and listing products are performed through this service.
- Purpose: Manages order processes.
- Usage: Handles order creation and stores order data. When an order is created, it fetches product information from the Product service and customer information from the Customer service.
- Purpose: Manages payment transactions.
- Usage: When an order is placed, this service processes the payment and confirms it. It then sends payment confirmation messages to the Notification service via Kafka.
- Purpose: Sends notifications.
- Usage: Listens to asynchronous messages from the Payment and Order services and sends notifications (such as emails) to the customer about the order status.
- Purpose: Enables asynchronous communication between microservices.
- Usage: Delivers confirmation messages from the Payment and Order services to the Notification service. This allows services to operate independently without tight coupling.
- Purpose: Distributed tracing and performance monitoring.
- Usage: Tracks requests across services and helps analyze their performance. It shows which services respond and how long they take.
- Purpose: Service discovery and registration.
- Usage: Helps identify where each microservice is running. Each microservice registers itself with this server, and others use it to locate services.
- Purpose: Centralized configuration management.
- Usage: Manages configuration files for all microservices from a central location. For example, when a database URL changes, it can be updated in one place.
- Purpose: Acts as the database.
- Usage: A NoSQL database used by the Customer, Product, Order, and Notification services to store their data.
- Purpose: Containerization of applications.
- Usage: Ensures microservices run the same way across different environments. Each service can be run inside a Docker container.
Scenario: A user named Joe decides to sign up on the e-commerce website.
- Joe enters his name, surname, and email to register on the site.
- A new record is added to the
Customertable with Joe’s information. - Joe also enters his address (e.g.,
street: "Atatürk Cad.",houseNumber: "10",zipCode: "34560"). - The address is stored in the
Addresstable and linked to theCustomertable.
Scenario: Joe browses products and adds the ones he’s interested in to his cart.
- Joe browses various categories, e.g., selects the “Electronics” category from the
Categorytable. - Products in that category are fetched from the
Producttable (e.g., “Laptop”, “Smartphone”). - Joe adds a laptop to his cart. Product details like name, description, price, and available quantity come from the
Producttable.
Scenario: Joe decides to buy the products in his cart.
- Joe proceeds to checkout. An order is created and stored in the
Ordertable (e.g.,orderDate,reference). - Each product in the order is recorded in the
OrderLinetable (e.g.,id: 1,quantity: 1). - The relationship between the order and its order lines shows how many of each product Joe ordered.
Scenario: Joe enters his credit card details to pay for the order.
- Once Joe submits his card details, the payment information is saved in the
Paymenttable (e.g.,reference,amount,status). - This payment is linked to the related order record, showing which order the payment belongs to.
Scenario: Joe’s order is successfully completed and he receives a notification.
- When the order is completed, the system automatically sends Joe an email notification.
- This notification is stored in the
Notificationtable with details likecontent,sender,recipient, anddate. - The notification is linked to the relevant order.
Scenario: Joe’s order is shipped and delivered to the provided address.
- The order status is updated and shipping information is added.
- Product stock quantities are updated (
availableQuantityis reduced). - Joe is notified that his order has been delivered, and this is recorded in the
Notificationtable.