A production-grade async backend system using FastAPI + Redis + RQ + WebSockets with a professional React dashboard.
User (Browser)
│
├── POST /api/tasks → FastAPI (submits job to Redis Queue)
├── GET /api/tasks/{id} → FastAPI (polls task status)
└── WS /ws/{client_id} → WebSocket (real-time push notifications)
↑
RQ Worker (processes jobs, notifies via Redis PubSub)
↑
Redis (message broker + job store)
- Distributed Task Queue via RQ (Redis Queue)
- Real-Time WebSocket Notifications — browser gets notified the instant a job finishes
- Multiple Task Types: Email Campaigns, Image Processing, Data Reports, File Exports
- Job Progress Tracking with percentage updates
- Retry & Failure Handling with exponential backoff
- Professional React Dashboard with live updates, job history, analytics
- Redis Pub/Sub bridge between worker and WebSocket server
| Layer | Technology |
|---|---|
| API Server | FastAPI (Python) |
| Task Queue | RQ (Redis Queue) |
| Message Broker | Redis 7 |
| Real-Time | WebSockets (FastAPI) |
| Frontend | React 18 + Vite |
| Styling | Tailwind CSS |
| Dev Tools | Docker Compose (optional) |
- Python 3.11+
- Node.js 18+
- Redis (Windows: use Memurai or WSL2)
git clone https://github.com/YOUR_USERNAME/taskflow.git
cd taskflow# Create virtual environment
python -m venv venv
venv\Scripts\activate # Windows
# source venv/bin/activate # Mac/Linux
# Install dependencies
pip install -r requirements.txtOption A — Memurai (recommended for Windows): Download from https://www.memurai.com/ and install. It runs as a Windows service automatically.
Option B — WSL2:
wsl sudo service redis-server startOption C — Docker:
docker run -d -p 6379:6379 redis:7-alpineTerminal 1 — API Server:
venv\Scripts\activate
uvicorn backend.api.main:app --reload --port 8000Terminal 2 — RQ Worker:
venv\Scripts\activate
python -m backend.worker.run_workerTerminal 3 — Frontend:
cd frontend
npm install
npm run devVisit http://localhost:5173
taskflow/
├── backend/
│ ├── api/
│ │ ├── main.py # FastAPI app + WebSocket server
│ │ ├── routes.py # REST API endpoints
│ │ └── schemas.py # Pydantic models
│ ├── worker/
│ │ ├── run_worker.py # RQ worker entrypoint
│ │ └── tasks.py # Task definitions (email, image, etc.)
│ └── core/
│ ├── config.py # Settings & environment
│ ├── redis_client.py # Redis connection
│ └── ws_manager.py # WebSocket connection manager
├── frontend/
│ ├── src/
│ │ ├── components/ # React UI components
│ │ ├── hooks/ # Custom hooks (useWebSocket, useTasks)
│ │ └── pages/ # Dashboard, History pages
│ └── package.json
├── requirements.txt
├── .env.example
└── README.md
POST /api/tasks
Content-Type: application/json
{
"task_type": "email_campaign",
"payload": {
"recipients": 5000,
"template": "newsletter_v2"
},
"priority": "high"
}GET /api/tasks/{task_id}GET /api/tasks?status=pending&limit=20const ws = new WebSocket(`ws://localhost:8000/ws/${clientId}`);
ws.onmessage = (event) => {
const { task_id, status, progress, result } = JSON.parse(event.data);
};| Type | Description | Simulated Duration |
|---|---|---|
email_campaign |
Bulk email sending simulation | 10–30s |
image_processing |
Resize/compress image batch | 5–15s |
data_report |
Generate analytics report | 8–20s |
file_export |
Export large dataset to CSV | 6–18s |
notification_blast |
Send push notifications | 4–12s |
# Submit a test task via curl
curl -X POST http://localhost:8000/api/tasks \
-H "Content-Type: application/json" \
-d '{"task_type": "email_campaign", "payload": {"recipients": 1000}}'
# Watch the terminal — worker picks it up, updates Redis, WebSocket pushes to browserdocker-compose up --buildAll services start automatically (Redis, API, Worker, Frontend).
- Message Broker Pattern — Redis decouples API from Worker
- Pub/Sub Bridge — Worker publishes events; WebSocket server subscribes and pushes to clients
- Horizontal Scalability — Multiple workers can consume from the same queue
- Graceful Error Handling — Failed jobs are retried with backoff, then moved to failed queue
- Real-Time UX — No polling; WebSocket delivers instant updates
MIT