This is a task scheduler system designed for scheduling, executing, and monitoring tasks. It combines a FastAPI backend, Celery-based task queue, and a Streamlit dashboard for task monitoring, making it ideal for automated workflows and testing scheduled tasks such as email notifications.
- REST API for Task Management: Create, update, pause, resume, delete, and trigger tasks.
- Task Scheduling: Supports one-time, interval-based, and cron-like recurring tasks.
- Celery Workers: Asynchronous task execution with retries and status tracking.
- Task Monitoring Dashboard: Streamlit-based UI for viewing tasks and their runs.
- Authentication: JWT-based login and registration.
- Email Execution Example: Sends email notifications for scheduled tasks via SMTP (for testing purposes).
- Dockerized Setup: Easy deployment using Docker containers.
[Streamlit Dashboard] <--> [FastAPI API] <--> [PostgreSQL Database]
|
v
[Celery Beat] ---> [Celery Worker]
- FastAPI handles API requests and user authentication.
- Celery Beat polls the database and schedules tasks.
- Celery Worker executes tasks asynchronously.
- Streamlit dashboard communicates with the API to display task and run status.
- Docker & Docker Compose
- Python 3.10+
- PostgreSQL
- Clone the repository:
git clone https://github.com/barshakc/Task-Scheduler.git- Navigate to the project directory:
cd task-scheduler- Build and run containers using Docker Compose:
docker-compose up --build-
Access services:
- FastAPI API:
http://localhost:8000/docs - Streamlit Dashboard:
http://localhost:8501
- FastAPI API:
The project is fully dockerized with separate services for API, Celery workers, Celery Beat, and Streamlit dashboard.
-
Docker Compose orchestrates all services.
-
Dockerfiles for:
- FastAPI API
- Celery Worker
- Streamlit Dashboard
-
Environment Variables: Configure PostgreSQL database URL, email credentials, and other settings in
.envfile.
- Build containers:
docker-compose build- Start all services:
docker-compose up- Stop all services:
docker-compose down- Run a one-off command inside the API container:
docker-compose run api python manage.py migrateFor production deployment with PostgreSQL, follow these steps:
-
Prepare Environment Variables
-
Create a
.env.prodfile with production configurations, including:POSTGRES_USER,POSTGRES_PASSWORD,POSTGRES_DBDATABASE_URL(e.g.,postgresql://user:password@db:5432/dbname)EMAIL_HOST,EMAIL_PORT,EMAIL_USER,EMAIL_PASSWORD,EMAIL_FROMJWT_SECRET_KEY
-
-
Persistent Storage
- Map a Docker volume for PostgreSQL to persist task and user data.
- Example in
docker-compose.prod.yml:
volumes:
postgres_data:
driver: local- Start Services in Detached Mode
docker-compose -f docker-compose.prod.yml up -d --build-
Optional Reverse Proxy and SSL
- Use NGINX or Traefik to expose FastAPI and Streamlit over HTTPS.
- Configure firewall rules to allow traffic on required ports.
-
Monitoring & Logs
- Check logs for API and Celery services:
docker-compose logs -f apidocker-compose logs -f worker- Ensure Celery Beat is scheduling tasks correctly and workers are processing them.
- Register a user via
/registerendpoint. - Login to obtain JWT token.
- Create tasks with
schedule_type(once, interval, cron) and optional payload (e.g., email details). - Trigger tasks manually via API or let Celery Beat schedule them automatically.
- Monitor tasks and runs in the Streamlit dashboard.
- Task management: pause, resume, update, or delete tasks using API endpoints.
{
"recipient": "user@example.com",
"subject": "Test Task",
"message": "This is a test scheduled email."
}- Basic health checks for API endpoints, Celery workers, and task execution.
- Sample tasks can be scheduled and monitored through the dashboard.
Contributions are welcome! Steps:
- Fork the repository.
- Create a feature branch.
- Make changes and commit.
- Push the branch and open a pull request.
MIT License. See LICENSE file for details.
Efficiently schedule, monitor, and execute tasks with a full-stack Python scheduler using PostgreSQL.