https://github.com/maron09/ecommerce-microservice
https://github.com/maron09/ecommerce-microservice
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/maron09/ecommerce-microservice
- Owner: Maron09
- Created: 2025-06-10T21:15:13.000Z (about 1 year ago)
- Default Branch: dev
- Last Pushed: 2025-11-09T15:00:56.000Z (9 months ago)
- Last Synced: 2025-11-09T16:09:47.888Z (9 months ago)
- Language: JavaScript
- Size: 344 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ποΈ E-Commerce Microservices System
A **scalable, event-driven e-commerce platform** built with a microservices architecture using **Node.js**, **Express**, **MongoDB**, **RabbitMQ**, and **Paystack** for payments.
This project showcases a distributed system design where independent services handle different business domains β enabling better scalability, maintainability, and fault isolation.
---
## π Overview
This system demonstrates a modular e-commerce backend, where each service operates independently and communicates asynchronously through **RabbitMQ**.
Itβs designed for portfolio and production-level demonstration β combining clean code practices, microservice patterns, and real payment integration.
---
## π§© Services Breakdown
| Service | Description |
|----------|-------------|
| **API Gateway** | Central entry point. Handles routing, authentication, and request forwarding to respective services. |
| **Auth Service** | Manages user registration, login, JWT authentication, and role-based access control (customer, vendor, admin). |
| **Customer Service** | Handles customer profile, preferences, and order history. |
| **Vendor Service** | Manages vendor registration, store setup, and payout configurations (including Paystack subaccounts). |
| **Cart Service** | Handles cart creation, item addition/removal, and cart persistence per customer session. |
| **Order Service** | Coordinates order creation, status updates, and fulfillment workflows. |
| **Product Service** | Manages product listing, stock updates, categories, and vendor associations. |
| **Inventory Service** | Tracks product stock levels and updates them based on order activity. |
| **Payment Service** | Integrates with **Paystack** for secure transactions and automatic vendor payment splits. |
| **Notification Service** | Sends real-time notifications (email/SMS) for order confirmations, payment updates, and vendor alerts. |
| **Admin Service** | Provides administrative controls for monitoring, approving vendors, and managing platform data. |
---
## π§ Architecture
The project is designed around **microservice principles**:
- πΈ **Event-driven communication** via **RabbitMQ**
- π§± **Independent MongoDB databases** for each service
- π **JWT-based Authentication** (managed by the Auth Service)
- π³ **Paystack Integration** for real payments and vendor split handling
- βοΈ **API Gateway** for unified request management
- π¬ **Asynchronous messaging** for decoupled service interactions
- π§© **Scalable microservices** that can run separately or as a cluster
---
## π¦ Tech Stack
| Category | Technology |
|-----------|-------------|
| **Language** | Node.js (ES Modules) |
| **Framework** | Express.js |
| **Database** | MongoDB (Mongoose ODM) |
| **Message Broker** | RabbitMQ |
| **Payment Integration** | Paystack |
| **Authentication** | JWT |
| **Logging** | Winston-based logger |
| **Containerization (optional)** | Docker & Docker Compose |
---
## π³ Payment Flow (Paystack Integration)
1. **Customer places an order** via the API Gateway.
2. The **Order Service** creates the order and publishes a message to RabbitMQ.
3. The **Payment Service** initializes a Paystack transaction with split details for vendors.
4. Upon successful payment, Paystack calls the **/verify** endpoint.
5. The **Payment Service** verifies the transaction, updates the order via the **Order Service**, and publishes a payment completion event.
6. **Notification Service** informs the customer and vendor of the payment status.
---
## π¨ RabbitMQ Message Flow
| Event | Publisher | Subscriber(s) | Description |
|--------|------------|---------------|--------------|
| `order.created` | Order Service | Payment, Inventory | Triggered when an order is created. |
| `payment.completed` | Payment Service | Order, Notification | Triggered when a payment is verified. |
| `inventory.updated` | Inventory Service | Order | Adjusts stock levels after successful order. |
| `vendor.payout` | Payment Service | Vendor | Handles Paystack vendor split confirmation. |
---
## ποΈ Directory Structure (Example)
ecommerce-microservices/
β
βββ api-gateway/
β βββ routes/
β βββ middlewares/
β βββ server.js
β
β βββ auth/
β βββ cart/
β βββ customer/
β βββ vendor/
β βββ order/
β βββ product/
β βββ inventory/
β βββ payments/
β βββ notification/
β βββ admin/
β
β
βββ README.md
```bash
git clone https://github.com/maron09/Ecommerce-Microservice.git
cd ecommerce-microservices
```
```bash
npm install
```
## Each service has its own .env file. Example for Payment Service:
- PORT=5007
- MONGO_URI=mongodb://localhost:27017/payment
- RABBITMQ_URL=amqp://localhost
- PAYSTACK_SECRET_KEY=sk_test_xxxxxxxxxxxxx
- PAYSTACK_PUBLIC_KEY=pk_test_xxxxxxxxxxxxx
## π Future Improvements
1. β
Add Analytics to track performance
2. β
Integrate Kubernetes for deployment orchestration.
3. β
Add unit/integration tests (Jest + Supertest).
## π§βπ» Author
**Ezra**
- Backend Developer (Python, Node.js)
- Building scalable systems with clean architecture & efficient APIs.
## ποΈ License
- This project is licensed under the MIT License β feel free to use and modify it for learning or production.