A comprehensive, production-ready e-commerce platform built with microservices architecture. This platform provides a complete solution for online shopping with shop management, product catalog, order processing, analytics, and search capabilities.
- Overview
- Architecture
- Services
- Technologies
- Getting Started
- Service Communication
- API Documentation
- Development
- Deployment
- Future Features
EcommerceLocal is a distributed e-commerce platform that follows microservices architecture principles. The platform is designed to be scalable, maintainable, and resilient, with each service handling a specific business domain.
- User Management: Registration, authentication, profile management
- Shop Management: Multi-vendor support with shop approval workflow
- Product Catalog: Products, variations, categories, images, comments
- Shopping Cart: Real-time stock validation and cart management
- Order Processing: Complete order lifecycle with status tracking
- Wishlist: Save products and shops for later
- Analytics: Comprehensive sales and performance analytics
- Search: Full-text search across shops and products using Elasticsearch
- API Gateway: Unified entry point with authentication and routing
โโโโโโโโโโโโโโโ
โ Clients โ
โโโโโโโโฌโโโโโโโ
โ
โโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Traefik (Reverse Proxy) โ
โโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Gateway Service (API Gateway) โ
โ - JWT Authentication โ
โ - Request Routing โ
โ - Unified API Documentation โ
โโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโ
โ โ โ โ
โโโโโโโโผโโโโโโโ โโโโโโโผโโโโโโโ โโโโโโโผโโโโโโโ โโโโโโโผโโโโโโโ
โ User โ โ Shop โ โ Product โ โ Order โ
โ Service โ โ Service โ โ Service โ โ Service โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโ
โ โ โ โ
โโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโ
โ โ โ
โโโโโโผโโโโโ โโโโโโผโโโโโ โโโโโผโโโโโ
โ Shopcartโ โWishlist โ โAnalyticโ
โ Service โ โ Service โ โService โ
โโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโ
- Synchronous: HTTP/REST API calls between services
- Asynchronous: RabbitMQ message broker for event-driven communication
- Caching: Redis for token blacklisting and session management
- Search: Elasticsearch for full-text search capabilities
- Framework: Django REST Framework
- Database: PostgreSQL 16
- Features:
- User registration and authentication
- Profile management with image upload
- Password reset functionality
- Shop owner status tracking
- Documentation: user-service/README.md
- Framework: Django REST Framework
- Database: PostgreSQL 16
- Features:
- Shop creation and management
- Shop approval workflow (PENDING, APPROVED, REJECTED)
- Branch management with geolocation
- Comments and ratings
- Media uploads
- Social media integration
- Order item tracking
- Documentation: shop-service/README.md
- Framework: FastAPI
- Database: PostgreSQL 15+
- Features:
- Product CRUD operations
- Category management
- Product variations (size, color, etc.)
- Stock management
- Product images
- Comments on products
- Automatic stock reduction on order
- Documentation: product-service/README.md
- Framework: Django REST Framework
- Database: PostgreSQL 16
- Features:
- Order creation from shopping cart
- Order item management
- Status tracking (Processing, Shipped, Delivered, Cancelled)
- Stock validation before order creation
- Automatic order approval
- Integration with analytics
- Documentation: order-service/README.md
- Framework: FastAPI
- Database: PostgreSQL 16
- Features:
- Shopping cart management
- Real-time stock verification
- Automatic cart creation on user registration
- Cart clearing after order
- Periodic stock synchronization (Celery)
- Documentation: shopcart-service/README.md
- Framework: FastAPI
- Database: PostgreSQL 16
- Features:
- Add products to wishlist
- Add shops to wishlist
- Wishlist management
- Product/shop validation
- Documentation: wishlist-service/README.md
- Framework: Django REST Framework
- Database: PostgreSQL 17
- Features:
- Order analytics and revenue tracking
- Shop dashboard with statistics
- Product view analytics
- Shop view analytics
- Sales reports with filtering
- Product performance metrics
- Documentation: analytic-service/README.md
- Framework: FastAPI
- Search Engine: Elasticsearch 8.12.1
- Features:
- Full-text search across shops and products
- Fuzzy matching for typo tolerance
- Real-time index updates via events
- Shop-specific product search
- Kibana integration for visualization
- Documentation: elasticsearch-service/README.md
- Framework: FastAPI
- Features:
- Single entry point for all API requests
- JWT token validation and management
- Request routing to backend services
- Unified OpenAPI documentation
- Token blacklisting via Redis
- Documentation: gateway-service/README.md
- Technology: Traefik v2.10
- Features:
- Reverse proxy and load balancing
- Service discovery via Docker labels
- SSL/TLS termination
- Automatic routing
- Documentation: traefik-service/README.md
- Technology: RabbitMQ 3-management
- Features:
- Message broker for event-driven architecture
- Topic exchanges for event routing
- Web-based management interface
- Reliable message delivery
- Documentation: rabbitmq-service/README.md
- Technology: Redis 7.2
- Features:
- Token blacklisting for JWT
- High-performance caching
- Session storage
- AOF persistence
- Documentation: redis-service/README.md
- Django 5.2.7 - User, Shop, Order, Analytics services
- FastAPI 0.115.0+ - Product, Shopcart, Wishlist, Elasticsearch, Gateway services
- Django REST Framework 3.16.1 - REST API for Django services
- SQLAlchemy 2.0+ - ORM for FastAPI services
- SQLModel 0.0.22 - ORM for Wishlist service
- PostgreSQL 15-17 - Primary database for all services
- Elasticsearch 8.12.1 - Full-text search engine
- Redis 7.2 - Caching and token blacklisting
- RabbitMQ 3-management - Event-driven communication
- Pika 1.3.2 - Synchronous AMQP client
- aio-pika 9.4.3+ - Asynchronous AMQP client
- Celery 5.5.3+ - Background task processing (Shopcart service)
- Redis - Celery backend
- Traefik v2.10 - Reverse proxy and load balancer
- Docker & Docker Compose - Containerization
- Gunicorn 23.0.0 - WSGI server for Django services
- Uvicorn 0.30.6+ - ASGI server for FastAPI services
- JWT (python-jose 3.5.0) - Token-based authentication
- Django Authentication - User authentication
- CSRF Protection - Cross-site request forgery protection
- SQL Injection Protection - ORM-based protection
- drf-spectacular 0.28.0 - OpenAPI schema for Django
- FastAPI Auto Docs - Swagger UI and ReDoc
- drf-yasg 1.21.7+ - Alternative Swagger for Django
- pytest 8.4.2+ - Testing framework
- pytest-django 4.11.1+ - Django integration for pytest
- Python 3.10+ - User, Analytics services
- Python 3.11+ - Product, Shopcart, Wishlist, Elasticsearch services
- Python 3.13+ - Shop, Order, Gateway services
- Docker and Docker Compose installed
- Python 3.10+ (for local development)
- PostgreSQL (for local development, optional)
- Git for cloning the repository
- Clone the repository:
git clone <repository-url>
cd EcommerceLocal- Start all services:
# Start infrastructure services first
cd rabbitmq-service && docker-compose up -d
cd ../redis-service && docker-compose up -d
cd ../traefik-service && docker-compose up -d
# Start core services
cd ../gateway-service && docker-compose up -d
cd ../user-service && docker-compose up -d
cd ../shop-service && docker-compose up -d
cd ../product-service && docker-compose up -d
cd ../shopcart-service && docker-compose up -d
cd ../order-service && docker-compose up -d
cd ../wishlist-service && docker-compose up -d
cd ../analytic-service && docker-compose up -d
cd ../elasticsearch-service && docker-compose up -d- Access the services:
- Gateway API:
http://gateway.localhost - API Documentation:
http://gateway.localhost/docs - Traefik Dashboard:
http://traefik.localhost - RabbitMQ Management:
http://rabbitmq-admin.localhost - Kibana:
http://kibana-admin.localhost
For detailed setup instructions for each service, refer to their individual README files:
- User Service Setup
- Shop Service Setup
- Product Service Setup
- Order Service Setup
- Shopcart Service Setup
- Wishlist Service Setup
- Analytics Service Setup
- Elasticsearch Service Setup
- Gateway Service Setup
Each service requires specific environment variables. Create .env files in each service directory based on the examples in their respective README files.
Common environment variables:
- Database connection strings
- RabbitMQ connection details
- Service URLs for inter-service communication
- JWT secrets
- Redis connection details
Services communicate via HTTP REST APIs:
- Gateway โ Services: Routes requests with
X-User-IDheader - Service โ Service: Direct HTTP calls for data fetching
- Authentication: Header-based (
X-User-IDorX-User-Id)
Event-driven communication via RabbitMQ exchanges:
-
user_events
user.created- New user registration- Consumed by: Shopcart Service (auto-create cart)
-
shop_events
shop.approved- Shop approvedshop.updated- Shop updatedshop.deleted- Shop deleted- Consumed by: User Service (update shop owner status), Shopcart Service (delete cart), Elasticsearch Service (index updates)
-
product_events
product.created- New productproduct.updated- Product updatedproduct.deleted- Product deleted- Consumed by: Elasticsearch Service (index updates)
-
order_events
order.created- New orderorder.item.created- Order item createdorder.item.status.updated- Order item status changed- Consumed by: Product Service (stock reduction), Shopcart Service (clear cart), Shop Service (create shop order items), Analytics Service (order processing)
-
wishlist_events
wishlist.created- Item added to wishlistwishlist.deleted- Item removed from wishlist
- User creates order from cart โ Order Service
- Order Service validates stock โ Product Service (HTTP)
- Order Service creates order โ Publishes
order.createdevent - Product Service consumes event โ Reduces stock
- Shopcart Service consumes event โ Clears cart
- Shop Service consumes
order.item.createdโ Creates shop order items - Order items reach final status โ Analytics Service receives approved order
- User registers โ User Service
- User Service publishes
user.createdevent - Shopcart Service consumes event โ Auto-creates shopping cart
- Admin approves shop โ Shop Service
- Shop Service publishes
shop.approvedevent - User Service consumes event โ Updates
is_shop_ownerflag - Shopcart Service consumes event โ Deletes user's cart (shop owners can't have carts)
- Elasticsearch Service consumes event โ Indexes shop for search
The Gateway Service provides unified API documentation for all services:
- Swagger UI:
http://gateway.localhost/docs - ReDoc:
http://gateway.localhost/redoc - OpenAPI JSON:
http://gateway.localhost/openapi.json
Each service also provides its own API documentation:
- User Service:
http://user-admin.localhost/api/schema/swagger/ - Shop Service:
http://shop-admin.localhost/api/schema/swagger-ui/ - Product Service:
http://product-admin.localhost/docs - Order Service:
http://order-admin.localhost/api/schema/swagger-ui/ - Analytics Service:
http://analytic-admin.localhost/api/schema/swagger-ui/ - Shopcart Service: Check service documentation
- Wishlist Service: Check service documentation
- Elasticsearch Service:
http://elasticsearch-api.localhost/docs
EcommerceLocal/
โโโ user-service/ # User authentication and management
โโโ shop-service/ # Shop management
โโโ product-service/ # Product catalog
โโโ order-service/ # Order processing
โโโ shopcart-service/ # Shopping cart
โโโ wishlist-service/ # Wishlist management
โโโ analytic-service/ # Analytics and reporting
โโโ elasticsearch-service/ # Search functionality
โโโ gateway-service/ # API Gateway
โโโ traefik-service/ # Reverse proxy
โโโ rabbitmq-service/ # Message broker
โโโ redis-service/ # Caching
- Start infrastructure services (RabbitMQ, Redis, Traefik)
- Start dependent services (User, Shop, Product)
- Start dependent services (Shopcart, Order, Wishlist)
- Start supporting services (Analytics, Elasticsearch)
- Start Gateway (last, as it depends on all services)
- Django Services: Follow Django and PEP 8 conventions
- FastAPI Services: Follow FastAPI and PEP 8 conventions
- Type Hints: Use type hints where applicable
- Documentation: Include docstrings for functions and classes
Run tests for each service:
# Django services
cd user-service && python manage.py test
cd shop-service && pytest
cd order-service && pytest
cd analytic-service && pytest
# FastAPI services
cd product-service && pytest
cd shopcart-service && pytest
cd wishlist-service && pytest
cd elasticsearch-service && pytest
cd gateway-service && pytestEach service includes a docker-compose.yml file for containerized deployment. Services are designed to work together via Docker networks.
- Database: Use managed PostgreSQL services (AWS RDS, Google Cloud SQL)
- Message Broker: Use managed RabbitMQ or cloud message queues
- Caching: Use managed Redis services
- Load Balancing: Configure Traefik for production with SSL certificates
- Monitoring: Set up logging and monitoring (ELK stack, Prometheus, Grafana)
- Security: Enable HTTPS, configure CORS, set up firewall rules
- Scaling: Scale services horizontally based on load
Some services support Google Cloud Run deployment:
- Order Service
- Shop Service
Configure CLOUD_SQL_CONNECTION_NAME for Cloud SQL integration.
The following features are planned for future implementation (not critical but will enhance the platform):
- Payment gateway integration (Stripe, PayPal, etc.)
- Payment processing service
- Payment history and receipts
- Refund management
- Email notifications (order confirmations, status updates)
- SMS notifications
- Push notifications
- In-app notifications
- Notification preferences
- Product reviews with ratings
- Shop reviews
- Review moderation
- Review analytics
- Advanced stock management
- Low stock alerts
- Automatic reordering
- Warehouse management
- Shipping provider integration
- Shipping cost calculation
- Tracking number management
- Delivery status updates
- Coupon code management
- Discount rules and conditions
- Promotional campaigns
- Flash sales
- Internationalization (i18n)
- Multi-language product descriptions
- Localized pricing
- Customer behavior analytics
- Sales forecasting
- Inventory analytics
- Marketing campaign analytics
- Centralized admin panel
- Shop approval workflow UI
- Order management interface
- Analytics dashboard
- User management
- RESTful API for mobile apps
- Mobile-specific endpoints
- Push notification support
- WebSocket support for real-time updates
- Live order tracking
- Real-time inventory updates
- Chat support
- Faceted search
- Search filters
- Search suggestions
- Search analytics
- Product recommendations
- "Customers who bought this also bought"
- Personalized recommendations
- Trending products
This project is part of the EcommerceLocal platform.
- Fork the repository
- Create a feature branch
- Make your changes
- Write tests
- Submit a pull request
For issues and questions:
- Check individual service README files for service-specific documentation
- Review API documentation at the Gateway Service
- Check service logs for debugging
- Microservices: Each service handles a specific business domain
- Event-Driven: Asynchronous communication via RabbitMQ
- API Gateway: Single entry point for all client requests
- Service Independence: Services can be developed and deployed independently
- Database per Service: Each service has its own database
- Containerization: All services are containerized with Docker
- Scalability: Services can be scaled independently based on load
Note: This is a comprehensive e-commerce platform. Each service is designed to be independently deployable and scalable. For detailed information about each service, refer to their individual README files.