Skip to content

๐Ÿ“ค Dynamic Notification System Documentation

๐Ÿ“ Overview

The Dynamic Notification System is a platform designed for managing โฐ jobs and sending ๐Ÿ“ง via multiple ๐Ÿ“ก. It supports:

  • ๐Ÿ“ฅ Dynamic ๐Ÿ”Œ for various ๐Ÿ“ฌ methods.
  • Managing โฐ jobs through a โฑ๏ธ-based scheduler.
  • ๐ŸŒ APIs for creating and managing jobs.

โญ Features

  • ๐Ÿ”„ Multi-platform Support: Send notifications via ๐Ÿ“ง, Slack, SMS, and Webhooks.
  • ๐Ÿ”Œ Dynamic Plugin System: Load ๐Ÿ“ฌ ๐Ÿ”Œ dynamically based on the โš™๏ธ.
  • ๐Ÿ—„๏ธ Database Integration: Store โฐ jobs and their execution ๐Ÿ“œ in a ๐Ÿฌ database.
  • โฑ๏ธ Scheduler: Manage job โฐ and ensure timely execution.
  • ๐ŸŒ API:
    • โœ๏ธ Create new jobs.
    • ๐Ÿ“„ Retrieve existing jobs.
  • โš ๏ธ Error Handling: Gracefully handle ๐Ÿšจ and ๐Ÿ”— issues.

๐Ÿ—๏ธ Architecture

๐Ÿงฉ Components

  1. โš™๏ธ Configuration Loader:

    • ๐Ÿ› ๏ธ Reads settings from a ๐Ÿ—‚๏ธ YAML โš™๏ธ file.
    • Configures ๐Ÿฌ, ๐Ÿ”Œ, and ๐Ÿ–ฅ๏ธ behavior.
  2. ๐Ÿ—„๏ธ Database:

    • ๐Ÿ› ๏ธ Stores job metadata, including โฐ expressions, ๐Ÿ“ฌ details, and execution ๐Ÿ“œ.
  3. ๐Ÿ”Œ Plugins:

    • Dynamically loaded ๐Ÿ“ฌ ๐Ÿ”Œ to send ๐Ÿ“จ through different ๐Ÿ“ก (e.g., ๐Ÿ“ง, ๐Ÿ“ฉ, ๐Ÿ’ฌ).
  4. โฑ๏ธ Scheduler:

    • Based on the cron ๐Ÿ› ๏ธ.
    • Executes โฐ jobs at specified ๐Ÿ•’.
  5. ๐ŸŒ API:

    • Built with Gorilla Mux for ๐Ÿ›ฃ๏ธ.
    • Provides ๐Ÿ”— for job management.

๐Ÿ› ๏ธ Setup and Installation

๐Ÿงพ Prerequisites

  • ๐Ÿน Go (version 1.23+)
  • ๐Ÿฌ MySQL database (docker compose includes one)
  • ๐Ÿ—‚๏ธ YAML โš™๏ธ file

๐Ÿ“ฆ Installation Steps

  1. Clone the repository:
    git clone https://github.com/zrougamed/dynamic-notification-system.git
    cd dynamic-notification-system
    
  2. Build the application:
    make all
    
  3. Configure the application:
  4. Create a config.yaml file:

scheduler: true
database:
    host: localhost
    port: 3306
    user: root
    password: password
    name: notifications
channels:
    email:
        enabled: true
        smtp_server: "smtp.example.com"
        smtp_port: 587
        username: "your-email@example.com"
        password: "your-password"
    sms:
        enabled: false
        provider_api: "https://sms-provider.com/api"
        api_key: "your-sms-api-key"
4. Run the application:
./dynamic-notification-system


๐Ÿ“š Table of Contents

  1. Getting Started
  2. Usage
  3. Developer Guide
  4. Main Module
  5. Scheduler Module
  6. Notifier Module
  7. Config Module
  8. Contributing

๐ŸŒ API Endpoints

๐Ÿ“ค POST /jobs

  • ๐Ÿ“„ Description: Create a new scheduled job.
  • ๐Ÿ“ Request Body:
    {
    "name": "Job Name",
    "notification_type": "email",
    "recipient": "example@example.com",
    "message": {
        "title": "Server Alert ๐Ÿšจ",
        "text": "Disk space is low on server",
        "priority": "high"
    },
    "schedule_expression": "0 9 * * *"
    }
    
  • ๐Ÿ“ฌ Response:
    {
    "id": 1,
    "name": "Job Name",
    "notification_type": "email",
    "recipient": "example@example.com",
    "message": {
        "title": "Server Alert ๐Ÿšจ",
        "text": "Disk space is low on server",
        "priority": "high"
    },
    "schedule_expression": "0 9 * * *"
    }
    

๐Ÿ“„ GET /jobs

  • ๐Ÿ“„ Description: Retrieve all scheduled jobs.
  • ๐Ÿ“ฌ Response:
    [
    {
        "id": 1,
        "name": "Job Name",
        "notification_type": "email",
        "recipient": "example@example.com",
        "message": {
        "title": "Server Alert ๐Ÿšจ",
        "text": "Disk space is low on server",
        "priority": "high"
        },
        "schedule_expression": "0 9 * * *"
    }
    ]
    

๐Ÿ› ๏ธ Development

๐Ÿ”‘ Libraries Used

  • github.com/gorilla/mux: For API routing.
  • github.com/robfig/cron/v3: For job scheduling.
  • github.com/go-sql-driver/mysql: For MySQL database integration.

๐Ÿš€ Future Enhancements

  • Support for additional channels (e.g., WhatsApp, Telegram).
  • Role-based access control (RBAC) for APIs.
  • Enhanced logging and monitoring tools.

๐Ÿ“œ License

MIT License


๐Ÿ‘ฅ Contributors