A distributed task execution platform that allows users to submit background jobs, process them asynchronously using a worker system, and track their status in real time.
The system is designed to handle tasks such as sending emails or messages without blocking the main application flow.
- Asynchronous job processing using queues
- Retry mechanism for failed jobs
- Job status tracking (PENDING, PROCESSING, COMPLETED, FAILED, RETRYING)
- Secure authentication using JWT
- Scalable worker-based architecture
| Technology | Purpose |
|---|---|
| Node.js | Runtime |
| TypeScript | Language |
| Express.js | HTTP Server |
| PostgreSQL | Database |
| Prisma ORM | Database ORM |
| Redis | Queue Store |
| BullMQ | Job Queue |
| Resend API | Email Service |
| Docker | Containerization |
User → API → Queue (Redis + BullMQ) → Worker → Database → Response
PENDING → PROCESSING → COMPLETED PENDING → PROCESSING → FAILED PENDING → PROCESSING → RETRYING → PROCESSING
src/ controller/ # Request handlers services/ # Business logic routes/ # API route definitions middleware/ # Auth & validation worker/ # Job processors queue/ # BullMQ queue setup database/ # Prisma client types/ # TypeScript types
git clone https://github.com/Sahil162005/distributed-task-scheduler.git
cd distributed-task-schedulernpm installCreate a .env file in the root directory:
DATABASE_URL=postgresql://username:password@localhost:5432/user-auth
SECRET_KEY=your_secret_key
RESEND_API_KEY=your_resend_api_key
TELEGRAM_BOT_TOKEN=your_telegram_bot_token
REDIS_URL=redis://localhost:6379
PORT=5007docker run -d -p 6379:6379 --name redis redisnpx prisma migrate dev
npx prisma generatenpm run dev| Method | Endpoint | Description |
|---|---|---|
| POST | /api/auth/signup | Register a new user |
| POST | /api/auth/login | Login and get JWT token |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/jobs | Submit a new job (auth required) |
| GET | /api/jobs/:id | Get job status (auth required) |
| Method | Endpoint | Description |
|---|---|---|
| GET | /health | Health check |
{
"job_type": "SEND_EMAIL",
"payload": {
"to": "example@gmail.com",
"subject": "Test Email",
"body": "Hello from the scheduler"
}
}Use Postman or any API client:
- Register a user via
POST /api/auth/signup - Login and copy the JWT token
- Submit a job via
POST /api/jobswith Bearer token - Poll job status via
GET /api/jobs/:id
- Implemented worker-based job execution
- Integrated external email service
- Designed job lifecycle and retry mechanism
- Developed and tested APIs
- Handled authentication and validation
- WebSocket integration for real-time updates
- Dashboard for monitoring jobs
- Multiple worker scaling
- Job prioritization and rate limiting
This project is for academic and educational use.