You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A modern, scalable e-commerce platform built with microservices architecture. Each service is independently deployable, has its own database, and communicates via REST APIs and message queuing.
Architecture Overview
graph TB
subgraph "Frontend"
NEXT[Next.js App<br/>Port 3000]
end
subgraph "Application Services"
AUTH[Auth Service<br/>Port 3001]
PROD[Product Service<br/>Port 3002]
ORDER[Order Service<br/>Port 3003]
NOTIF[Notification Service]
end
subgraph "Data Stores"
PG[(PostgreSQL<br/>Per-service DBs)]
MONGO[(MongoDB<br/>Products / Notifications)]
REDIS[(Redis<br/>Cache Layer)]
end
subgraph "Infrastructure"
RABBIT[RabbitMQ<br/>Message Broker]
STRIPE[Stripe<br/>Payment Gateway]
MAIL[MailHog<br/>Email Preview]
CLOUD[Cloudinary<br/>Image Uploads]
end
NEXT --> AUTH
NEXT --> PROD
NEXT --> ORDER
AUTH --> PG
PROD --> PG
PROD --> MONGO
PROD --> REDIS
PROD --> CLOUD
ORDER --> PG
ORDER --> STRIPE
ORDER --> RABBIT
RABBIT --> NOTIF
NOTIF --> MONGO
NOTIF --> MAIL
Loading
Service Interaction Flow
sequenceDiagram
participant U as Browser
participant F as Frontend (Next.js)
participant A as Auth Service
participant P as Product Service
participant O as Order Service
participant N as Notification Service
participant R as RabbitMQ
U->>F: Browse products
F->>P: GET /products
P-->>F: Product list
F-->>U: Render catalog
U->>F: Register / Login
F->>A: POST /register
A-->>F: JWT tokens
F->>U: Store tokens
U->>F: Add to cart
F-->>U: Update cart (localStorage)
U->>F: Checkout
F->>O: POST /orders (JWT)
O->>O: Create order (PostgreSQL)
O->>O: Process payment (Stripe)
O->>R: Publish order.created
O-->>F: Order created
R->>N: Consume order.created
N->>N: Send email notification
F-->>U: Redirect to order page
Loading
Database Design
Each service has its own isolated database (separate PostgreSQL databases and/or MongoDB collections).
erDiagram
User ||--o{ Order : places
User {
uuid id PK
string name
string email UK
string password
enum role
string avatar
string phone
string address
datetime createdAt
datetime updatedAt
string refreshToken
string resetToken
datetime resetTokenExp
}
Category ||--o{ Product : contains
Category {
uuid id PK
string name UK
string slug UK
}
Product {
uuid id PK
string name
string slug UK
string description
float price
float comparePrice
string[] images
int stock
bool featured
uuid categoryId FK
datetime createdAt
datetime updatedAt
}
Order ||--o{ OrderItem : includes
Order {
uuid id PK
string userId
float total
float subtotal
float shipping
float discount
string status
string paymentIntentId
json shippingAddress
string trackingNumber
datetime estimatedDelivery
datetime paidAt
datetime createdAt
datetime updatedAt
}
OrderItem {
uuid id PK
uuid orderId FK
string productId
string name
float price
int quantity
string image
}
Loading
Tech Stack
Layer
Technology
Frontend
Next.js 14, TypeScript, TailwindCSS, shadcn/ui
Auth
Node.js, Express, JWT, bcrypt, Prisma
Products
Node.js, Express, Prisma, Mongoose, Redis
Orders
Node.js, Express, Prisma, Stripe, RabbitMQ
Notifications
Node.js, RabbitMQ, MongoDB, Resend/MailHog
Databases
PostgreSQL 16, MongoDB 7, Redis 7
Message Broker
RabbitMQ 3 (Management)
Containerization
Docker & Docker Compose
Email Dev
MailHog
CI/CD
GitHub Actions
Image Upload
Cloudinary
Getting Started
Prerequisites
Node.js 20+
Docker & Docker Compose
npm or yarn
Quick Start (Docker)
# 1. Clone and enter the project
git clone https://github.com/andrelima28439/ecommerce-microservices.git
cd ecommerce-microservices
# 2. Start everything (10 containers)
docker compose up --build -d
# 3. Seed initial data (admin user, categories, products)
docker exec ecommerce-postgres psql -U ecommerce -d ecommerce_auth \
-c "UPDATE \"User\" SET role='ADMIN' WHERE email='admin@test.com';"# 4. Access the platform
open http://localhost:3000
Manual Start (without Docker)
Start infrastructure services first (PostgreSQL, MongoDB, Redis, RabbitMQ), then run each service:
# Auth Servicecd auth-service && npm install && cp .env.example .env && npm run dev
# Product Servicecd product-service && npm install && cp .env.example .env && npm run dev
# Order Servicecd order-service && npm install && cp .env.example .env && npm run dev
# Notification Servicecd notification-service && npm install && cp .env.example .env && npm run dev
# Frontendcd frontend && npm install && cp .env.example .env && npm run dev