Next.jsDjangoReact企业官网

Agentic-Email-Campaign-Management-Platform — Next.js 企业官网模板

作者 MusfiqDehan

基于 Next.js 与 Django 的多租户邮件营销平台,支持联系人管理、模板编辑、批量邮件/SMS 发送与实时通知,并集成 AI 模板生成与自然语言联系人助手。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

2 个预览视图
桌面端首页1 / 2
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 2

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-04查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

多租户架构,按组织隔离联系人、模板、发件服务商与营销活动,支持 owner/admin/member 角色

02

支持 AWS SES 与 Gmail/Outlook SMTP 多服务商发送,凭据加密存储并按组织配置层级解析

03

集成 Gemini(DeepSeek 回退)生成邮件模板内容,并提供自然语言联系人管理助手端点

04

包含双向邮箱同步、第一方打开/点击追踪、SES/SendGrid/Brevo 送达事件 webhook

05

通过 Django Channels 与 WebSocket 提供实时应用内通知,并支持 Web 推送

06

提供 Docker Compose 配置、Traefik 生产部署指南与 GitHub Actions CI

模板详细介绍

这是一个多租户的邮件(及短信)营销平台,后端为 Django REST API,前端为 Next.js。每个组织拥有独立的联系人、模板、发件服务商与营销活动,成员角色分为 owner/admin/member。核心功能包括:创建、排期、启动、暂停、恢复、取消和复制邮件营销活动,支持测试发送与实时预览,并提供按活动的送达/打开/点击统计。联系人管理支持 CSV 批量导入、列表与分组统计,以及通过自然语言描述来创建、更新、搜索联系人的 AI 助手端点。模板方面提供富 HTML 编辑器、动态个性化变量、分类与预览,并可用 Gemini(DeepSeek 作为回退)生成模板内容。发送层支持 AWS SES 与 Gmail/Outlook SMTP,按组织配置层级解析,凭据加密存储,并带有健康检查与速率/配额限制;同时接收 SES、SendGrid、Brevo 的送达事件 webhook。平台还包含双向邮箱同步、第一方打开/点击追踪、基于规则的自动化触发邮件、通过 Twilio 发送 SMS/WhatsApp、基于 WebSocket 的应用内通知与 Web 推送。后端使用 PostgreSQL、Redis、Celery 与 Celery Beat、Django Channels 与 Daphne,JWT 认证,drf-spectacular 提供 OpenAPI 文档。前端使用 App Router、Tailwind CSS、Radix UI、React Hook Form 与 Zod、next-themes 等。仓库包含 Docker Compose 配置、Traefik 生产部署指南与 GitHub Actions CI。演示站可访问,但仓库中 mobile 目录为 Expo 脚手架,基本未使用。

Next.jsDjango企业官网

适合你的项目吗?

适用场景

  • 需要为多个组织或团队分别管理邮件营销活动与联系人列表的场景
  • 希望通过 CSV 批量导入联系人并利用 AI 生成邮件模板内容的团队
  • 需要在同一平台内切换 AWS SES 与 Gmail/Outlook SMTP 等发件服务商的场景
  • 需要追踪邮件打开、点击并接收送达事件通知的营销运营
  • 需要结合邮件、SMS 与 WhatsApp 触发式自动化的通知场景

适合人群

  • 具备 Django 与 Next.js 开发能力、希望自托管邮件营销平台的技术团队
  • 需要多租户隔离与角色权限管理的组织或 SaaS 产品原型
  • 需要集成 AI 模板生成与自然语言联系人操作的开发者
  • 希望使用 Docker Compose 与 Traefik 进行部署的运维人员

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    需要准备 PostgreSQL 与 Redis 服务,并配置对应的环境变量

  2. 2

    后端依赖 Python 3.12 与 Django 5.2,前端依赖 Next.js 16 与 React 19

  3. 3

    邮件发送需配置 AWS SES 或 Gmail/Outlook SMTP 凭据,SMS/WhatsApp 需配置 Twilio

  4. 4

    AI 模板生成与联系人助手需配置 Gemini API 密钥,DeepSeek 作为回退

  5. 5

    可使用仓库提供的 Docker Compose 或按 README 手动启动后端、前端与 Celery 工作进程

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 Apache-2.0 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发;分发时需随附 Apache-2.0 许可证。
  • 修改过的文件需显著标明改动,并保留相关版权、专利、商标及归属声明。
  • 若原项目附有 NOTICE 文件,分发衍生作品时需保留其中适用的归属声明。
  • 许可包含适用的贡献者专利授权;发起许可所述专利诉讼会终止该专利授权,且不授予商标使用权。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 Apache-2.0 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
  • 项目提供在线演示站点,但演示站仅为展示用途,实际使用需自行部署。
  • 运行平台必须自行准备 PostgreSQL 14+ 与 Redis 7+ 服务,属于外部依赖要求。
  • Docker 与 Docker Compose 为可选依赖,仅在使用容器化工作流时需要。
  • AI 模板生成与自然语言联系人助手需要配置 Gemini API 密钥,DeepSeek 作为回退密钥。
  • 邮件发送需自行配置 SMTP/SES 相关环境变量与凭据,属于外部服务要求。
  • 启用 Web 推送通知需自行生成并配置 VAPID 公钥、私钥与声明邮箱。
  • 发送速率与每日配额受环境变量限制,需按组织配置上限。
  • 统一生产 Compose 需要 Cloudflare Origin TLS 证书与真实反向代理,不适合在笔记本上独立运行。
  • 后端独立 Compose 依赖名为 dokploy-network 的外部 Docker 网络,需预先创建。
  • 前端独立 Compose 依赖名为 ecmp_network 的外部 Docker 网络,需预先创建。
  • apps.notifications、apps.platform_admins、apps.template_managers 为空占位目录,相关功能实际位于 apps.campaigns 中。
  • mobile 目录仅为 Expo 脚手架,基本未使用,不构成可用移动端功能。
  • 批量邮件发送与定时自动化必须额外运行 Celery worker 与 beat 进程。
  • 项目为生产风格的多租户应用,但 README 未对生产环境可用性作出保证。
查看原文依据

no-charge, royalty-free, irrevocable copyright license

许可证原文

**Live Demo:** https://emailcampaign.musfiqdehan.com

README 原文

**PostgreSQL** (14+) and **Redis** (7+) — locally installed, or run via Docker (see below)

README 原文

**Docker** + **Docker Compose** (optional, for the containerized workflow)

README 原文

| AI providers | `GEMINI_API_KEY`, `DEEPSEEK_API_KEY` (fallback) |

README 原文

| Email / SMTP / SES | `EMAIL_BACKEND`, `EMAIL_HOST(_USER/_PASSWORD)`, `EMAIL_PORT`, `EMAIL_USE_TLS/SSL`, `DEFAULT_FROM_EMAIL` |

README 原文

| Web push (VAPID) | `VAPID_PUBLIC_KEY`, `VAPID_PRIVATE_KEY`, `VAPID_CLAIM_EMAIL` |

README 原文

| Sending limits | `ORG_PROVIDER_MAX_RATE_PER_SECOND/MINUTE/HOUR`, `ORG_PROVIDER_MAX_DAILY_QUOTA` |

README 原文

It expects Cloudflare Origin TLS certs at `nginx/certs/` and a real reverse proxy in front of it, so it isn't meant to be run standalone on a laptop.

README 原文

docker network create dokploy-network # skip if it already exists

README 原文

docker network create ecmp_network # skip if it already exists

README 原文

`apps.notifications`, `apps.platform_admins`, and `apps.template_managers` are empty placeholder > directories — notification and admin functionality actually lives inside `apps.campaigns`.

README 原文

├── mobile/ # Expo scaffold (minimal/unused)

README 原文

Required for bulk email sending and scheduled automation — run these alongside the backend:

README 原文

It's built as a production-style **multi-tenant** application

README 原文
https://github.com/MusfiqDehan/Agentic-Email-Campaign-Management-Platform/blob/main/LICENSEhttps://github.com/MusfiqDehan/Agentic-Email-Campaign-Management-Platform/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-04。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 88 / 100
技术栈
Next.js · Django · React
网站类型
企业官网
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-10-04
截图检查日期
2026-10-04

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

审核声明: [email protected] · 2026-10-04

查看当时使用的来源资料

SHA-256: b0bd7ca8554a4d8fb164e4c0446a702101893c54fb0346e42407e880096272b2

2026-10-04T11:17:34.892Z

来源文件 / 仓库
# 📧 Email Campaign Management Platform

A multi-tenant, AI-assisted email (and SMS) campaign management platform. Organizations manage contacts, build reusable templates, run bulk campaigns across multiple providers (AWS SES, Gmail/Outlook SMTP), and get real-time delivery notifications — with generative AI template creation and an agentic, natural-language contact-management assistant built in.

**Live Demo:** https://emailcampaign.musfiqdehan.com

![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)
![Python](https://img.shields.io/badge/Python-3.12-blue.svg)
![Django](https://img.shields.io/badge/Django-5.2-092E20.svg)
![Next.js](https://img.shields.io/badge/Next.js-16-black.svg)
![React](https://img.shields.io/badge/React-19-61DAFB.svg)
![TypeScript](https://img.shields.io/badge/TypeScript-5-3178C6.svg)

![Homepage of website](frontend/public/screenshot.png)

---

## 📑 Table of Contents

- [Project Overview](#-project-overview)
- [Features](#-features)
- [Tech Stack](#-tech-stack)
- [Architecture](#-architecture)
- [Project Structure](#-project-structure)
  - [Root Directory](#root-directory)
  - [Backend (`backend/`)](#backend-backend)
  - [Frontend (`frontend/`)](#frontend-frontend)
- [Getting Started](#-getting-started)
  - [Prerequisites](#prerequisites)
  - [Environment Variables](#environment-variables)
- [Running Locally (Manual Setup)](#-running-locally-manual-setup)
  - [1. Backend (Django)](#1-backend-django)
  - [2. Frontend (Next.js)](#2-frontend-nextjs)
  - [3. Background Workers (Celery)](#3-background-workers-celery)
- [Running with Docker](#-running-with-docker)
  - [Per-service Compose (local development)](#per-service-compose-local-development)
  - [Unified Production Compose](#unified-production-compose)
- [API Documentation](#-api-documentation)
- [Testing & Linting](#-testing--linting)
- [AI Tools Used](#-ai-tools-used)
- [Key Learnings](#-key-learnings)
- [Areas for Improvement](#-areas-for-improvement)
- [License](#-license)

---

## 🧭 Project Overview

This is an end-to-end **Email Campaign Management Platform** that allows organizations to manage contacts, create reusable templates, launch bulk email/SMS campaigns, and monitor delivery progress from a single system. It's built as a production-style **multi-tenant** application — each organization owns its own contacts, templates, providers, and campaigns, with role-based membership (owner/admin/member).

Beyond core campaign management, the platform includes:

- **Generative AI** support for email template creation (Gemini, with a DeepSeek fallback)
- An **agentic, natural-language contact-management** endpoint — manage contacts by describing what you want in plain English
- A **bidirectional mailbox** with first-party email open/click tracking
- **Multi-provider** sending (AWS SES, Gmail/Outlook SMTP) resolved per-organization at send time
- **Real-time** in-app and web-push notifications over WebSockets

---

## ✨ Features

### 🎯 Campaign Management
- Create, schedule, launch, pause, resume, cancel, and duplicate email campaigns
- Test-send and live preview before launch
- Per-campaign analytics with delivery/open/click stats and stat refresh

### 👥 Contact Management
- Contacts and contact lists with bulk CSV import
- Agentic, natural-language contact operations (create/update/search contacts via AI)
- Contact segmentation and list-level stats

### 📝 Templates
- Rich HTML template editor with dynamic personalization variables
- AI-generated template content (Gemini primary, DeepSeek fallback)
- Template categories, admin-curated templates, and previews

### 📬 Multi-Provider Email Delivery
- AWS SES and Gmail/Outlook SMTP, resolved per-organization via a config hierarchy
- Encrypted storage of provider credentials
- Provider health checks and rate/quota limiting (per-second/minute/hour/day)
- Delivery event webhooks from SES, SendGrid, and Brevo, plus a delivery log with resend/forward

### 📥 Mailbox & Tracking
- Bidirectional mailbox sync (send & receive) with a message inbox
- First-party open/click tracking pixels & redirect links

### 🔁 Automation
- Rule-based automation for triggered emails
- SMS and WhatsApp trigger campaigns (via Twilio)

### 🔔 Real-Time Notifications
- WebSocket-based in-app notifications (Django Channels)
- Web push notifications (VAPID)

### 🏢 Multi-Tenancy & Admin
- Organizations, membership roles (owner/admin/member), and per-org settings
- Platform-admin views for cross-tenant provider/organization management

### 🎨 Modern UI/UX
- Responsive dashboard with dark/light theme (system-aware)
- Animated, interactive landing page (SVG micro-interactions, pricing, growth/process visuals)

### 🔐 Security
- JWT authentication (access + refresh) with real DB-backed users
- Encrypted provider credentials, soft-delete on core models, org-scoped permissions

---

## 🛠 Tech Stack

### Backend

| Technology | Purpose |
|---|---|
| **Python 3.12** | Core language |
| **Django 5.2** + **DRF 3.15** | Web framework & REST API |
| **PostgreSQL** | Primary database |
| **Redis** | Celery broker/result backend & Channels layer |
| **Celery 5.3** + **Celery Beat** | Async & scheduled tasks (bulk email/SMS, automation) |
| **Django Channels** + **Daphne** | WebSocket notifications (ASGI) |
| **SimpleJWT** | JWT authentication |
| **drf-spectacular** | OpenAPI schema, Swagger UI, ReDoc |
| **django-ses**, **boto3** | AWS SES email provider |
| **Twilio** | SMS / WhatsApp sending |
| **SendGrid**, Brevo webhooks | Alternate delivery provider + inbound/event webhooks |
| **pywebpush** / **py-vapid** | Web push notifications |
| **google-genai** (Gemini) | AI template generation & the agentic contact assistant |
| **django-health-check** | `/api/v1/healthz/` liveness endpoint |
| **Gunicorn** / **Daphne** | Production servers (WSGI/ASGI) |
| **pytest**, **flake8**, **black** | Testing & code quality |

### Frontend

| Technology | Purpose |
|---|---|
| **Next.js 16** (App Router) | React framework |
| **React 19** + **TypeScript 5** | UI & type safety |
| **Tailwind CSS 4** | Styling |
| **Radix UI** + `class-variance-authority` | Accessible UI primitives (shadcn/ui-style) |
| **React Hook Form** + **Zod** | Forms & validation |
| **next-themes** | Dark/light theming |
| **Axios** | HTTP client |
| **React Quill (new)** | Rich text template editor |
| **Sonner** | Toast notifications |
| **Lucide React** | Icons |

### DevOps & Tooling

| Technology | Purpose |
|---|---|
| **Docker** / **Docker Compose** | Containerization (per-service & unified) |
| **Traefik** | Reverse proxy & TLS termination in production |
| **GitHub Actions** | CI (`check`, migration check, `manage.py test --parallel` against Postgres+Redis service containers) |
| **Nginx** | Static/reverse-proxy config for select deployments |

---

## 🏗 Architecture

```
┌──────────────────────────────────────────────────────────────────┐
│                          CLIENT LAYER                             │
│  Next.js 16 (React 19 + TypeScript)                               │
│  App Router · Tailwind + Radix UI · Axios · WebSocket hooks       │
└──────────────────────────────────────────────────────────────────┘
                               │  REST (JSON) + WebSocket
                               ▼
┌──────────────────────────────────────────────────────────────────┐
│                            API LAYER                               │
│  Django REST Framework · JWT Auth · Org-scoped permissions        │
│  Django Channels (ws/notifications/) served over Daphne (ASGI)    │
└──────────────────────────────────────────────────────────────────┘
                               │
                               ▼
┌──────────────────────────────────────────────────────────────────┐
│                       APPLICATION LAYER (apps.campaigns)           │
│  Campaigns · Contacts · Templates · Providers · Automation        │
│  Mailbox & Tracking · SMS/WhatsApp · Notifications · Admin         │
└──────────────────────────────────────────────────────────────────┘
                │                     │                     │
                ▼                     ▼                     ▼
      ┌─────────────────┐   ┌─────────────────┐   ┌─────────────────┐
      │   PostgreSQL     │   │      Redis       │   │      Celery      │
      │   (database)     │   │ (broker/cache/   │   │ (async & beat    │
      │                  │   │  channel layer)  │   │  scheduled tasks)│
      └─────────────────┘   └─────────────────┘   └─────────────────┘
                                                             │
                                                             ▼
                                          ┌───────────────────────────────┐
                                          │  AWS SES · Gmail/Outlook SMTP  │
                                          │  Twilio (SMS/WhatsApp)          │
                                          │  SendGrid / Brevo webhooks      │
                                          └───────────────────────────────┘
```

Email sending flow: organization config → `hierarchy_resolver` resolves the effective provider config → `ProviderBackendResolver` builds the right Django email backend → `unified_email_sender` sends it — one code path supporting SES, SMTP, or console/test sending interchangeably.

---

## 📁 Project Structure

### Root Directory

```
Email-Campaign-Management-Platform/
├── README.md                 # This file
├── DEPLOYMENT.md             # Full production/VPS deployment guide (Traefik + Cloudflare)
├── LICENSE                   # Apache 2.0
├── docker-compose.yml        # Unified production stack (Postgres, Redis, backend, Celery, frontend)
├── .env.example               # Environment variable reference for the unified compose
├── backend/                   # Django REST API
├── frontend/                  # Next.js dashboard & landing site
├── frontend-newsletter/       # Static embeddable newsletter signup widget
├── mobile/                    # Expo scaffold (minimal/unused)
└── nginx/                     # Reverse proxy config for select deployments
```

### Backend (`backend/`)

```
backend/
├── manage.py
├── requirements.txt
├── Dockerfile / docker-compose.yml / docker_entrypoint.sh
├── config/                    # Django project config
│   ├── settings.py
│   ├── urls.py                # /api/v1/auth, /api/v1/campaigns, /api/v1/healthz, /api/v1/schemas
│   ├── asgi.py                # Channels ProtocolTypeRouter (WebSocket)
│   ├── wsgi.py
│   └── celery.py
├── core/                       # Response envelope & centralized exception handling
│   ├── mixins.py               # ResponseMixin (aliased as CustomResponseMixin)
│   ├── exceptions.py           # custom_exception_handler (DRF EXCEPTION_HANDLER)
│   └── utils.py
├── apps/
│   ├── authentication/         # User, Organization, OrganizationMembership, JWT, permissions
│   │   ├── models.py / views.py / serializers.py / permissions.py / signals.py
│   │   ├── services/
│   │   └── management/commands/   # create_superuser, create_platform_admin,
│   │                                 create_user_organizations, assign_user_organization, list_users_orgs
│   ├── campaigns/               # Core app — the bulk of the business logic
│   │   ├── models/               # campaign, contact, email_config, provider, automation_rule,
│   │   │                            email_tracking, notification, push, sms_config, mailbox, org_email_config
│   │   ├── views/                 # campaign, admin, enhanced, template_operations, admin_templates,
│   │   │                            organization_admin, notification, push, sms_automation,
│   │   │                            email_automation, variable, ai_gen, contact_agent, mailbox,
│   │   │                            tracking, provider_webhooks, unsubscribe, debug
│   │   ├── serializers/           # campaign, admin, enhanced, push, mailbox, base
│   │   ├── utils/                  # email_providers, unified_email_sender, hierarchy_resolver,
│   │   │                            tenant_service, crypto, template_utils, variable_registry,
│   │   │                            ai_client, sms_utils, push_utils, mailbox_sync, email_tracking
│   │   ├── management/commands/   # generate_encryption_key, sync_email_providers,
│   │   │                            check_email_providers_health
│   │   ├── tasks.py                # Celery tasks for async/bulk sending
│   │   ├── backends.py             # ProviderBackendResolver (SES/SMTP/console)
│   │   ├── consumers.py / routing.py  # WebSocket notification consumer
│   │   ├── ses_event_handlers.py
│   │   └── migrations/
│   ├── notifications/, platform_admins/, template_managers/   # placeholder apps (not wired up)
│   └── utils/                   # BaseModel (soft-delete), pagination, filters, throttles, mixins
├── static/ · staticfiles/       # Collected static assets
└── media/ · media_files/        # User-uploaded assets (logos, profile images)
```

> `apps.notifications`, `apps.platform_admins`, and `apps.template_managers` are empty placeholder
> directories — notification and admin functionality actually lives inside `apps.campaigns`.

### Frontend (`frontend/`)

```
frontend/
├── package.json / tsconfig.json / next.config.ts / eslint.config.mjs
├── Dockerfile / docker-compose.yml
├── app/                          # Next.js App Router
│   ├── page.tsx                  # Marketing landing page
│   ├── layout.tsx / globals.css
│   ├── login/ · signup/ · reset-password/ · verify-email/ · unsubscribe/
│   └── dashboard/                # Authenticated app
│       ├── layout.tsx / page.tsx
│       ├── campaigns/ · contacts/ · templates/ · inbox/
│       ├── logs/ · notifications/ · team/ · admin/
│       └── settings/ · profile/
├── components/
│   ├── ui/                       # Radix-based primitives (button, dialog, table, tabs, ...)
│   ├── dashboard/                # sidebar, header, notification settings, floating AI agent input
│   ├── landing/                  # Animated SVG landing sections (hero, growth chart, network bg, ...)
│   ├── brand-logo.tsx / editor.tsx / providers.tsx
├── config/                       # axios client, constants, template & general utils
├── contexts/                     # AuthContext
├── hooks/                        # useNotifications, usePushNotifications, useRealtimeUpdates, ...
├── services/                     # auth.ts, campaigns.ts, notifications.ts — thin API wrappers
└── public/                       # Static assets (logo, icons, service worker)
```

---

## 🚀 Getting Started

### Prerequisites

- **Python 3.12+**
- **Node.js 20+** and npm
- **PostgreSQL** (14+) and **Redis** (7+) — locally installed, or run via Docker (see below)
- **Docker** + **Docker Compose** (optional, for the containerized workflow)

### Environment Variables

The backend and frontend each read from their own `.env` files, plus the repo root has a `.env.example` used by the unified Docker Compose stack. Copy the example and fill in values before running anything:

```bash
cp .env.example .env               # for the unified/root docker-compose.yml
cp backend/.env.example backend/.env
```

Key variable groups (see `.env.example` for the full list with comments):

| Group | Variables |
|---|---|
| Django core | `DEBUG`, `SECRET_KEY`, `SIGNING_KEY`, `EMAIL_CONFIG_ENCRYPTION_KEY`, `ALLOWED_HOSTS` |
| PostgreSQL | `POSTGRES_ENGINE`, `POSTGRES_DB`, `POSTGRES_USER`, `POSTGRES_PASSWORD`, `POSTGRES_HOST`, `POSTGRES_PORT` |
| Redis | `REDIS_HOST`, `REDIS_PASSWORD` |
| Frontend build args | `NEXT_PUBLIC_API_URL`, `NEXT_PUBLIC_WS_URL`, `NEXT_PUBLIC_VAPID_PUBLIC_KEY` |
| Email / SMTP / SES | `EMAIL_BACKEND`, `EMAIL_HOST(_USER/_PASSWORD)`, `EMAIL_PORT`, `EMAIL_USE_TLS/SSL`, `DEFAULT_FROM_EMAIL` |
| Web push (VAPID) | `VAPID_PUBLIC_KEY`, `VAPID_PRIVATE_KEY`, `VAPID_CLAIM_EMAIL` |
| AI providers | `GEMINI_API_KEY`, `DEEPSEEK_API_KEY` (fallback) |
| Sending limits | `ORG_PROVIDER_MAX_RATE_PER_SECOND/MINUTE/HOUR`, `ORG_PROVIDER_MAX_DAILY_QUOTA` |
| Bootstrap superuser | `DJANGO_SUPERUSER_USERNAME/EMAIL/PASSWORD/FIRST_NAME/LAST_NAME` |

Generate the required secrets with:

```bash
# EMAIL_CONFIG_ENCRYPTION_KEY
python manage.py generate_encryption_key

# SECRET_KEY / SIGNING_KEY
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"

# VAPID keys (web push)
python -c "from py_vapid import Vapid; v = Vapid(); v.generate_keys(); print(v.private_pem().decode()); print(v.public_key)"
```

---

## 💻 Running Locally (Manual Setup)

### 1. Backend (Django)

```bash
cd backend
python -m venv .venv
source .venv/bin/activate          # Windows: .venv\Scripts\activate

pip install -r requirements.txt
cp .env.example .env               # then fill in DB/Redis/secret values

# Make sure PostgreSQL & Redis are running and reachable per your .env

python manage.py migrate
python manage.py create_superuser --username admin --email [email protected] --password <password> --force
python manage.py create_user_organizations   # backfill an org for the new user, if needed

python manage.py runserver 8001    # plain dev server — fine for non-WebSocket work
# or, to exercise WebSocket notifications:
daphne -p 8001 -b 0.0.0.0 config.asgi:application
```

> The checked-in `frontend/.env.local` already points to `http://localhost:8001` — running the backend on
> port `8001` (as above) means the frontend works with zero extra config. Use plain `runserver` on its
> default port 8000 instead and the frontend just needs `NEXT_PUBLIC_API_URL`/`NEXT_PUBLIC_WS_URL` updated
> to match.

The API is now available at `http://localhost:8001/api/v1/`.

### 2. Frontend (Next.js)

```bash
cd frontend
npm install                        # use `npm ci --legacy-peer-deps` if npm complains (React 19 peer deps)
# frontend/.env.local already sets NEXT_PUBLIC_API_URL / NEXT_PUBLIC_WS_URL to http://localhost:8001 — edit if needed

npm run dev
```

The dashboard is now available at `http://localhost:3000`.

### 3. Background Workers (Celery)

Required for bulk email sending and scheduled automation — run these alongside the backend:

```bash
cd backend
celery -A config.celery worker --loglevel=info
celery -A config.celery beat --loglevel=info --scheduler django_celery_beat.schedulers:DatabaseScheduler
```

---

## 🐳 Running with Docker

### Per-service Compose (local development)

Each app ships its own `docker-compose.yml` for spinning it up in isolation. Both reference an **external** Docker network, so create it once before the first run:

```bash
# Backend — Django, PostgreSQL, Redis, Celery worker & beat
cd backend
cp .env.example .env
docker network create dokploy-network      # skip if it already exists
docker compose up -d --build

docker compose exec backend python manage.py migrate
docker compose exec backend python manage.py create_superuser --username admin --email [email protected] --password <password> --force
docker compose logs -f backend
```

- API → `http://localhost:8001/api/v1/`
- PostgreSQL → `localhost:5441`, Redis → `localhost:6391`

```bash
# Frontend — Next.js (standalone build)
cd frontend
docker network create ecmp_network         # skip if it already exists
docker compose up -d --build
```

- App → `http://localhost:3001` (defaults to talking to the backend above via `NEXT_PUBLIC_API_URL=http://localhost:8001/api/v1`)

Stop either stack with `docker compose down` from its directory.

### Unified Production Compose

The root [`docker-compose.yml`](docker-compose.yml) builds the **full stack** (PostgreSQL, Redis, backend on Daphne, Celery worker + beat, and the frontend) as it's actually deployed in production — fronted by **Traefik** on an external `traefik_proxy` network, with the app services only `expose`d (not published) to the host. It expects Cloudflare Origin TLS certs at `nginx/certs/` and a real reverse proxy in front of it, so it isn't meant to be run standalone on a laptop.

For the full VPS deployment walkthrough (DNS, certs, firewall, `docker compose up -d --build`, health checks, and troubleshooting), see **[DEPLOYMENT.md](DEPLOYMENT.md)**.

---

## 📚 API Documentation

Once the backend is running (adjust the port to match how you started it — `8001` in the examples above):

- **Swagger UI** — `http://localhost:8001/api/v1/schemas/swagger-ui/`
- **ReDoc** — `http://localhost:8001/api/v1/schemas/redoc`
- **OpenAPI schema (JSON)** — `http://localhost:8001/api/v1/schemas/swagger.json`
- **Health check** — `http://localhost:8001/api/v1/healthz/`

All application endpoints are namespaced under `/api/v1/auth/` (authentication) and `/api/v1/campaigns/` (campaigns, contacts, templates, providers, automation, SMS, mailbox, tracking, webhooks, admin).

---

## ✅ Testing & Linting

```bash
# Backend (Django's own test runner, not pytest, despite pytest-django being installed)
cd backend
python manage.py test
python manage.py test apps.campaigns.tests.test_email_logs
python manage.py check
python manage.py migrate --check --dry-run
flake8
black --check .

# Frontend
cd frontend
npm run lint
npx tsc --noEmit
```

CI (`.github/workflows/deploy.yml`) runs the same `check` → migration check → `manage.py test --verbosity=2 --parallel` sequence against Postgres + Redis service containers — mirror that locally before opening a PR.

---

## 🤖 AI Tools Used

- **Claude Code CLI** — code generation, problem-solving, and architectural guidance
- **GitHub Copilot** — real-time code suggestions and productivity improvements

---

## 📖 Key Learnings

During development, this project was an exercise in both system design and real-world production challenges:

**AI Integration**
- Integrated GenAI features across frontend and backend within an existing codebase
- Designed workflows for AI-assisted template generation and natural-language-driven operations

**Email Campaign System Design**
- Studied industry-standard email marketing platforms to understand campaign workflows and best practices
- Implemented dynamic email templates with variables and trigger-based campaign execution
- Built subscriber collection mechanisms using external APIs

**Email Infrastructure & Deliverability**
- Integrated **AWS SES** for scalable email automation
- Supported multiple email providers (SES, Gmail SMTP) with dynamic, per-organization provider selection
- Applied DNS-level configuration (SPF, DKIM, DMARC) to improve deliverability and avoid spam classification

**Backend Engineering & Scalability**
- Designed asynchronous email processing with **Celery** for bulk delivery
- Implemented real-time notifications using **WebSockets** for in-app and push notifications

**DevOps & Deployment**
- Deployed frontend and backend behind **Traefik**/**Nginx** on a cloud VPS
- Managed static assets and backups
- Built CI/CD pipelines with **GitHub Actions** for automated testing and deployment

**Security & Best Practices**
- Implemented unsubscribe mechanisms and email compliance standards
- Applied best practices for secure email template rendering, credential encryption, and campaign execution

---

## 🔭 Areas for Improvement

- Expanding support for additional email providers beyond AWS SES and Gmail/Outlook SMTP
- Extending agentic (AI-driven) capabilities across more workflows within the platform
- Enhancing analytics with additional metrics — bounce rate, deliverability scoring, cohort engagement, etc.
- Wiring up the currently-placeholder `apps.notifications`, `apps.platform_admins`, and `apps.template_managers` apps

---

## 📄 License

Licensed under the **Apache License 2.0** — see [LICENSE](LICENSE) for details.
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。