A production-ready e-commerce platform built with a modern microservices architecture. This project demonstrates enterprise-level implementation of:
- Service mesh with gRPC inter-service communication
- Event-driven architecture using Apache Kafka
- GraphQL API gateway for unified client access
- Elasticsearch-powered product search and cataloging
- ML-based product recommendations with Python
- Container orchestration with Docker Compose
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.
Below is a high-level overview of the system architecture:
-
API Gateway (GraphQL)talks to:Account clientβAccount serverβPostgresProduct clientβProduct serverβElasticSearch+ KafkaOrder clientβOrder serverβPostgres+ Kafka (also communicates with Product service via gRPC)Payment clientβPayment serviceβpayment provider+Postgres+ KafkaRecommender clientβRecommender server(Python) βPostgres (Replica)+ Kafka
-
Event Flow:
OrderandProductservices act as Kafka producers.Paymentservice is a Kafka consumer, ingesting product events and saving them in payment provider (DodoPayments).Recommenderservice is also a Kafka consumer, ingesting order/product events and updating internal state for recommendations.
- Responsibilities: Register, login, fetch account data, generate JWT tokens.
- Database: PostgreSQL
- Responsibilities: Product CRUD operations, indexing to Elasticsearch, event publishing to Kafka.
- Database: Elasticsearch
- Responsibilities: Order creation, price calculation, data persistence, Kafka event publishing.
- Dependencies: Calls product service to retrieve product info.
- Responsibilities: Kafka consumer that builds recommendations based on product/order events.
- Tech Stack: Python + gRPC + PostgreSQL (replica of product DB)
- Responsibilities: Unified GraphQL endpoint at
/graphql. - Implementation: Uses gRPC clients for all microservices and schema stitching.
Before running the project, ensure you have the following installed:
git clone https://github.com/tigriscloud/go-ecommerce-api.git
cd go-ecommerce-apiTo 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
recommenderservice - Databases: PostgreSQL, Elasticsearch
- Kafka + Zookeeper
- GraphQL gateway
Once everything is running, open your browser to:
- GraphQL API endpoint:
http://localhost:8080/graphql - GraphQL Playground:
http://localhost:8080/playground
Below are example GraphQL queries and mutations you can test in the GraphQL Playground.
mutation {
register(account: {
name: "Alice"
email: "alice@example.com"
password: "secret123"
}) {
token
}
}mutation {
login(account: {
email: "alice@example.com"
password: "secret123"
}) {
token
}
}mutation {
createProduct(product: {
name: "Camera"
description: "A digital camera"
price: 99.99
}) {
id
name
}
}query {
product(pagination: { skip: 0, take: 10 }) {
id
name
price
}
}mutation {
createOrder(order: {
products: [
{ id: "PRODUCT_ID", quantity: 2 }
]
}) {
id
totalPrice
products {
name
quantity
}
}
}We welcome contributions! To contribute:
Fork the repository
Create a new branch
Commit and push your changes
Open a Pull Request
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
