Apply all Docker skills in a comprehensive capstone project building a complete microservices-based e-commerce platform with multiple services, databases, and monitoring.
This capstone project brings together everything you've learned about Docker to build a real-world microservices e-commerce platform. You'll design, build, and deploy a complete system consisting of multiple independent services that work together to provide a full shopping experience.
The platform includes user authentication, product catalog, shopping cart, order management, payment processing, and notification services. Each service is independently deployable, scalable, and uses the most appropriate technology stack for its requirements. This project simulates the architecture used by major e-commerce platforms at scale.
Our e-commerce platform follows microservices best practices with clearly defined service boundaries, independent data stores, and asynchronous communication where appropriate.
Platform Services:
Supporting Infrastructure:
Communication Patterns:
The User Service handles authentication, authorization, and user profile management. It's built with Node.js and Express, using PostgreSQL for data persistence and JWT for stateless authentication.
Features:
Security Considerations:
The Product Service manages the product catalog, inventory, and search functionality. Built with FastAPI and MongoDB for flexible document storage, it handles complex product attributes and fast search queries.
Features:
Why MongoDB:
The Cart Service handles shopping cart operations with high performance using Go and Redis. Redis provides sub-millisecond response times essential for the shopping experience.
Features:
Why Go + Redis:
Deploying the complete microservices platform requires coordinating all services, databases, and infrastructure components. The deployment uses Docker Compose for orchestration with proper service dependencies, health checks, and networking.
Deployment Steps:
Scaling Considerations:
Complete implementation including all service configurations, API documentation, and deployment scripts.
1# Project Structure
2ecommerce-platform/
3├── docker-compose.yml
4├── docker-compose.prod.yml
5├── .env.example
6├── services/
7│ ├── user-service/
8│ │ ├── Dockerfile
9│ │ ├── package.json
10│ │ └── src/
11│ ├── product-service/
12│ │ ├── Dockerfile
13│ │ ├── pyproject.toml
14│ │ └── main.py
15│ ├── cart-service/
16│ │ ├── Dockerfile
17│ │ ├── go.mod
18│ │ └── main.go
19│ ├── order-service/
20│ │ ├── Dockerfile
21│ │ └── src/
22│ └── notification-service/
23│ ├── Dockerfile
24│ └── main.py
25├── monitoring/
26│ ├── prometheus.yml
27│ └── grafana/
28└── scripts/
29 ├── deploy.sh
30 ├── test.sh
31 └── seed-data.sh
32
33---
34# Order Service (Node.js) - Orchestrates order workflow
35# services/order-service/src/index.ts
36
37import express from 'express';
38import { PrismaClient } from '@prisma/client';
39import amqplib from 'amqplib';
40
41const app = express();
42const prisma = new PrismaClient();
43
44let channel: amqplib.Channel;
45
46// Connect to RabbitMQ
47async function connectQueue() {
48 const connection = await amqplib.connect(process.env.RABBITMQ_URL!);
49 channel = await connection.createChannel();
50 await channel.assertQueue('orders');
51 await channel.assertQueue('notifications');
52}
53
54app.post('/api/orders', async (req, res) => {
55 const { userId, items, shippingAddress } = req.body;
56
57 try {
58 // Calculate total
59 const total = items.reduce((sum, item) => sum + item.price * item.quantity, 0);
60
61 // Create order
62 const order = await prisma.order.create({
63 data: {
64 userId,
65 items: { create: items },
66 shippingAddress,
67 total,
68 status: 'PENDING',
69 },
70 });
71
72 // Publish order.created event
73 channel.sendToQueue(
74 'orders',
75 Buffer.from(JSON.stringify({
76 event: 'order.created',
77 orderId: order.id,
78 userId,
79 total,
80 }))
81 );
82
83 // Queue notification
84 channel.sendToQueue(
85 'notifications',
86 Buffer.from(JSON.stringify({
87 type: 'order_confirmation',
88 userId,
89 orderId: order.id,
90 total,
91 }))
92 );
93
94 res.status(201).json(order);
95 } catch (error) {
96 res.status(500).json({ error: 'Failed to create order' });
97 }
98});
99
100app.patch('/api/orders/:id/status', async (req, res) => {
101 const { id } = req.params;
102 const { status } = req.body;
103
104 const order = await prisma.order.update({
105 where: { id },
106 data: { status },
107 });
108
109 // Publish status change event
110 channel.sendToQueue(
111 'orders',
112 Buffer.from(JSON.stringify({
113 event: 'order.status_changed',
114 orderId: id,
115 status,
116 }))
117 );
118
119 res.json(order);
120});
121
122connectQueue().then(() => {
123 app.listen(3004, () => console.log('Order service on port 3004'));
124});
125
126---
127# Notification Service (Python) - Consumes events
128# services/notification-service/main.py
129
130import pika
131import json
132import os
133import smtplib
134from email.mime.text import MIMEText
135
136def send_email(to, subject, body):
137 msg = MIMEText(body)
138 msg['Subject'] = subject
139 msg['From'] = os.getenv('SMTP_FROM')
140 msg['To'] = to
141
142 with smtplib.SMTP(os.getenv('SMTP_HOST'), 587) as server:
143 server.starttls()
144 server.login(os.getenv('SMTP_USER'), os.getenv('SMTP_PASS'))
145 server.send_message(msg)
146
147def callback(ch, method, properties, body):
148 message = json.loads(body)
149 print(f"Received: {message}")
150
151 if message['type'] == 'order_confirmation':
152 # In production, fetch user email from user-service
153 send_email(
154 to='[email protected]',
155 subject=f"Order #{message['orderId']} Confirmed",
156 body=f"Your order totaling ${message['total']} has been received."
157 )
158
159 ch.basic_ack(delivery_tag=method.delivery_tag)
160
161def main():
162 connection = pika.BlockingConnection(
163 pika.ConnectionParameters(host='rabbitmq')
164 )
165 channel = connection.channel()
166 channel.queue_declare(queue='notifications')
167 channel.basic_consume(
168 queue='notifications',
169 on_message_callback=callback
170 )
171 print('Notification service started')
172 channel.start_consuming()
173
174if __name__ == '__main__':
175 main()
176
177---
178# Deployment Script
179#!/bin/bash
180# scripts/deploy.sh
181
182set -e
183
184VERSION=${1:-latest}
185
186echo "=== Deploying E-Commerce Platform v$VERSION ==="
187
188# Pull latest images
189docker compose pull
190
191# Deploy infrastructure first
192docker compose up -d postgres mongo redis rabbitmq
193echo "Waiting for databases..."
194sleep 30
195
196# Run migrations
197docker compose run --rm user-service npm run migrate
198docker compose run --rm order-service npm run migrate
199
200# Deploy services
201docker compose up -d --scale user-service=2 --scale product-service=2 --scale cart-service=3
202
203# Health check
204echo "Checking service health..."
205sleep 20
206curl -sf http://localhost/api/users/health
207curl -sf http://localhost/api/products/health
208curl -sf http://localhost/api/cart/health
209curl -sf http://localhost/api/orders/health
210
211echo "=== Deployment Complete ==="Your progress is saved in this browser, on this device only.