Skip to main content

Real-time database change monitoring with rule engine and multi-channel notifications (Slack, Email, Webhook, REST API, Teams)

Project description

๐Ÿ”„ CDC Stream

Real-time database change notifications - No Docker, No Kafka, Just Python!

CDC Stream captures database changes (INSERT, UPDATE, DELETE) and sends notifications to Slack, Email, Webhooks, or REST APIs.

โœจ Features

  • ๐Ÿš€ Simple Setup: Just pip install and start
  • ๐Ÿ˜ PostgreSQL Support: Native trigger-based CDC
  • ๐Ÿ“ก Multiple Notification Channels: Slack, Email, Webhook, REST API
  • ๐ŸŽฏ Flexible Rules: Filter and route events based on conditions
  • ๐ŸŒ Web UI: Beautiful dashboard for configuration
  • ๐Ÿ Pure Python: No Docker, Kafka, or external dependencies required

๐Ÿš€ Quick Start

# Install
pip install cdc-stream

# Start (that's it!)
python -m cdc_stream start

# Open http://localhost:5858 in your browser

๐Ÿ“ฆ Installation

From PyPI (Recommended)

pip install cdc-stream

From Source

git clone https://github.com/yourusername/cdc-stream.git
cd cdc-stream
pip install -e .

๐ŸŽฏ How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Your Database                          โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  INSERT/UPDATE/DELETE on your tables                โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚                         โ”‚ TRIGGER (auto-installed)         โ”‚
โ”‚                         โ–ผ                                   โ”‚
โ”‚              pg_notify('cdc_stream_events')                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                          โ”‚
                          โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    CDC Stream Worker                        โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”‚
โ”‚  โ”‚  LISTEN โ†’ Filter โ†’ Rule Check โ†’ Send Notification   โ”‚   โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚
โ”‚         โ”‚              โ”‚              โ”‚              โ”‚      โ”‚
โ”‚         โ–ผ              โ–ผ              โ–ผ              โ–ผ      โ”‚
โ”‚     ๐Ÿ“ง Email      ๐Ÿ’ฌ Slack      ๐Ÿ”— Webhook     ๐ŸŒ REST     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ–ฅ๏ธ Web UI

Open http://localhost:5858 after starting CDC Stream:

  1. Add Connection: Configure your PostgreSQL database
  2. Create Alert: Select table, define filters, choose notification channel
  3. Watch Live: Real-time event stream visualization

๐Ÿ“‹ CLI Commands

# Start everything (web UI + worker)
python -m cdc_stream start

# Start with custom port
python -m cdc_stream start --port 8080

# Start only web server
python -m cdc_stream webserver

# Start only worker
python -m cdc_stream worker

# Check status
python -m cdc_stream status

# Show version
python -m cdc_stream version

# Manage triggers
python -m cdc_stream triggers <datasource_id> list
python -m cdc_stream triggers <datasource_id> sync
python -m cdc_stream triggers <datasource_id> remove

# Test listener
python -m cdc_stream test-listener <datasource_id>

๐Ÿ”” Notification Channels

Slack

{
  "webhook_url": "https://hooks.slack.com/services/..."
}

Email (SMTP)

{
  "smtp_host": "smtp.gmail.com",
  "smtp_port": 587,
  "smtp_user": "your@email.com",
  "smtp_password": "app-password",
  "from_email": "alerts@yourcompany.com",
  "to_emails": ["team@yourcompany.com"]
}

Webhook

{
  "url": "https://your-api.com/webhook",
  "method": "POST",
  "headers": {"Authorization": "Bearer token"}
}

REST API

{
  "method": "POST",
  "url": "https://api.example.com/events",
  "auth_type": "bearer",
  "auth_token": "your-token",
  "headers": {},
  "body": "{\"event\": \"{{data}}\"}"
}

๐ŸŽฏ Filter & Rule Examples

Filters (Pre-condition)

Only process events matching these conditions:

[
  {"field": "status", "operator": "==", "value": "active"},
  {"field": "amount", "operator": ">", "value": 1000}
]

Rules (Alert condition)

Send notification when these conditions are met:

[
  {"field": "priority", "operator": "==", "value": "critical"}
]

๐Ÿ”ง Configuration

Environment Variables

# Optional: Change default ports
CDC_STREAM_PORT=5858
CDC_STREAM_DB_PATH=./cdc_stream.db

Database Requirements

CDC Stream requires PostgreSQL 10+ with these settings (usually default):

-- Check your settings
SHOW wal_level;  -- Should work with any value

Note: Unlike traditional CDC tools, CDC Stream uses trigger-based capture which works without changing wal_level.

๐Ÿ“Š System Requirements

  • Python: 3.9+
  • Database: PostgreSQL 10+
  • RAM: ~50MB
  • Disk: ~10MB

๐Ÿ”’ Security

  • Credentials stored locally in SQLite
  • No external services required
  • All communication stays within your infrastructure

๐Ÿ› Troubleshooting

Worker not receiving events

  1. Check if triggers are installed:
python -m cdc_stream triggers <datasource_id> list
  1. Sync triggers with alerts:
python -m cdc_stream triggers <datasource_id> sync

Connection issues

  1. Verify database is accessible
  2. Check firewall settings
  3. Ensure user has CREATE TRIGGER permission

๐Ÿ“ License

MIT License - see LICENSE file for details.

๐Ÿค Contributing

Contributions are welcome! Please read our contributing guidelines first.


Made with โค๏ธ for the developer community

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_cdcstream-1.0.19.tar.gz (87.9 kB view details)

Uploaded Source

File details

Details for the file py_cdcstream-1.0.19.tar.gz.

File metadata

  • Download URL: py_cdcstream-1.0.19.tar.gz
  • Upload date:
  • Size: 87.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for py_cdcstream-1.0.19.tar.gz
Algorithm Hash digest
SHA256 d13d474e42b6ccdaf74c57f4ccc04e3fc981790fc4fc1e20f8628c473934f8ec
MD5 974970d878e8a51485f6c5fe7fcc6208
BLAKE2b-256 90a1815d264a27b8313de89bd784700bce97ff57e2d1a824540e2aea0dca3a4b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page