Skip to content

silverstar33/smart-queue-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🧠 Smart Queue System

A task queue system built with FastAPI, Redis, and a simple HTML dashboard to monitor live tasks, handle failures, view logs, and test real-world DevOps architecture.


πŸ”§ Features

  • βœ… Submit tasks via FastAPI
  • πŸ‘· Process background tasks with retry logic
  • ❌ Auto-handles task failures and retries
  • πŸ“Š Admin dashboard displays:
    • Live and completed tasks
    • Failed tasks with error info
    • πŸ” Task logs viewable directly from the UI
  • πŸ“ All logs are saved to logs/task_queue.log

πŸ—‚οΈ Project Structure

.
β”œβ”€β”€ main.py               # FastAPI server with API routes
β”œβ”€β”€ redis_queue.py        # Task enqueue logic
β”œβ”€β”€ worker.py             # Background task processor
β”œβ”€β”€ logger.py             # Centralized logger setup
β”œβ”€β”€ templates/
    └── dashboard.html    # HTML dashboard (Admin UI)
β”œβ”€β”€ logs/
β”‚   └── task_queue.log    # Log file (auto-created)
β”œβ”€β”€ requirements.txt      # Python dependencies
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml    # Multi-container Docker setup


πŸš€ Run Locally

Make sure Redis is running on localhost:6379.

πŸ”¨ Build & Run Manually

# Step 1: Build Docker image
docker build -t smart-queue .

# Step 2: Run the container
docker run -p 8000:8000 smart-queue

Visit the app at: http://localhost:8000

πŸ“₯ Submit Task Example (API)

curl -X POST http://localhost:8000/submit \
  -H "Content-Type: application/json" \
  -d '{"task_name": "test_api", "data": {"key": "value"}}'

πŸ’» Admin Dashboard
Accessible at: http://localhost:8000/admin

Includes:

πŸ“‹ Live task list with real-time status

- Uses WebSocket (`/ws/tasks`) to show live task status updates instantly
- Built with FastAPI + Uvicorn + Vanilla JS

βœ… Completed task results

❌ Failed task error messages

πŸ“ Log viewer (reads last 50 lines from task_queue.log)

πŸ§ͺ API Endpoints
Method	Endpoint	Description
POST	/submit	Submit a new task
GET	/admin	View the admin dashboard (UI)
GET	/tasks	Get all pending/processing tasks
GET	/tasks/completed	Get completed tasks
GET	/logs	View last 50 lines from log

πŸ” Retry Logic
Max retries per task: 2

Failed tasks are automatically retried

Redis tracks status:

queued

processing

completed

failed

🐳 Coming Soon
βœ… Dockerized backend (multi-service with Redis)

πŸ”„ GitHub Actions CI/CD

βš›οΈ React frontend for the dashboard

✍️ Author
~ Ashwin Bagul

Built with ❀️ as a real-world DevOps & distributed task system showcase.

---

About

πŸš€ A real-world DevOps Queue System built with FastAPI + Redis + Dashboard

Resources

Stars

Watchers

Forks

Packages

No packages published