Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Ecommerce Microservices

Node.js, Express, MongoDB, and RabbitMQ implementation of the Ecommerce Microservices.

Services

Service Port Responsibility
Customer Service 3001 Stores and exposes seeded customers
Product Service 3002 Stores and exposes seeded products
Order Service 3003 Validates checkout data, creates pending orders, calls payment
Payment Service 3004 Simulates payment and publishes transaction events
Transaction Worker n/a Consumes transaction events and stores transaction history

Run Locally

npm install
npm run build
docker compose -f docker.compose.yml up --build

Seed customer and product data:

npm run seed

Run tests:

npm test

Checkout Flow

  1. Customer submits an order request to POST /orders.
  2. Order Service validates the customer through Customer Service.
  3. Order Service validates product availability through Product Service.
  4. Order Service stores a pending order in MongoDB.
  5. Order Service calls Payment Service.
  6. Payment Service publishes transaction details to RabbitMQ.
  7. Transaction Worker consumes the event and persists transaction history.

Example Request

Place a checkout order by sending a POST to the Order Service. Use IDs from the seeded customer and product data.

POST http://localhost:3003/orders
Content-Type: application/json

{
  "customerId": "684a1f3e2c8b4d001f6e3a12",
  "productId": "684a1f3e2c8b4d001f6e3b45",
  "quantity": 2
}

Response 201 Created

{
  "success": true,
  "message": "Order created and payment initiated",
  "data": {
    "order": {
      "id": "684a2c1e9f0b3d001a7c5e88",
      "orderId": "a3f7b2d1-4c8e-4a2f-b6d9-1e3c7f5a9b20",
      "customerId": "684a1f3e2c8b4d001f6e3a12",
      "productId": "684a1f3e2c8b4d001f6e3b45",
      "quantity": 2,
      "amount": 24000,
      "orderStatus": "pending",
      "paymentStatus": "successful",
      "transactionId": "txn_9b3f1d72e4a85c60"
    },
    "paymentStatus": "successful",
    "transactionId": "txn_9b3f1d72e4a85c60"
  }
}

Note: Payment is simulated and always returns successful. The transaction is persisted asynchronously by the Transaction Worker via RabbitMQ.

Documentation

Architecture

API Reference

Data

Design

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages