Skip to content

PHPxCODER/sendincraft

Repository files navigation

SendinCraft πŸ“§

A powerful, self-hosted email automation platform that makes sending transactional emails, marketing campaigns, and automated workflows simple and reliable.

✨ Features

  • πŸš€ Transactional Emails: Send emails programmatically via REST API
  • πŸ“Š Email Campaigns: Create and send marketing campaigns to your contacts
  • ⚑ Automation: Set up triggered email workflows based on user events
  • πŸ“ˆ Analytics: Track email opens, clicks, bounces, and delivery rates
  • πŸ”§ Templates: Create reusable email templates with dynamic content
  • πŸ‘₯ Contact Management: Manage subscriber lists and contact metadata
  • 🏷️ Event Tracking: Track user events and trigger automated responses
  • πŸ”’ Domain Verification: Verify your domains for better deliverability
  • πŸ“‹ Team Management: Collaborate with team members on projects
  • πŸ“± Dashboard: Intuitive web interface for managing everything

πŸ› οΈ Tech Stack

Backend

  • Node.js with TypeScript
  • Express.js with @overnightjs/core for API routing
  • Prisma ORM with PostgreSQL database
  • Redis for caching and session management
  • AWS SES for email delivery
  • Zod for schema validation
  • MJML for responsive email templates

Frontend

  • React with TypeScript
  • Next.js framework
  • Tailwind CSS for styling
  • Modern component architecture

Infrastructure

  • Docker support for easy deployment
  • Yarn Workspaces for monorepo management
  • Prisma Migrations for database schema management

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • Yarn 4.3.x
  • PostgreSQL database
  • Redis server
  • AWS SES credentials

Installation

  1. Clone the repository

    git clone https://github.com/PHPxCODER/sendincraft.git
    cd sendincraft
  2. Install dependencies

    yarn install
  3. Set up environment variables

    API Environment (.env)

    # Database
    DATABASE_URL=postgresql://username:password@localhost:5432/sendincraft
    
    # Redis
    REDIS_URL=redis://localhost:6379
    
    # JWT Secret
    JWT_SECRET=your-super-secret-jwt-key
    
    # AWS SES Configuration
    AWS_REGION=us-east-1
    AWS_ACCESS_KEY_ID=your-aws-access-key
    AWS_SECRET_ACCESS_KEY=your-aws-secret-key
    AWS_SES_CONFIGURATION_SET=your-ses-configuration-set
    
    # App URLs
    API_URI=http://localhost:4000
    APP_URI=http://localhost:3000
    
    # Optional: Disable signups
    DISABLE_SIGNUPS=false
  4. Set up the database

    yarn generate
    yarn migrate
  5. Start development servers

    # Start all services (PostgreSQL, Redis)
    yarn services:up
    
    # Start API server
    yarn dev:api
    
    # Start dashboard (in another terminal)
    yarn dev:dashboard
  6. Access the application

πŸ“ Project Structure

sendincraft/
β”œβ”€β”€ packages/
β”‚   β”œβ”€β”€ api/                 # Backend API server
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ controllers/ # API route controllers
β”‚   β”‚   β”‚   β”œβ”€β”€ services/    # Business logic
β”‚   β”‚   β”‚   β”œβ”€β”€ middleware/  # Express middleware
β”‚   β”‚   β”‚   β”œβ”€β”€ util/        # Utility functions
β”‚   β”‚   β”‚   └── database/    # Database configuration
β”‚   β”‚   └── package.json
β”‚   β”œβ”€β”€ dashboard/           # Frontend React app
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ components/  # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ pages/       # Next.js pages
β”‚   β”‚   β”‚   β”œβ”€β”€ hooks/       # Custom React hooks
β”‚   β”‚   β”‚   └── utils/       # Frontend utilities
β”‚   β”‚   └── package.json
β”‚   └── shared/              # Shared schemas and types
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   └── index.ts     # Zod schemas
β”‚       └── package.json
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma        # Database schema
β”‚   └── migrations/          # Database migrations
β”œβ”€β”€ docker-compose.dev.yml   # Development services
└── package.json             # Root package.json

πŸ”§ Configuration

Domain Setup

SendinCraft uses custom MAIL FROM domains for better email deliverability:

  1. Default Configuration: Emails are sent from sendincraft.yourdomain.com
  2. Custom Subdomain: You can specify custom subdomains like bounces.yourdomain.com
  3. DNS Records: The platform provides the required DNS records for setup

AWS SES Setup

  1. Create an AWS SES configuration set
  2. Set up SNS notifications for bounces, complaints, and delivery tracking
  3. Configure the webhook endpoint: https://yourapi.com/webhooks/incoming/sns

πŸ“– API Documentation

Authentication

All API endpoints require authentication via API keys:

  • Secret Key: sk_... for server-side operations
  • Public Key: pk_... for client-side tracking

Core Endpoints

Send Transactional Email

POST /v1/send
Authorization: Bearer sk_your_secret_key

{
  "to": ["[email protected]"],
  "subject": "Welcome!",
  "body": "<h1>Welcome to our platform!</h1>",
  "from": "[email protected]"
}

Track Events

POST /v1/track
Authorization: Bearer pk_your_public_key

{
  "email": "[email protected]",
  "event": "user-signup",
  "data": {
    "plan": "premium"
  }
}

Manage Contacts

POST /v1/contacts
Authorization: Bearer sk_your_secret_key

{
  "email": "[email protected]",
  "subscribed": true,
  "data": {
    "firstName": "John",
    "lastName": "Doe"
  }
}

🚒 Deployment

Docker Deployment

  1. Build the containers

    docker-compose up -d
  2. Run migrations

    docker-compose exec api yarn migrate:deploy

Environment Setup

Ensure all environment variables are properly configured for production:

  • Use strong JWT secrets
  • Configure proper database connections
  • Set up AWS SES with appropriate permissions
  • Configure Redis for production use

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“œ Scripts

Development

  • yarn dev:api - Start API development server
  • yarn dev:dashboard - Start dashboard development server
  • yarn dev:shared - Watch shared package for changes

Building

  • yarn build:api - Build API for production
  • yarn build:dashboard - Build dashboard for production
  • yarn build:shared - Build shared package

Database

  • yarn migrate - Run database migrations
  • yarn migrate:deploy - Deploy migrations to production
  • yarn generate - Generate Prisma client

Services

  • yarn services:up - Start development services (PostgreSQL, Redis)
  • yarn services:down - Stop development services

Utilities

  • yarn clean - Clean all dependencies and reinstall

πŸ”’ Security

  • All API endpoints are protected with proper authentication
  • JWT tokens for session management
  • Input validation using Zod schemas
  • SQL injection protection via Prisma ORM
  • Rate limiting and request validation

πŸ“Š Monitoring

The platform includes built-in analytics for:

  • Email delivery rates
  • Open and click tracking
  • Bounce and complaint monitoring
  • Contact growth metrics
  • Campaign performance

πŸ†˜ Troubleshooting

Common Issues

  1. Database Connection Issues

    • Verify PostgreSQL is running
    • Check DATABASE_URL format
    • Ensure database exists
  2. Redis Connection Issues

    • Verify Redis server is running
    • Check REDIS_URL configuration
  3. AWS SES Issues

    • Verify AWS credentials
    • Check SES service limits
    • Ensure domain verification is complete
  4. Email Delivery Issues

    • Check DNS records are properly configured
    • Verify domain verification status
    • Review AWS SES reputation

πŸ“„ License

This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Built with modern web technologies
  • Inspired by the need for self-hosted email automation
  • Community-driven development

Ready to send amazing emails? πŸš€

Start by setting up your first project and verifying your domain!

About

The most developer-friendly transactional email service.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published