Skip to content

DARPAI/mailing-api

Repository files navigation

Mailing API

A microservice-based email notification system that provides a REST API for sending various types of email notifications.

Architecture

The system consists of the following components:

  • API Service: A FastAPI application that receives email requests, formats them using Jinja2 templates, and sends them to Kafka.
  • Worker Service: Consumes email messages from Kafka and sends them via SMTP.
  • Kafka: Message broker for asynchronous processing of email requests.
  • Zookeeper: Required for Kafka operation.
  • PostgreSQL: Database for storing email-related data.

Features

  • Send email notifications for various events:
    • Server deployment success notifications
    • Server healthcheck failure alerts
    • User email confirmations
  • HTML email templates
  • Asynchronous processing via Kafka
  • Scalable microservice architecture

Setup

Prerequisites

  • Docker and Docker Compose
  • Environment variables for email provider configuration

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd mailing-api
  2. Configure environment variables: Create a .env file with the following variables:

    MAILING_API_IMAGE_NAME=mailing-api:latest
    MAILING_WORKER_IMAGE_NAME=mailing-worker:latest
    EMAIL_PROVIDER_ADDRESS=your-email@example.com
    EMAIL_PROVIDER_HOST=smtp.example.com
    EMAIL_PROVIDER_USERNAME=your-username
    EMAIL_PROVIDER_PASSWORD=your-password
    EMAIL_PROVIDER_PORT=587
    
  3. Start the services:

    docker-compose up -d

Development

For development purposes, use the development compose file:

docker-compose -f compose-dev.yaml up -d

This will:

  • Mount local directories as volumes for hot-reloading
  • Use development-specific run scripts
  • Expose necessary ports for local development

API Endpoints

Email Notifications

  • POST /v1/emails/server-success-deploy

    • Sends a notification about successful server deployment
    • Requires: recipient email, subject, and deployment details
  • POST /v1/emails/server-healthcheck-failed

    • Sends a notification about failed server healthchecks
    • Requires: recipient email, subject, and server details
  • POST /v1/emails/email-confirmation

    • Sends an email confirmation message
    • Requires: recipient email, subject, and confirmation details

Configuration

The system can be configured using environment variables:

Worker Service

  • MAILING_WORKER_HOST: Hostname for the worker service
  • MAILING_WORKER_PORT: Port for the worker service
  • MAILING_WORKER_DB_*: Database connection parameters
  • EMAIL_PROVIDER_*: Email provider configuration

About

to.ci notification API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published