Enterprise-grade demonstration of Shopify webhook automation showcasing professional software architecture, design patterns, and scalable order fulfillment processing.
Key Features:
- β Event-driven webhook architecture with unified endpoint
- β Multiple design patterns (Factory, Strategy, Observer, Chain of Responsibility)
- β Idempotent processing with deduplication
- β Async-ready architecture (Celery structure)
- β SOLID principles and clean code
- β Comprehensive testing and documentation
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β Shopify βββββΆβ Webhook βββββΆβ Handler β
β Webhook β β Validator β β Factory β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ βββββββββββββββββββ
β Deduplication β β Strategy β
β Service β β Selector β
ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ βββββββββββββββββββ
β Database β β Fulfillment β
β Storage β β Execution β
ββββββββββββββββββββ βββββββββββββββββββ
β β
βΌ βΌ
ββββββββββββββββββββ βββββββββββββββββββ
β Observer β β Result β
β Notifications β β Response β
ββββββββββββββββββββ βββββββββββββββββββ
Creates appropriate webhook handlers based on event type:
handler = WebhookHandlerFactory.create_handler('orders/create')Selects fulfillment strategy based on order characteristics:
- AutoFulfillmentStrategy: All items in stock
- PartialFulfillmentStrategy: Some items available
- ManualReviewStrategy: High-value orders (>$1000)
- ExpressFulfillmentStrategy: VIP customers
Notifies multiple observers of webhook events:
- LoggingObserver: Detailed event logging
- MetricsObserver: Processing statistics
- NotificationObserver: Alert system
Validation pipeline:
HMAC Validation β Schema Validation β Deduplication β Business Rules
- Clone and Setup
git clone <repository-url>
cd shopify_automation_demo
uv sync- Environment Configuration
cp .env.example .env
# Edit .env with your configuration- Database Setup
uv run python manage.py migrate
uv run python manage.py createsuperuser- Run Development Server
uv run python manage.py runserver# Build and start all services
docker-compose up --build
# Run migrations
docker-compose exec web python manage.py migrate
# Create superuser
docker-compose exec web python manage.py createsuperusercurl -X POST http://localhost:8000/webhooks/shopify/ \
-H "Content-Type: application/json" \
-H "X-Shopify-Topic: orders/create" \
-H "X-Shopify-Webhook-Id: unique-id-123" \
-H "X-Shopify-Shop-Domain: test-shop.myshopify.com" \
-d @webhooks/tests/fixtures/orders_create.json# Simulate different webhook events
uv run python manage.py simulate_webhook orders/create
uv run python manage.py simulate_webhook orders/updated
uv run python manage.py simulate_webhook orders/cancelledorders/create- New order processingorders/updated- Order modificationsorders/cancelled- Order cancellationsorders/fulfilled- Fulfillment updatesproducts/create- New product notificationscustomers/create- Customer registration
- Webhook Events:
/admin/webhooks/webhookevent/ - Orders:
/admin/webhooks/shopifyorder/ - Fulfillment Tasks:
/admin/webhooks/fulfillmenttask/
# View webhook processing logs
tail -f logs/webhooks.log
# Docker logs
docker-compose logs -f webProcessing statistics are automatically tracked:
- Total webhooks processed
- Success/failure rates
- Processing times
- Event type distribution
- HMAC Signature Validation: Verifies webhook authenticity
- Idempotent Processing: Prevents duplicate processing
- Request Size Limits: Protects against large payloads
- SQL Injection Prevention: Django ORM protection
- Environment-based Configuration: No hardcoded secrets
- Database Indexing: Optimized queries on webhook_id, order_id
- Redis Caching: Fast deduplication checks
- Async Processing Ready: Celery integration structure
- Connection Pooling: PostgreSQL optimization
- Batch Processing: Scalable for high-volume scenarios
# Run all tests
uv run python manage.py test
# Run with coverage
uv run pytest --cov=webhooks --cov-report=html
# Run specific test modules
uv run python manage.py test webhooks.tests.test_handlersPOST /webhooks/shopify/
Headers:
X-Shopify-Topic: Event type (required)X-Shopify-Webhook-Id: Unique webhook ID (required)X-Shopify-Shop-Domain: Shop domain (required)X-Shopify-Hmac-SHA256: HMAC signature (required in production)
Response:
{
"status": "success",
"webhook_id": "unique-id-123",
"event_topic": "orders/create",
"result": {
"fulfillment_method": "automatic",
"status": "fulfilled",
"tracking_numbers": ["1Z999AA1234567890"]
}
}β
Enterprise Architecture Patterns
β
Production-Ready Code Quality
β
Comprehensive Error Handling
β
Scalable Design (1000+ webhooks/hour)
β
Docker Containerization
β
Professional Documentation
β
SOLID Principles Applied
β
Test-Driven Development
- Backend: Django 5.0, Django REST Framework
- Database: PostgreSQL (production), SQLite (development)
- Cache: Redis
- Task Queue: Celery (structure ready)
- Containerization: Docker, Docker Compose
- Testing: pytest, factory-boy
- Code Quality: black, flake8, mypy
MIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run the test suite
- Submit a pull request
For questions about this portfolio project or potential collaboration opportunities, please reach out through:
- Portfolio: [Your Portfolio URL]
- LinkedIn: [Your LinkedIn Profile]
- Email: [Your Professional Email]
This project demonstrates enterprise-level set up for high-value e-commerce automation projects.