Skip to content

adityaShar24/ecommerce-microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

# πŸš€ Ecommerce Microservices

A scalable and resilient e-commerce platform built with microservices architecture.

Streamlining online shopping with independent, manageable services.

![License](https://img.shields.io/github/license/adityaShar24/ecommerce-microservices)
![GitHub stars](https://img.shields.io/github/stars/adityaShar24/ecommerce-microservices?style=social)
![GitHub forks](https://img.shields.io/github/forks/adityaShar24/ecommerce-microservices?style=social)
![GitHub issues](https://img.shields.io/github/issues/adityaShar24/ecommerce-microservices)
![GitHub pull requests](https://img.shields.io/github/issues-pr/adityaShar24/ecommerce-microservices)
![GitHub last commit](https://img.shields.io/github/last-commit/adityaShar24/ecommerce-microservices)

<img src="https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white" />
<img src="https://img.shields.io/badge/Docker-2CA5E0?style=for-the-badge&logo=docker&logoColor=white" />
<img src="https://img.shields.io/badge/Flask-000000?style=for-the-badge&logo=flask&logoColor=white" />
<img src="https://img.shields.io/badge/PostgreSQL-316192?style=for-the-badge&logo=postgresql&logoColor=white" />

## πŸ“‹ Table of Contents

- [About](#about)
- [Features](#features)
- [Demo](#demo)
- [Quick Start](#quick-start)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [API Reference](#api-reference)
- [Project Structure](#project-structure)
- [Contributing](#contributing)
- [Testing](#testing)
- [Deployment](#deployment)
- [FAQ](#faq)
- [License](#license)
- [Support](#support)
- [Acknowledgments](#acknowledgments)

## About

This project aims to create a robust and scalable e-commerce platform using a microservices architecture. It is designed to handle high traffic, provide fault tolerance, and allow for independent scaling and deployment of individual services. This architecture enables easier maintenance, faster development cycles, and greater flexibility in choosing the right technology for each service.

The platform addresses the challenges faced by monolithic e-commerce applications, such as slow deployment times, scalability bottlenecks, and difficulty in adopting new technologies. By breaking down the application into smaller, independent services, we can improve overall system resilience and agility. The target audience includes developers, architects, and businesses looking to build or migrate to a modern, scalable e-commerce solution.

Key technologies include Python, Flask, PostgreSQL, and Docker. The architecture consists of several microservices, such as a product catalog service, an order management service, a user authentication service, and a payment processing service. Each service is responsible for a specific business function and communicates with other services through APIs or message queues. This modular design allows for independent development, testing, and deployment of each service, making the platform more manageable and scalable.

## ✨ Features

- 🎯 **Product Catalog**: Browse and search products with detailed information.
- πŸ›’ **Shopping Cart**: Add, remove, and manage items in the shopping cart.
- πŸ‘€ **User Authentication**: Secure user registration, login, and profile management.
- πŸ’³ **Payment Processing**: Integrate with payment gateways for secure transactions.
- πŸ“¦ **Order Management**: Track order status, manage shipments, and handle returns.
- ⚑ **Scalability**: Designed for horizontal scaling to handle high traffic loads.
- πŸ”’ **Security**: Implements security best practices to protect user data and prevent fraud.
- πŸ› οΈ **Extensible**: Modular design allows for easy addition of new features and services.

## 🎬 Demo

πŸ”— **Live Demo**: [https://your-demo-url.com](https://your-demo-url.com)

### Screenshots
![Product Catalog](screenshots/product-catalog.png)
*Product catalog showcasing various items for sale*

![Shopping Cart](screenshots/shopping-cart.png)
*Shopping cart interface displaying selected items and total cost*

## πŸš€ Quick Start

Clone and run the services using Docker Compose:

```bash
git clone https://github.com/adityaShar24/ecommerce-microservices.git
cd ecommerce-microservices
docker-compose up --build

Open http://localhost to view the application in your browser (adjust port if needed).

πŸ“¦ Installation

Prerequisites

  • Docker and Docker Compose
  • Python 3.8+ (for local development)
  • PostgreSQL (for local development)

Option 1: Docker Compose (Recommended)

  1. Clone the repository:
git clone https://github.com/adityaShar24/ecommerce-microservices.git
cd ecommerce-microservices
  1. Configure environment variables (see Configuration section).

  2. Run Docker Compose:

docker-compose up --build

Option 2: Local Development (for individual services)

  1. Clone the repository:
git clone https://github.com/adityaShar24/ecommerce-microservices.git
cd ecommerce-microservices
  1. Navigate to the service directory (e.g., cd product-catalog-service).

  2. Create a virtual environment:

python3 -m venv venv
source venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables (see Configuration section).

  2. Run the service:

python app.py

πŸ’» Usage

Accessing the Services

Once the services are running, you can access them through their respective ports:

  • Product Catalog Service: http://localhost:5000 (example)
  • Order Management Service: http://localhost:5001 (example)
  • User Authentication Service: http://localhost:5002 (example)

Refer to the API Reference for specific endpoints and usage examples.

Example: Fetching Products from the Product Catalog Service

import requests

response = requests.get('http://localhost:5000/products')
products = response.json()

print(products)

βš™οΈ Configuration

Environment Variables

Create a .env file in each service directory based on the .env.example file:

# Database configuration
DATABASE_URL=postgresql://user:password@host:port/database

# Service port
PORT=5000

# Debug mode
DEBUG=True

# API Keys
PAYMENT_GATEWAY_API_KEY=your_payment_gateway_api_key

Example .env.example file:

DATABASE_URL=postgresql://ecommerce_user:ecommerce_password@localhost:5432/ecommerce_db
PORT=5000
DEBUG=True

API Reference

Each microservice exposes a REST API. Here are some examples:

Product Catalog Service

  • GET /products: Get all products.
    • Response:
      [
          {
              "id": 1,
              "name": "Product 1",
              "description": "Description of Product 1",
              "price": 19.99
          },
          {
              "id": 2,
              "name": "Product 2",
              "description": "Description of Product 2",
              "price": 29.99
          }
      ]
  • GET /products/{id}: Get a specific product by ID.

Order Management Service

  • POST /orders: Create a new order.
    • Request body:
      {
          "user_id": 1,
          "product_ids": [1, 2],
          "total_amount": 49.98
      }
  • GET /orders/{id}: Get a specific order by ID.

πŸ“ Project Structure

ecommerce-microservices/
β”œβ”€β”€ πŸ“ product-catalog-service/
β”‚   β”œβ”€β”€ πŸ“„ app.py                # Flask application
β”‚   β”œβ”€β”€ πŸ“„ models.py             # Database models
β”‚   β”œβ”€β”€ πŸ“„ routes.py             # API routes
β”‚   β”œβ”€β”€ πŸ“„ requirements.txt      # Dependencies
β”‚   β”œβ”€β”€ πŸ“„ Dockerfile            # Docker configuration
β”‚   └── πŸ“„ .env.example          # Example environment variables
β”œβ”€β”€ πŸ“ order-management-service/
β”‚   └── ...
β”œβ”€β”€ πŸ“ user-authentication-service/
β”‚   └── ...
β”œβ”€β”€ πŸ“ payment-processing-service/
β”‚   └── ...
β”œβ”€β”€ πŸ“„ docker-compose.yml       # Docker Compose configuration
β”œβ”€β”€ πŸ“„ README.md                # Project documentation
└── πŸ“„ LICENSE                # License file

🀝 Contributing

We welcome contributions! Please see our Contributing Guide (placeholder) for details.

Quick Contribution Steps

  1. 🍴 Fork the repository
  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

Development Setup

# Fork and clone the repo
git clone https://github.com/yourusername/ecommerce-microservices.git

# Install dependencies (example for product-catalog-service)
cd product-catalog-service
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# Create a new branch
git checkout -b feature/your-feature-name

# Make your changes and test
python app.py # Or run tests

# Commit and push
git commit -m "Description of changes"
git push origin feature/your-feature-name

Code Style

  • Follow existing code conventions (PEP 8).
  • Use a linter (e.g., flake8) to check for code style issues.
  • Add tests for new features.
  • Update documentation as needed.

Testing

Each service should have its own set of unit and integration tests.

Running Tests (example for product-catalog-service)

cd product-catalog-service
python -m unittest discover tests

Deployment

Docker Compose

The easiest way to deploy the application is using Docker Compose:

  1. Build and push Docker images for each service to a container registry (e.g., Docker Hub).
  2. Update the docker-compose.yml file with the correct image names.
  3. Deploy the docker-compose.yml file to a server with Docker and Docker Compose installed.
  4. Run docker-compose up -d to start the services.

Kubernetes

For more complex deployments, consider using Kubernetes. You will need to create Kubernetes deployment and service manifests for each microservice.

FAQ

Q: How do I scale the application?

A: You can scale individual services by increasing the number of replicas in Docker Compose or Kubernetes.

Q: How do I add a new microservice?

A: Create a new directory for the service, implement the service logic, and add it to the docker-compose.yml file or Kubernetes deployment.

Q: How do I handle inter-service communication?

A: Services can communicate with each other using REST APIs or message queues (e.g., RabbitMQ or Kafka).

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

License Summary

  • βœ… Commercial use
  • βœ… Modification
  • βœ… Distribution
  • βœ… Private use
  • ❌ Liability
  • ❌ Warranty

πŸ’¬ Support

πŸ™ Acknowledgments

About

A scalable and modular E-commerce platform built using a microservices architecture, designed to handle real-world production workflows such as authentication, product catalog management, order processing, payments, and asynchronous notifications. This project demonstrates modern backend engineering with service isolation, event-driven communicati

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors