A Distributed Job Processing & Workflow Orchestration Platform
Submit a job. Don't block the request. Get results when they're ready.
Anvil is a horizontally scalable, distributed job processing and orchestration platform built for high-throughput, fault-tolerant asynchronous work. Designed to offload heavy computations from client-facing applications, Anvil ensures jobs are executed reliably, retried intelligently, and monitored comprehensively.
Whether it's report generation, AI content creation, bulk email campaigns, or CSV imports, Anvil acts as the resilient backbone that handles the complexity of distributed execution, state management, and real-time client updates.
- Asynchronous Processing: Submit jobs via a REST API and receive a tracking ID immediately.
- Priority Queues: Redis-backed queues supporting HIGH, MEDIUM, and LOW priority execution.
- Real-Time Updates: WebSocket (STOMP/SockJS) integration pushes live progress and status changes directly to the client.
- Robust Error Handling: Configurable automatic retries with exponential backoff and a robust Dead Letter Queue (DLQ) for permanent failures.
- Comprehensive Admin Console: Dashboard for real-time statistics, worker node management, and DLQ inspection.
- Role-Based Access Control: Secure JWT authentication separating User workspaces from Admin tooling.
Anvil is built to demonstrate production-ready engineering patterns to solve distributed system challenges:
- Transactional Outbox Pattern: Ensures dual-write consistency. Database writes and queue enqueues occur atomicallyβpreventing ghost jobs or data loss if a process crashes mid-transaction.
- Resilience & Chaos Tested: Proven against rigorous chaos tests (20 kill/restart cycles). Orphan jobs are successfully reclaimed without data loss.
- Observability-First Design: Implements structured JSON logging with correlation IDs for request tracing, combined with Prometheus metrics for throughput, latency, and worker health monitoring.
- State Machine Job Lifecycle: Strict state transitions (
CREATEDβQUEUEDβRUNNINGβCOMPLETED/FAILED) guarantee deterministic job handling. - Clean Architecture: Strict separation of concerns (Controllers, Services, Repositories). Handlers strictly implement a
JobHandlerinterface, ensuring adding new job types never touches core orchestration logic.
| Category | Technologies |
|---|---|
| Backend Core | Java 21, Spring Boot 3.5, Spring Security, Maven |
| Data Layer | PostgreSQL 16, Flyway (Migrations) |
| Caching & Queues | Redis 7 |
| Real-time Comms | Spring WebSocket (STOMP + SockJS) |
| Frontend | React 19, TypeScript, Vite, Tailwind CSS |
| Observability | Micrometer, Prometheus, Logstash Encoder |
| Testing | JUnit 5, Mockito, Testcontainers, Vitest, React Testing Library |
| Infrastructure | Docker, Docker Compose |
The system splits cleanly into a write path (submit β queue β execute β persist) and a read path (dashboard queries + live push), avoiding read-write contention.
βββββββββββββββββββββββββ
β Client App β
ββββββββββββ¬βββββββββββββ
β POST /api/v1/jobs
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β Spring Boot REST API β
ββββββββββββ¬βββββββββββββββββββββββββββββββββ
β BEGIN TX: INSERT job + INSERT outbox row
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β PostgreSQL 16 β
ββββββββββββ¬βββββββββββββββββββββββββββββββββ
β OutboxRelay β ZADD
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β Redis 7 β Priority Queue β
ββββββββββββ¬βββββββββββββββββββββββββββββββββ
β poll() β claim
βΌ
βββββββββββββββββββββββββββββββββββββββββββββ
β Worker Pool β
β claim β JobHandler.execute() β ack/nack β
βββββ¬ββββββββββββββββββββ¬ββββββββββββββββββββ
β persist result β push WS progress
βΌ βΌ
ββββββββββββββ βββββββββββββββββββββ
β PostgreSQL β β WebSocket Service β
ββββββββββββββ βββββββββββ¬ββββββββββ
β
βββββββββββ΄ββββββββββ
β React Dashboard β
βββββββββββββββββββββ
CREATED ββ(enqueue)βββΆ QUEUED ββ(claim)βββΆ RUNNING ββ(success)βββΆ COMPLETED
β² β
β ββββββ(failure)ββββΆ FAILED ββ(retries left)βββΆ RETRYING
β β
βββββββββ(backoff expires)βββββββββββββββββ
β
(no retries left)
βΌ
FAILED_PERMANENTLY (DLQ)
Anvil isn't just built to run; it's built to fail safely and recover gracefully.
- Crash Recovery: Outbox durability ensures jobs survive DB/Queue dual-write failures.
- Orphan Job Reclamation: Visibility timeouts and worker heartbeats allow the system to detect crashed workers and automatically re-queue stalled jobs.
- Load Testing Results: Sustains 3857 jobs/min API submission throughput with p95=17ms and p99=34ms latency.
- Health Probes: Kubernetes-ready
/actuator/health/livenessandreadinessendpoints.
- Java 21+ & Maven 3.9+
- Node.js 18+
- Docker & Docker Compose
Spin up the entire stackβPostgreSQL, Redis, API, and Frontendβwith one command:
docker compose up -d- Frontend Dashboard:
http://localhost - Backend API:
http://localhost:8080/api/v1 - Swagger Docs:
http://localhost:8080/swagger-ui/index.html - Prometheus Metrics:
http://localhost:8080/actuator/prometheus
- Start Infrastructure (DB & Cache):
docker compose up -d postgres redis
- Start Backend API:
cd backend ./mvnw spring-boot:run - Start Frontend Dashboard:
cd frontend npm install && npm run dev
Anvil employs a rigorous testing strategy ensuring extreme reliability.
- Backend (180+ Tests, 0 Failures):
- Unit Tests: Core domain logic, state transitions, retry backoff algorithms.
- Integration Tests: Driven by Testcontainers (spinning up real Postgres and Redis nodes), verifying queue operations, worker orchestration, outbox relays, and WebSocket security. No database mocking.
- Contract Tests: Comprehensive endpoint validation.
- Frontend (31+ Tests, 0 Failures):
- Uses Vitest and React Testing Library to cover UI components, form validation, and admin route guards.
Run tests locally:
# Backend
cd backend && mvn test
# Frontend
cd frontend && npm testβββ backend/ # Java 21, Spring Boot, REST API, WebSocket
β βββ src/main/java/.../
β β βββ api/ # REST Controllers, DTOs
β β βββ job/ # Job Domain, State Machine, Handlers (CSV, Email, AI, etc.)
β β βββ queue/ # Redis Queue implementations, Transactional Outbox Relay
β β βββ worker/ # Worker Orchestration, Watchdogs
β β βββ notification/ # WebSocket STOMP messaging
β βββ src/test/ # 180+ Integration & Unit Tests (Testcontainers)
β
βββ frontend/ # React 19, Vite, Tailwind SPA
β βββ src/
β β βββ components/ # Reusable UI elements
β β βββ pages/ # Admin Console, User Workspace, Job Detail
β β βββ hooks/ # Custom hooks (e.g., useWebSocket)
β β βββ api/ # API Client with interceptors
β
βββ scripts/ # Load & Chaos testing PowerShell scripts
βββ docs/ # Product specs and technical architecture
βββ docker-compose.yml # Infrastructure orchestration
Distributed under the MIT License. See LICENSE for more information.
Built with β€οΈ focusing on clean architecture and robust distributed systems design.