A modern, full-stack ecommerce platform built with microservices architecture using Next.js, TypeScript, and a suite of specialized services. This project demonstrates enterprise-level patterns with clean architecture, real-time communication, and modern UI/UX design.
- Frontend: Next.js 15, React 18, TypeScript, Tailwind CSS
- Backend: Node.js, Express.js, Fastify, Hono.js
- Databases: PostgreSQL, MongoDB with Prisma ORM
- Event Streaming: Apache Kafka with KRaft mode
- Authentication: Clerk with JWT tokens
- Payments: Stripe integration
- State Management: Zustand for client-side state
- Monorepo: Turborepo with PNPM workspace
- Containerization: Docker & Docker Compose
This project follows a microservices architecture pattern with the following key components:
- π Client App (
apps/client) - Customer-facing ecommerce website (Port: 3000) - π¨βπΌ Admin Dashboard (
apps/admin) - Admin panel for managing products, orders, and users (Port: 3001)
- ποΈ Product Service (
apps/product-service) - Manages products and categories (Port: 8001) - π¦ Order Service (
apps/order-service) - Handles order processing and management (Port: 8002) - π³ Payment Service (
apps/payment-service) - Processes payments via Stripe (Port: 8003) - π Auth Service (
apps/auth-service) - User authentication and authorization (Port: 8004) - π§ Email Service (
apps/email-service) - Sends transactional emails
- π Types (
packages/types) - Shared TypeScript types across services - ποΈ Product DB (
packages/product-db) - Database models and utilities for products - π Order DB (
packages/order-db) - Database models and utilities for orders - π Kafka (
packages/kafka) - Event streaming and messaging utilities - βοΈ Config Packages - ESLint and TypeScript configurations
- π¨ Modern UI/UX - Clean, responsive design with Tailwind CSS
- π Product Search & Filtering - Advanced search with category filters
- π Shopping Cart - Persistent cart with quantity management
- π³ Secure Checkout - Multi-step checkout process with Stripe integration
- π± Responsive Design - Mobile-first approach for all devices
- π€ User Authentication - Secure login/signup via Clerk
- π¦ Order Tracking - View order history and status
- π Analytics Dashboard - Order trends, sales charts, and metrics
- π¦ Product Management - CRUD operations for products and categories
- ποΈ Order Management - View and manage customer orders
- π₯ User Management - Admin user controls and permissions
- π Real-time Analytics - Live data visualization with charts
- π Event-Driven Architecture - Kafka for service communication
- π JWT Authentication - Secure token-based auth with Clerk
- π§ Email Notifications - Automated transactional emails
- πͺ Real-time Updates - Live order and inventory updates
- π Role-based Access Control - Admin and customer permissions
- π± Progressive Web App - Modern web app capabilities
- Next.js 15 - React framework with App Router
- TypeScript - Type-safe development
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Modern icon library
- Lottie React - Animations and micro-interactions
- Zustand - State management
- React Hook Form - Form handling with validation
- Node.js - JavaScript runtime
- Express.js - Web framework for REST APIs
- Fastify - Fast web framework for Order Service
- Hono - Lightweight framework for Payment Service
- Prisma - Database ORM and migrations
- MongoDB/PostgreSQL - Database solutions
- Kafka - Event streaming platform
- Clerk - Authentication and user management
- Stripe - Payment processing
- JWT - Secure token authentication
- Turborepo - Monorepo build system
- PNPM - Fast package manager
- ESLint - Code linting
- Prettier - Code formatting
- TypeScript - Static type checking
Modern homepage with hero section, featured products, and category navigation
Product listing with advanced filtering and search capabilities
Detailed product view with image gallery, options, and reviews
Multi-step checkout process with cart management
Secure payment process with Stripe integration
Customer order history and tracking
Analytics dashboard with sales metrics and charts
Comprehensive product management interface
Order tracking and management system
Ensure you have the following installed:
- Node.js (v18 or higher)
- PNPM (v10 or higher)
- PostgreSQL (for Product Service)
- MongoDB (for Order Service)
- Kafka (for event streaming)
-
Clone the repository
git clone https://github.com/reda-trouki/Ecom.git cd Ecom -
Install dependencies
pnpm install
-
Environment Variables
Create
.envfiles in each service directory with the required variables:Client App (
.env.localinapps/client/)NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key NEXT_PUBLIC_PRODUCT_SERVICE_URL=http://localhost:8001 NEXT_PUBLIC_ORDER_SERVICE_URL=http://localhost:8002 NEXT_PUBLIC_PAYMENT_SERVICE_URL=http://localhost:8003 NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
Admin App (
.env.localinapps/admin/)NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key NEXT_PUBLIC_PRODUCT_SERVICE_URL=http://localhost:8001 NEXT_PUBLIC_ORDER_SERVICE_URL=http://localhost:8002 NEXT_PUBLIC_AUTH_SERVICE_URL=http://localhost:8004
Product Service (
.envinapps/product-service/)DATABASE_URL=postgresql://username:password@localhost:5432/products_db CLERK_SECRET_KEY=your_clerk_secret_key KAFKA_BROKERS=localhost:9094,localhost:9095,localhost:9096
Order Service (
.envinapps/order-service/)MONGODB_URI=mongodb://localhost:27017/orders_db CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key KAFKA_BROKERS=localhost:9094,localhost:9095,localhost:9096
Payment Service (
.envinapps/payment-service/)STRIPE_SECRET_KEY=your_stripe_secret_key STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key CLERK_SECRET_KEY=your_clerk_secret_key KAFKA_BROKERS=localhost:9094,localhost:9095,localhost:9096
Auth Service (
.envinapps/auth-service/)CLERK_SECRET_KEY=your_clerk_secret_key KAFKA_BROKERS=localhost:9094,localhost:9095,localhost:9096
Email Service (
.envinapps/email-service/)USER_EMAIL=your_gmail@gmail.com GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret GOOGLE_REFRESH_TOKEN=your_google_refresh_token KAFKA_BROKERS=localhost:9094,localhost:9095,localhost:9096
-
PostgreSQL Setup (Product Service)
# Create database createdb products_db # Run migrations cd packages/product-db pnpm run db:generate pnpm run db:deploy
-
MongoDB Setup (Order Service)
# MongoDB should be running on localhost:27017 # Database will be created automatically
This project uses Docker Compose to run Kafka in KRaft mode (no Zookeeper required) with a 3-broker cluster setup.
-
Prerequisites
- Docker and Docker Compose installed on your system
- Ensure ports 9094, 9095, 9096, and 8080 are available
-
Start Kafka Cluster
# Navigate to the Kafka package directory cd packages/kafka # Start the Kafka cluster with 3 brokers + Kafka UI docker-compose up -d # Check if all services are running docker-compose ps
-
Kafka Cluster Configuration
- Broker 1:
localhost:9094(External access) - Broker 2:
localhost:9095(External access) - Broker 3:
localhost:9096(External access) - Kafka UI:
http://localhost:8080(Web interface for managing topics and messages)
- Broker 1:
-
Environment Variables for Services
# Use these broker addresses in your service .env files KAFKA_BROKERS=localhost:9094,localhost:9095,localhost:9096
-
Topics Auto-Creation The Kafka cluster is configured with auto-topic creation enabled. Topics will be created automatically when first accessed by the services:
product.created- Product creation eventsproduct.deleted- Product deletion eventspayment.successful- Successful payment eventsorder.created- Order creation eventsuser.created- User registration events
-
Managing Kafka (Optional)
# View logs docker-compose logs -f kafka-broker-1 # Stop Kafka cluster docker-compose down # Stop and remove volumes (reset data) docker-compose down -v # Access Kafka UI for topic management # Open http://localhost:8080 in your browser
-
Kafka Utilities Package The project includes a shared Kafka package (
@repo/kafka) with utilities:- Client: Creates Kafka client instances for each service
- Producer: Publishes events to topics
- Consumer: Subscribes to topics and handles messages
Example usage in services:
import { createKafkaClient, createProducer, createConsumer } from '@repo/kafka'; const kafka = createKafkaClient('product-service'); const producer = createProducer(kafka); const consumer = createConsumer(kafka, 'product-group');
-
Clerk Authentication
- Sign up at clerk.com
- Create a new application
- Get your publishable and secret keys
- Configure user roles (admin/customer)
-
Stripe Payment Processing
- Sign up at stripe.com
- Get your publishable and secret keys
- Set up webhook endpoints for payment events
-
Google OAuth (Email Service)
- Go to Google Cloud Console
- Create OAuth 2.0 credentials
- Enable Gmail API
- Get refresh token for email service
-
Start all services in development mode
# This will start all apps and services concurrently pnpm run dev -
Or start services individually
# Frontend applications cd apps/client && pnpm run dev # Port 3000 cd apps/admin && pnpm run dev # Port 3001 # Backend services cd apps/product-service && pnpm run dev # Port 8001 cd apps/order-service && pnpm run dev # Port 8002 cd apps/payment-service && pnpm run dev # Port 8003 cd apps/auth-service && pnpm run dev # Port 8004 cd apps/email-service && pnpm run dev # Background service
-
Access the applications
- Customer App: http://localhost:3000
- Admin Dashboard: http://localhost:3001
-
Build all applications
pnpm run build
-
Start production servers
pnpm run start
# Install dependencies
pnpm install
# Start development servers
pnpm run dev
# Build all apps
pnpm run build
# Run linting
pnpm run lint
# Format code
pnpm run format
# Type checking
pnpm run check-types
# Generate database schemas
pnpm run db:generate
# Run database migrations
pnpm run db:migrate- User Action β Frontend (Client/Admin)
- API Request β Authentication Middleware (Clerk)
- Business Logic β Microservice (Product/Order/Payment/Auth)
- Event Publishing β Kafka
- Event Consumption β Other Services
- Database Update β PostgreSQL/MongoDB
- Notification β Email Service
- Product Events:
product.created,product.deleted - Payment Events:
payment.successful - Order Events:
order.created - User Events:
user.created
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Turborepo for monorepo management
- Clerk for authentication services
- Stripe for payment processing
- Vercel for deployment platform
- Tailwind CSS for styling framework
For support, email trouki.reda@gmail.com or create an issue in this repository.
Happy Coding! π