A production-ready sample application demonstrating the Durabull workflow engine for Node.js/TypeScript. This app showcases durable, long-lived workflows that generate multiple hash digests (MD5, SHA1, SHA256, SHA512, BLAKE3) for uploaded images using parallel processing.
- π Durable Workflows: Long-lived, fault-tolerant workflow orchestration using Durabull
- β‘ Parallel Processing: Computes 5 different hash algorithms simultaneously
- π Modern Stack:
- Backend: Fastify API server with TypeScript
- Frontend: React with Vite
- Queue: Redis with BullMQ
- Workflow Engine: Durabull
- π³ Docker Ready: Complete Docker Compose setup for Redis
- π» Codespaces Ready: Full devcontainer configuration for GitHub Codespaces
- β¨ Production Best Practices:
- ESLint and Prettier for code quality
- Structured logging
- Error handling
- Clean architecture
- MD5
- SHA1
- SHA256
- SHA512
- BLAKE3 (via WebAssembly)
βββββββββββββββββββ
β React Frontend β
β (Vite + TS) β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ ββββββββββββββββ
β Fastify API βββββββΊβ Redis β
β Server β β (BullMQ) β
ββββββββββ¬βββββββββ ββββββββ²ββββββββ
β β
βΌ β
βββββββββββββββββββ β
β Durabull βββββββββββββββ
β Workflow/ β
β Activity β
β Workers β
βββββββββββββββββββ
- Workflow (
ImageHashWorkflow): Orchestrates the parallel hash computation - Activities (
ComputeHashActivity): Individual hash computation tasks - Workers: Process workflow and activity jobs from Redis queues
- API Server: Handles file uploads and provides workflow status
- Frontend: User interface for uploading images and viewing results
- Node.js 18+ and npm
- Docker and Docker Compose (for Redis)
- Git
- Clone the repository
git clone https://github.com/typescript-workflow/sample-app.git
cd sample-app- Install dependencies
npm install- Start everything (backend, worker, frontend)
Open one terminal and run:
npm run devThis will start the backend API server, the Durabull worker, and the Vite dev server for the frontend concurrently. The frontend is served at http://localhost:5173 by default.
- Open your browser
Navigate to http://localhost:5173 and upload an image!
This project is fully configured for GitHub Codespaces:
- Click the "Code" button on the repository
- Select "Codespaces" tab
- Click "Create codespace on main"
- Wait for the environment to build
- Run the commands above to start the services
The devcontainer will automatically:
- Install all dependencies
- Configure VS Code extensions
- Forward necessary ports
Create a .env file in the root directory:
# Redis Connection
REDIS_URL=redis://redis:6379
# API Server
PORT=3000
HOST=0.0.0.0
NODE_ENV=developmentThe Durabull engine is configured in backend/config/durabull.ts:
Durabull.configure({
redisUrl: process.env.REDIS_URL ?? 'redis://127.0.0.1:6379',
queues: {
workflow: 'durabull:workflow',
activity: 'durabull:activity',
},
serializer: 'json',
pruneAge: '30 days',
});User uploads an image through the React frontend. The file is sent to the Fastify API server.
The API server creates a new ImageHashWorkflow and starts it with the image buffer and list of hash algorithms.
const workflow = await WorkflowStub.make(ImageHashWorkflow);
await workflow.start({
imageBuffer: buffer,
algorithms: ['md5', 'sha1', 'sha256', 'sha512', 'blake3'],
}, fileName);The workflow dispatches 5 ComputeHashActivity tasks in parallel:
const hashStubs = input.algorithms.map((algorithm) =>
ActivityStub.make(ComputeHashActivity, input.imageBuffer, algorithm)
);
const hashes = yield ActivityStub.all(hashStubs);The Durabull workers pick up the workflow and activity jobs from Redis queues and execute them.
The frontend polls the API to check workflow status. Once complete, it displays all hash results.
- Drag & Drop: Easy file upload
- Image Preview: View uploaded image before processing
- Real-time Updates: Polls for workflow completion
- Copy to Clipboard: One-click hash copying
- Responsive Design: Works on mobile and desktop
- Beautiful UI: Modern gradient design with smooth animations
- File size limit: 10MB maximum
- File type validation: Only images allowed
- No persistent storage: Images are processed in memory
- Activity timeout: 30 seconds per hash computation
- Retry logic: 3 attempts per activity
- Fastify - Fast web framework
- React - UI library
- Vite - Build tool
- BullMQ - Queue system
- Redis - In-memory data store
Contributions are welcome! Please feel free to submit a Pull Request.
MIT
Built with β€οΈ as a demonstration of the Durabull workflow engine
Note: This is a sample application for demonstration purposes. For production use, consider adding:
- Authentication and authorization
- Persistent storage for images and results
- Rate limiting
- Monitoring and observability
- Horizontal scaling
- Database for workflow history