How benfoxyy/django-online-shop works
Main Components
• Frontend Presentation Layer: Represent the HTML/CSS/JS templates, static files, and client-side interactions that present the user-facing interface (e.g., product lists, cart, checkout, dashboards).
• Django Backend: Highlight the “core” directory as the central hub composed of modular apps:
– Accounts (handles authentication, profiles, and user types)
– Cart (manages shopping cart logic)
– Dashboard (separates admin and customer interfaces)
– Order (order processing and management)
– Payment (integrates with ZarinPal and contains payment client logic)
– Review (customer feedback and review handling)
– Shop (product listing and detail APIs)
– Website (public site pages, sitemap, etc.)
• External Services:
– Cache (Redis for caching operations as noted in the README)
– Object Storage (MinIO for media file storage)
– Payment Gateway (ZarinPal integration)
– Security/Anti-bot service (reCAPTCHA v3)
• Deployment and Infrastructure:
– Docker containers: Separate containers for the backend (Django), the databases (PostgreSQL), the caching layer (Redis), MinIO, as well as for Nginx and Gunicorn in deployment.
– Nginx: As a reverse proxy and static file server.
– Gunicorn: For the WSGI application server.
– Docker compose setups: One for development and one for deployment.
• Additional Tools:
– Django Debug Toolbar (for development diagnostics)
– Pytest (for testing, as managed inside a container)
Relationships and Data Flow
• User Requests Flow: Users (of various types – customer, admin, superuser) initiate requests via their browsers. The requests first hit Nginx, which routes them to Gunicorn serving the Django application.
• Internal Module Interactions: Inside Django, modular apps communicate through URL routing (as seen in the file structure under “urls.py” of each module) and shared middleware (perhaps for caching with Redis).
• Data Persistence: The Django app interacts with the PostgreSQL database for core data and utilizes MinIO for media storage.
• Caching and Performance: Redis is used to cache commonly accessed data.
• Payment Process: The payment module communicates with external APIs like ZarinPal.
• Development vs. Production Modes: Note the separate Docker configurations and settings (development using the Django Debug Toolbar and local recaptcha keys versus production with Nginx/Gunicorn and secure settings).
Architectural Patterns and Technologies
• Modular/Django “Apps” Pattern: Each functional aspect (accounts, cart, etc.) is in its own Django app.
• MVC (or MVT in Django): Separate the concerns with models, templated views, and controllers.
• Containerized Deployment: Using Docker containers to isolate services (backend, database, cache, media store, proxy server).
• API Layer: Some modules (like the accounts and shop modules) include API endpoints (e.g., under “api/v1”), which indicates RESTful design.