How amazingcoderpro/email-distribution-management-system works
Project type and purpose
• This is a full-stack Email-Direct-Marketing (EDM) system built on Django.
• It exposes a REST API for a separate JS frontend (dist), integrates with Shopify (OAuth + Webhooks), Google Analytics, and an EMS (email sending) service, and runs scheduled data-processing/email tasks.
File structure
• Top-level:
• manage.py, run_task.py – entry points for web and batch processes
• config.py – centralizes settings
• Pipfile/Pipfile.lock – Python deps via Pipenv
• “edm/”: Django project (urls.py, wsgi.py)
• “app/”: Core Django app (models, views, serializers, filters, middleware, migrations)
• “sdk/”: External-service clients:
– sdk/shopify – OAuth, Webhook handling, data fetch
– sdk/googleanalytics – OAuth + reporting API
– sdk/ems – send email via EMS API
• “task/”: Batch jobs invoked by run_task.py (customer-group processing, data migration, recommendations, statistics, email template dispatch)
• “bin/”: Deployment scripts & configs for Gunicorn & Supervisor
README for deployment & architecture hints
• MySQL database initialization via raw SQL inserts
• Nginx serves static frontend (dist/) and proxies “/api” to Gunicorn:8000
• Supervisor manages two processes: Gunicorn (web) and run_task.py (workers)
a. Main components:
• Client Browser (JS frontend)
• Nginx (static file server + reverse proxy)
• Supervisor → Gunicorn (Django WSGI)
• Django Application
– URL Router (edm/urls.py + app/urls.py)
– API Views (app/views)
– Serializers (app/serializers)
– Business Filters/Services (app/filters, app/utils)
– ORM Models & Migrations (app/models, app/migrations)
• MySQL Database
• Supervisor → run_task.py (Batch Worker)
– task modules (task/*.py)
• External Services (Shopify, Google Analytics, EMS)
b. Relationships & data flows:
• Browser ↔ Nginx:
– GET “/” → static HTML/CSS/JS
– GET/POST “/api/*” → proxied → Gunicorn:8000
• Nginx → Gunicorn → Django: WSGI calls → Views → Serializers → Models → MySQL
• Django ↔ External SDKs: HTTP calls for OAuth flows, data fetch, webhook handling
• Scheduler (Supervisor) launches run_task.py on cron or interval → Task modules → read/write DB & call External APIs asynchronously
c. Architectural patterns & principles:
• Monolithic MVC (Django) with clear layers (views, serializers, filters, models)
• Reverse-proxy pattern (Nginx) separating static vs dynamic content
• Asynchronous processing via separate worker processes
• Dependency injection via sdk/ modules
d. Key technologies/frameworks:
• Python 3 + Django, Pipenv
• Gunicorn + Supervisor (bin/gunicorn.py, supervisord.conf)
• Nginx
• MySQL
• JavaScript frontend (built into dist/)
• External APIs: Shopify, Google Analytics, EMS