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 installandstart - ๐ 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:
- Add Connection: Configure your PostgreSQL database
- Create Alert: Select table, define filters, choose notification channel
- 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
- Check if triggers are installed:
python -m cdc_stream triggers <datasource_id> list
- Sync triggers with alerts:
python -m cdc_stream triggers <datasource_id> sync
Connection issues
- Verify database is accessible
- Check firewall settings
- 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_cdcstream-1.0.6-py3-none-any.whl.
File metadata
- Download URL: py_cdcstream-1.0.6-py3-none-any.whl
- Upload date:
- Size: 6.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
47c52cbc93a78f59f14b0fe25f61c9bf540ef747b15c9ebec5e83ff54048e57c
|
|
| MD5 |
57dfdcb47ad2752d82e43bdd1de83404
|
|
| BLAKE2b-256 |
c8cf16af6ce1036d2dac169ffffb5f5b3c9782c949099fc91cf1d61a639d2d47
|