Event-Driven Inventory API
Django inventory service backed by a Celery task pipeline. Domain events trigger async workers through Redis, keeping side effects isolated and the request path fast.
Visit github.com/Lanrey/event-driven-inventory-api →Situation
Inventory operations frequently trigger side effects like notifications, downstream syncs, analytics events, and external webhooks. When these run synchronously in the request path, a slow external call or a failing integration degrades response times for the main operation. The request and its side effects become implicitly coupled in ways that are hard to test and harder to change.
Task
Build an inventory API where domain events drive all side effects asynchronously through a task pipeline, keeping the request path thin and the side effects independently testable and deployable.
Action
- Domain events (stock updated, item created, threshold breached) are published to Redis after each write operation.
- Celery workers consume those events and execute side effects like notifications, downstream syncs, and analytics without touching the request path.
- Each worker type handles a single concern. Notification workers do not know about sync workers, and sync workers do not know about analytics workers.
- Django REST framework handles the API layer. PostgreSQL backs the inventory state. Redis serves as both the message broker and cache layer.
Result
- The request path stays fast regardless of downstream system health. A slow webhook consumer does not affect inventory write latency.
- Side effects are independently retryable via Celery's built-in retry mechanism with backoff.
- Each worker is independently testable with no dependency on the others.
- The event-driven model makes it straightforward to add new side effects without modifying existing code.