Skip to content

Latest commit

 

History

20 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eCommerce Microservices Platform

A modular eCommerce system built using microservices architecture. Each service is independently deployable, scalable, and responsible for a single domain. The platform includes services for user management, product catalog, order handling, and payment processing.


Table of Contents

  1. Project Structure
  2. Microservices Overview
  3. How to Run
  4. API Authentication
  5. Features
  6. License

Project Structure

project-root/
├── user-service/
├── product-service/
├── order-service/
├── payment-service/
├── docker-compose.yml
└── README.md

Microservices Overview

1. User Service

  • Description: Handles user registration, login, token management, and role assignments. Acts as the identity provider for the platform.
  • Models:
    • BaseModel: id (auto-generated), deleted (boolean)
    • User: name, email, hashed password, isVerified, one-to-many with UserRole
    • Token: data (string), expiryAt (long), many-to-one with User
    • UserRole: value (string), many-to-one with User (via user_id)
  • Endpoints:
    • POST /register
    • POST /login
    • GET /me
  • Responsibilities: Authentication, authorization, token validation

2. Product Service

  • Description: Manages product catalog including categories and product information.
  • Models:
    • BaseEntity: id (auto-generated)
    • Category: title
    • Product: title, description, price, quantity, many-to-one with Category
  • Endpoints:
    • GET /products/{id}
    • GET /products
    • PUT /products/{id}
    • POST /products
    • GET /products/search
  • Security: All endpoints require a valid token from the UserService
  • Responsibilities: Catalog management, product search, category mapping

3. Order Service

  • Description: Handles order placement and manages the lifecycle of an order.
  • Models:
    • Order: id, userId, productIds, status, createdAt
    • OrderItem: productId, quantity, price, orderId
  • Endpoints:
    • POST /orders - Create new order
    • GET /orders/{id} - View order by ID
    • GET /orders - List orders by user
  • Security: Requires valid token from UserService
  • Responsibilities: Order creation, item grouping, tracking status

4. Payment Service

  • Description: Handles payment processing via Razorpay SDK.
  • Models:
    • Payment: id, orderId, amount, paymentStatus, transactionId
  • Endpoints:
    • POST /payments/create-order - Initiate a Razorpay order
    • POST /payments/verify - Verify a completed Razorpay payment
  • Integration: Uses Razorpay SDK with keys configured via environment variables
  • Security: Requires valid token and order validation before payment processing
  • Responsibilities: Payment initiation, confirmation, and linking to orders

How to Run

  1. Make sure Docker and Docker Compose are installed.

  2. Clone the repository and run:

    docker-compose up --build
  3. Each service will run on its own port:

  4. Access logs or debug using standard Docker logs command:

    docker-compose logs -f

API Authentication

  • Each request to Product, Order, and Payment services must include a valid token header:
    • Token: <access_token>
  • The token is issued by the User Service upon successful login or registration.
  • If a token is invalid or expired, services will return HTTP 401 Unauthorized.

Features

  • Fully modular and independent microservices
  • Centralized user authentication
  • Product search and category filtering
  • Secure order creation and tracking
  • Razorpay integration for secure payments
  • Token-based service-to-service authentication
  • Dockerized for easy development and deployment

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages