Marketing Platform

Marketing Platform Implementation

Unified marketing platform combining contact management, data enrichment, campaign execution, and omnichannel communication

Key Features

Contact Management

CSV upload, enrichment queue, manual updates via chat interface, opt-out tracking

AI-Powered Enrichment

Multi-agent architecture with Firecrawl scraping, OpenAI analysis, source citation, human review

Campaign Execution

SMS via Sent.dm, Email via Postmark, targeting filters, smart send rules, rate limiting

Omnichannel Inbox

Chatwoot integration for SMS, Email, Facebook, Instagram, WhatsApp, Telegram responses

Meeting Booking

Cal.com webhooks to track bookings, link to contacts and campaigns

Ad Generation

AI-generated ad copy for Facebook, Google, LinkedIn with targeting suggestions

Daily Analytics

Track contacts per day, SMS/Email sent, responses, opt-outs, cost breakdown

Marketing History

Full timeline per contact showing all SMS, Emails, Ads, responses, meetings

System Architecture

Component Overview
How the platform components interact
┌─────────────────────────────────────────────────────────┐
│                    UNIFIED PLATFORM                      │
├─────────────────────────────────────────────────────────┤
│                                                           │
│  ┌─────────────┐  ┌──────────────┐  ┌─────────────┐    │
│  │   Contact   │  │  Enrichment  │  │  Campaign   │    │
│  │  Management │  │   Pipeline   │  │  Management │    │
│  └─────────────┘  └──────────────┘  └─────────────┘    │
│                                                           │
│  ┌─────────────┐  ┌──────────────┐  ┌─────────────┐    │
│  │  Marketing  │  │     Chat     │  │  Analytics  │    │
│  │   History   │  │  Interface   │  │  Dashboard  │    │
│  └─────────────┘  └──────────────┘  └─────────────┘    │
│                                                           │
│  ┌─────────────┐  ┌──────────────┐  ┌─────────────┐    │
│  │  Ad Copy    │  │     SMS      │  │    Email    │    │
│  │  Generator  │  │   (Sent.dm)  │  │ (Postmark)  │    │
│  └─────────────┘  └──────────────┘  └─────────────┘    │
│                                                           │
└─────────────────────────────────────────────────────────┘
                            │
                            ▼
                   ┌────────────────┐
                   │   PostgreSQL   │
                   │    Database    │
                   └────────────────┘
                            │
                   ┌────────┴────────┐
                   │                 │
                   ▼                 ▼
            ┌─────────────┐   ┌──────────┐
            │   Chatwoot  │   │   n8n    │
            │  (Inbox)    │   │ (Scrapers)│
            └─────────────┘   └──────────┘
                   │
                   ▼
            ┌─────────────┐
            │   Cal.com   │
            │  (Meetings) │
            └─────────────┘

Technology Stack

Frontend
React 19Vite 8TypeScriptTailwind CSS 4RechartsLucide Icons
Backend
Next.js 15 (API Routes)Prisma ORMPostgreSQLBullMQ + Redis
Authentication
Next-AuthSession Management
Communication
Sent.dm (SMS)Postmark (Email)Chatwoot (Omnichannel)Cal.com (Meetings)
AI & Enrichment
OpenAIFirecrawlMulti-agent Architecture
Automation
n8nWebhooksScheduled Jobs
Deployment
DockerCoolifynginxPostgreSQL (Supabase)

Database Schema

Core Tables
8 main tables with PostgreSQL + Prisma ORM

contacts

Core contact information with enriched data

emailphonenamecompanyenrichment_status

campaigns

SMS/Email/Ad campaign definitions

nametypestatustarget_filterstats

marketing_activities

Every SMS, Email, Ad interaction per contact

contact_idcampaign_idtypestatussent_at

daily_analytics

Aggregated daily metrics

datetotal_contactedsms_sentemails_sent

conversation_messages

Omnichannel messages (SMS, Email, Facebook, Instagram, WhatsApp)

contact_idchanneldirectionchatwoot_conversation_id

calendar_bookings

Cal.com meeting bookings

contact_idstart_timecalcom_booking_idstatus

enrichment_queue

Human review queue for enrichment

contact_idstatussuggested_datapriority

ad_campaigns

Social media ad campaigns

platformtargeting_criteriastatusspend_cents

Implementation Phases

Stage 1: Foundation

Database + Backend API

Pending

Goals:

  • Set up PostgreSQL database with Prisma ORM
  • Create backend API endpoints for contacts and campaigns
  • Migrate contractor-marketing to use API
  • Add basic authentication

Key Tasks:

  • Initialize Prisma and create schema
  • Create API endpoints (contacts, campaigns, analytics)
  • Refactor frontend to use API calls
  • Implement Next-Auth with credentials
Stage 2: Enrichment Pipeline

With Human Review

Pending

Goals:

  • Integrate fire-enrich-email enrichment engine
  • Add human-in-the-loop review interface
  • Create enrichment queue system
  • Add chat interface for manual updates

Key Tasks:

  • Extract enrichment core from fire-enrich-email
  • Build enrichment API endpoints
  • Create review interface with approval workflow
  • Implement chat-based contact updates
Stage 2.5: Omnichannel Communication

Chatwoot + Cal.com Integration

Pending

Goals:

  • Set up Chatwoot for unified inbox
  • Track responses across SMS, Email, Facebook, Instagram, WhatsApp
  • Integrate Cal.com for meeting bookings
  • Link all conversations to contacts

Key Tasks:

  • Deploy Chatwoot (self-hosted or cloud)
  • Connect all communication channels
  • Build Chatwoot webhook handler
  • Build Cal.com webhook handler
  • Update contact timeline with conversations
Stage 3: Marketing History & Analytics

Daily Tracking

Pending

Goals:

  • Track all marketing activities per contact
  • Build daily analytics dashboard
  • Prevent duplicate sends
  • Calculate contact frequency limits

Key Tasks:

  • Implement automatic activity tracking
  • Build daily analytics aggregation
  • Create analytics dashboard UI
  • Add contact history timeline view
Stage 4: Campaign Management

& Sending

Pending

Goals:

  • Create campaigns with targeting
  • Send SMS via Sent.dm
  • Send Email via Postmark
  • Real-time progress tracking

Key Tasks:

  • Build campaign builder interface
  • Integrate Postmark for email
  • Create campaign queue worker (BullMQ + Redis)
  • Set up delivery webhooks
Stage 5: Social Ad Generation
Pending

Goals:

  • Generate ad copy based on contact data
  • Create targeting suggestions
  • Support Facebook, Google, LinkedIn
  • Manual ad creation workflow

Key Tasks:

  • Build AI ad copy generator
  • Create targeting logic
  • Build ad builder interface
  • Manual performance tracking
Stage 6: n8n Integration
Pending

Goals:

  • Connect n8n scrapers to database
  • Automate contact import
  • Trigger enrichment from n8n
  • Two-way sync

Key Tasks:

  • Create webhook endpoints for n8n
  • Add API key authentication
  • Document n8n workflow patterns

Deployment

Docker + Coolify Deployment
Multi-stage Docker build with nginx serving

Frontend (Current Status)

  • • React 19 + Vite 8 + TypeScript
  • • Multi-stage Docker build (Node 20 Alpine → nginx Alpine)
  • • Deployed to Coolify via GitHub integration
  • • GitHub: devsupport-tech/marketing-platform

Backend (Planned)

  • • Next.js 15 API routes
  • • PostgreSQL database (Supabase or self-hosted)
  • • Redis for BullMQ queue
  • • Deployed to Coolify or Vercel

Dependencies

  • • Chatwoot (self-hosted or cloud)
  • • n8n (self-hosted on Coolify)
  • • Cal.com API
  • • Sent.dm, Postmark, OpenAI, Firecrawl (external APIs)