Skip to content

shubhrad1/TaskZap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TaskZap

TaskZap is a simple job scheduling API built with FastAPI. It allows users to create and manage scheduled jobs that make HTTP requests based on cron expressions.

Features

  • Create scheduled jobs with custom URLs, HTTP methods, and cron schedules
  • Configurable retry counts for failed requests
  • Health check endpoint
  • PostgreSQL database for persistence
  • Docker Compose setup for easy deployment

Project Structure

TaskZap/
├── docker-compose.yaml    # Docker Compose configuration for PostgreSQL and Redis
├── api-service/
│   ├── requirements.txt   # Python dependencies
│   └── app/
│       ├── main.py        # FastAPI application and endpoints
│       ├── models.py      # SQLAlchemy models
│       ├── schemas.py     # Pydantic schemas
│       └── database.py    # Database configuration
└── README.md              # This file

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd TaskZap
  2. Create a .env file in the api-service directory with the following variables:

    DATABASE_URL=postgresql://user:password@localhost:5432/dbname
    POSTGRES_USER=user
    POSTGRES_PASSWORD=password
    POSTGRES_DB=dbname
    
  3. Install dependencies:

    cd api-service
    pip install -r requirements.txt

Usage

Running Locally

  1. Start the database:

    docker-compose up postgres
  2. Run the API:

    cd api-service
    uvicorn app.main:app --reload

The API will be available at http://localhost:8000.

Using Docker Compose

  1. Update the .env file with your database credentials.

  2. Run the entire stack:

    docker-compose up

API Endpoints

Health Check

  • GET /health
    • Returns: {"status": "ok"}

Create Job

  • POST /jobs
    • Body:
      {
          "url": "https://example.com/webhook",
          "method": "POST",
          "cron": "0 * * * *",
          "retry_count": 3
      }
    • Returns: Created job object

Job Model

  • id: Integer (auto-generated)
  • url: String (required) - The URL to call
  • method: String (default: "POST") - HTTP method
  • cron: String (required) - Cron expression for scheduling
  • retry_count: Integer (default: 3) - Number of retries on failure

Dependencies

  • FastAPI: Web framework
  • SQLAlchemy: ORM for database interactions
  • PostgreSQL: Database
  • Pydantic: Data validation
  • Uvicorn: ASGI server

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published