How tranduyduong/ecommerce works
Project type and purpose
• This is a full-stack, microservice-styled e-commerce system.
• It consists of a React single-page frontend and a Django-based backend composed of multiple Django “apps” (auth_core, core, payment_gateway), with asynchronous processing via Celery and RabbitMQ, all containerized with Docker Compose.
Main components
a. Frontend (React)
• Node.js container or client browser—serves the SPA, static assets, and routes user interactions to the API.
b. Backend API (Django REST)
• One or more web containers running the Django project (config/urls.py, views, serializers).
• Hosts the three “microservices” as Django apps (auth_core, core, payment_gateway).
c. Message broker (RabbitMQ)
• Handles task queueing for asynchronous work (order fulfillment, emails, payments).
d. Worker (Celery)
• One or more Celery worker containers listening on RabbitMQ, executing background tasks.
e. Database (PostgreSQL)
• Primary relational datastore for all apps.
f. Media storage (Docker volume or shared storage)
• Where uploaded files (e.g. product images) are persisted.
g. External services
• Third-party payment provider (called from payment_gateway/proccess_payment.py).
Relationships and data flows
• Client → (HTTPS/REST) → Django API
• Django API → (SQL) → PostgreSQL
• Django API → (AMQP) → RabbitMQ
• Celery Worker → (AMQP) → RabbitMQ
• Celery Worker → (SQL) → PostgreSQL
• Celery Worker → (HTTPS/SDK) → External Payment API
• Client ← (HTTP/WebSocket optional) ← Django API responses
Architectural patterns and design principles
• Micro-Django apps: auth_core, core, payment_gateway are loosely coupled but share the same project settings.
• Event-driven, asynchronous processing (Celery + RabbitMQ).
• 12-factor app approach: configuration via environment variables, stateless containers, separate backing services.
• Container orchestration with Docker Compose: defines services for web, worker, broker, db, and optionally a volume for media.