Skip to content
프로젝트

소개

GraphQL 게이트웨이와 계정, 상품, 주문, 결제, 추천 기능을 위한 gRPC 마이크로서비스로 구성된 모듈형 이커머스 백엔드.

비즈니스 및 금융

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
+1
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

ECOMMERCE MICROSERVICES

This repository hosts a sample e-commerce platform demonstrating a microservices architecture using multiple Go services alongside a Python-based Recommender service. The project showcases:

  • gRPC communication between services
  • Kafka-based event streaming pipeline
  • A unified GraphQL API gateway for clients
  • Elasticsearch integration for product search

📚 Table of Contents


🧭 Overview

The system comprises several microservices:

  • Account (Go): Manages user accounts, authentication, and authorization.
  • Product (Go): CRUD for products; indexes product data in Elasticsearch.
  • Order (Go): Handles order creation and persistence; publishes events to Kafka.
  • Payment (Go): Handles payment operations and sends updates to order microservice
  • Recommender (Python): Consumes Kafka events and builds product recommendations.
  • API Gateway (Go): A GraphQL service exposing a unified API for front-end clients.

The entire ecosystem is containerized using Docker Compose. Datastores include PostgreSQL, Elasticsearch, and Kafka.


🏗 Architecture Diagram

Below is a high-level overview of the system architecture:

API Design

Communication Overview

  • API Gateway (GraphQL) talks to:

    • Account client → Account server → Postgres
    • Product client → Product server → ElasticSearch + Kafka
    • Order client → Order server → Postgres + Kafka (also communicates with Product service via gRPC)
    • Payment client → Payment service → payment provider + Postgres + Kafka
    • Recommender client → Recommender server (Python) → Postgres (Replica) + Kafka
  • Event Flow:

    • Order and Product services act as Kafka producers.
    • Payment service is a Kafka consumer, ingesting product events and saving them in payment provider (DodoPayments).
    • Recommender service is also a Kafka consumer, ingesting order/product events and updating internal state for recommendations.

⚙ Services

🧑‍💼 Account Service (Go)

  • Responsibilities: Register, login, fetch account data, generate JWT tokens.
  • Database: PostgreSQL

📦 Product Service (Go)

  • Responsibilities: Product CRUD operations, indexing to Elasticsearch, event publishing to Kafka.
  • Database: Elasticsearch

🛒 Order Service (Go)

  • Responsibilities: Order creation, price calculation, data persistence, Kafka event publishing.
  • Dependencies: Calls product service to retrieve product info.

🧠 Recommender Service (Python)

  • Responsibilities: Kafka consumer that builds recommendations based on product/order events.
  • Tech Stack: Python + gRPC + PostgreSQL (replica of product DB)

🚪 API Gateway (Go)

  • Responsibilities: Unified GraphQL endpoint at /graphql.
  • Implementation: Uses gRPC clients for all microservices and schema stitching.

🚀 Getting Started

✅ Prerequisites

Before running the project, ensure you have the following installed:


📥 Clone the Repository

  git clone https://github.com/rasadov/EcommerceAPI.git
  cd ecommercemicroservices

🐳 Run the Stack

To build and start all services using Docker Compose, run:

# Step 1: Build the base image
docker compose build base

# Step 2: Build and start all services
docker compose up -d --build```

This will start:

  • Go microservices (account, order, product, payment, graphql)
  • Python-based recommender service
  • Databases: PostgreSQL, Elasticsearch
  • Kafka + Zookeeper
  • GraphQL gateway

🌐 Access the API

Once everything is running, open your browser to:


📬 Usage (GraphQL)

Below are example GraphQL queries and mutations you can test in the GraphQL Playground.


📝 Register a New Account

mutation {
  register(account: {
    name: "Alice"
    email: "[email protected]"
    password: "secret123"
  }) {
    token
  }
}

🔐 Login

mutation {
  login(account: {
    email: "[email protected]"
    password: "secret123"
  }) {
    token
  }
}

➕ Create a Product

mutation {
  createProduct(product: {
    name: "Camera"
    description: "A digital camera"
    price: 99.99
  }) {
    id
    name
  }
}

🔍 Query Products

query {
  product(pagination: { skip: 0, take: 10 }) {
    id
    name
    price
  }
}

🛒 Create an Order

mutation {
  createOrder(order: {
    products: [
      { id: "PRODUCT_ID", quantity: 2 }
    ]
  }) {
    id
    totalPrice
    products {
      name
      quantity
    }
  }
}

🤝 Contributing

We welcome contributions! To contribute:

Fork the repository

Create a new branch

Commit and push your changes

Open a Pull Request

👤 Author

Rauf Asadov
GitHub: @rasadov
LinkedIn: Rauf Asadov
Email: [email protected]

🪪 License

This project is licensed under the Apache License 2.0.

관련 프로젝트 살펴보기

불러오는 중…