https://github.com/manojkp08/segwise-webhook-service
A robust & scalable webhook processing system
https://github.com/manojkp08/segwise-webhook-service
celery fastapi google-cloud-platform postgresql python redis streamlit
Last synced: 8 days ago
JSON representation
A robust & scalable webhook processing system
- Host: GitHub
- URL: https://github.com/manojkp08/segwise-webhook-service
- Owner: manojkp08
- Created: 2025-05-03T10:58:19.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2026-06-02T03:13:58.000Z (22 days ago)
- Last Synced: 2026-06-02T05:09:05.038Z (22 days ago)
- Topics: celery, fastapi, google-cloud-platform, postgresql, python, redis, streamlit
- Language: Python
- Homepage: https://webhooktesting-segwiseassessmentmanoj.streamlit.app/
- Size: 134 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🌟 Webhook Delivery Service
> A robust & scalable webhook processing system



[](https://fastapi.tiangolo.com/)
[](https://www.python.org/)
[](https://redis.io/)
[](https://www.postgresql.org/)
[](https://www.docker.com/)
## 📌 Overview
Modern applications rely heavily on real-time event notifications. This project delivers a high-performance webhook service that:
- ⚡ Ingests webhooks with millisecond latency
- 🔄 Delivers payloads with exponential backoff retries (up to 5 attempts)
- 🔒 Verifies webhook signatures for security
- 📊 Provides complete visibility into delivery status
Built for e-commerce platforms, payment processors, and SaaS applications needing reliable webhook infrastructure.
## 🔥 Why Webhooks Matter
Webhooks power critical workflows:
- 💳 Payment gateways notifying about transactions
- 🔄 GitHub triggering CI/CD pipelines
- 👥 CRM systems syncing customer data
**Our solution solves:**
| Problem | Solution |
|---------|----------|
| 📮 Lost webhooks | Automatic retries with exponential backoff |
| 👁️ No delivery visibility | Full attempt history logging |
| 🔐 Security risks | Payload signature verification |
## 🏗️ Architecture
### Tech Stack
| Category | Technology | Purpose |
|----------|------------|---------|
| Backend | Python + FastAPI | Blazing fast API endpoints |
| Async | Celery + Redis | Background task processing |
| Database | PostgreSQL (GCP Cloud SQL) | Reliable data persistence |
| Caching | Redis Cloud | Queue management + subscription caching |
| Monitoring | Streamlit Dashboard | Real-time delivery analytics |
## 📸 Screenshots
Desktop interface with file browser
System configuration window
Application with terminal view
Terminal with command outputs
System settings dialog
Code or text editor interface
System information display
Terminal with system information
## 🔄 Workflows
### 1. Webhook Processing

### 2. Database Schema

### 3. Data Fetching Flow

### 4. Data Update Flow

### 5. Deployment Architecture

## 🏃 Local Setup (1 Minute)
```bash
# 1. Clone repo
git clone https://github.com/manojkp08/segwise-webhook-service.git
# 2. Go into the project file
cd segwise-webhook-service
# 3. Run services
docker-compose up --build # Starts API + Worker + Streamlit
```
### 🔧 Port Conflict Fixes (If Needed)
- If ports are already allocated (Error: "port is already allocated"):
**Option 1: Quick Port Change**
Edit `docker-compose.yml` and change these lines:
```yaml
services:
redis:
ports:
- "6381:6379" # Change 6381 to any free port (e.g., 6382)
streamlit:
ports:
- "8502:8501" # Change 8502 to any free port (e.g., 8503)
web:
ports:
- "8001:8000" # Change 8001 to any free port (e.g., 8002)
```
**Option 2: Kill Occupied Ports (Linux/Mac)**
```bash
sudo lsof -i :8501 # Check which process uses port 8501
kill -9 # Replace with the process ID from above
```
## 📡 API Documentation
(Full API documentation can be found at https://docs.google.com/document/d/1mwhyYywsMIbqxx-ZCbivbzKzG3M394B47ILTwtQzyrY/edit?usp=sharing)
1. Create Subscription
POST - https://segwise-webhook-service.onrender.com/api/v1/subscriptions/
Example:
Input:
```
{
"target_url": "https://hook.eu2.make.com/oa7dkj27u6dsx5lcnj7siwcldjg4uj1v",
"secret": "2c6d8d1d-01d5-4898-8188-f3cadfd44163",
"event_types": ["payment.processed"]
}
```
Output:
```
{
"target_url": "https://hook.eu2.make.com/oa7dkj27u6dsx5lcnj7siwcldjg4uj1v",
"event_types": [
"payment.processed"
],
"id": "e5b40e29-5f9d-4c83-8562-6bd0cd3a4e74",
"is_active": true,
"created_at": "2025-05-04T06:04:41.250794Z",
"updated_at": null
}
```
2. Injest Webhook
POST - https://segwise-webhook-service.onrender.com/api/v1/ingest/{subscription_id}
Example:
Input:
```
{
"event": "payment.processed",
"amount": 34567
}
```
Output:
```
{
"status": "accepted",
"delivery_id": "b3827820-5992-46c1-9866-16940b53093f",
"subscription_id": "e5b40e29-5f9d-4c83-8562-6bd0cd3a4e74"
}
```
3. Delivery Logs
GET - https://segwise-webhook-service.onrender.com/api/v1/status/delivery/{delivery_id}
Example
Output:
```
{
"delivery_id": "b3827820-5992-46c1-9866-16940b53093f",
"attempts": [
{
"attempt_number": 0,
"status": "queued",
"status_code": null,
"timestamp": "2025-05-04T06:05:33.813352"
}
]
}
```
## 🧠 Redis Architecture
1. Queues:
celery: Stores pending delivery tasks
2. Caching:
subscription:{id}: Caches subscription details (TTL: 5m)
Key Commands:
```bash
redis-cli KEYS '*' # List all keys
redis-cli LLEN celery # Check queue length
redis-cli FLUSHDB # Clear all data (dev only)
```
## ☁️ Production Deployment
| Service | Provider | Details |
|---------|----------|---------|
| PostgreSQL | GCP Cloud SQL | Managed database service |
| Redis | Redis Cloud | Through Google Cloud Free tier |
| Streamlit UI | Streamlit Community Cloud | Analytics dashboard |
| Fast API | Render | Free tier |
Made with ❤️ by Manoj