A minimal, production-ready eCommerce backend built with Golang, gRPC, HTTP, MongoDB, and Hexagonal Architecture. The system is divided into independent microservices for scalability and maintainability.
| Service | Description | Protocols Supported |
|---|---|---|
product-ms |
Handles product CRUD and catalog queries | HTTP, gRPC |
order-ms |
Manages orders and interacts with payment | HTTP, gRPC |
payment-ms |
Handles payments via Stripe | HTTP only |
user-ms |
Manages user authentication and sessions | HTTP, gRPC |
All services interact with user-ms for authentication and authorization.
- Language: Go
- DB: MongoDB
- APIs: HTTP + gRPC
- Architecture: Hexagonal (Clean)
- Auth: JWT
- Payment: Stripe
Each microservice follows the same structure:
ecommerce/
├── product-ms/
│ ├── internal/
│ │ ├── domain/ # Entity Definitions
│ │ ├── dto/ # Data Transfer Objects
│ │ ├── handler/ # HTTP Handlers
│ │ ├── domain/ # Entity Definitions
│ │ ├── repository/ # Interfaces & DB Implementation
│ │ ├── usecase/ # Business Logic
│ │ ├── infrastructure/
│ │ │ ├── client/ # gRPC files
│ │ │ ├── config/ # Configuration
│ │ │ ├── database/ # Database connection
│ │ │ └── middleware/ # Auth middleware, logging, etc.
│ ├── cmd/ # Main function
│ ├── pkg/ # Utility functions
│ ├── docs/ # Swagger documentation
│ ├── go.mod # Go module
│ ├── go.sum # Go sum
│ ├── README.md # README
│ └── .env # Environment variables
...
- Go 1.20+
- MongoDB (local or Atlas)
- Stripe Developer Account
protoc(Protocol Buffer Compiler)
git clone https://github.com/haileamlak/ecommerce-with-microservices.git
cd ecommerce-with-microservices/{service-name}
go mod tidy
go run cmd/main.gouser-msissues and verifies JWTs.- Other services use gRPC calls to
user-msfor token validation.
All Services Have Swagger Documentation
GET /swagger/*(works for all services)
-
POST /register -
POST /login -
gRPC:
Login,VerifyToken
-
POST /products -
GET /products/{id} -
GET /products -
PUT /products/{id} -
DELETE /products/{id} -
gRPC:
CreateProduct,GetProduct,GetProducts,UpdateProduct,DeleteProduct
POST /ordersGET /orders/{id}GET /orders/user/{userId}PUT /orders/{id}DELETE /orders/{id}- gRPC:
CreateOrder,GetOrder
POST /initiate-paymentPOST /webhook
- Placed under:
infrastructure/middleware/auth.go - Calls
user-msover gRPC to verify tokens - Injects
userIDinto request context
- Set your Stripe secret key in
.envor as an environment variable. - Payments are created from
payment-msand verified through webhooks or polling.
No-license — free to use, modify, and distribute.