Skip to content

This project is a multi-component application developed using FastAPI. It combines a classic RESTful API for managing a task list with background processes using Celery and Redis, as well as integration with a machine learning model for predicting task priority.

Notifications You must be signed in to change notification settings

OldFox7322/technical-task-keymark

Repository files navigation

To-Do API with Celery and ML Integration

Project Description

This project is a multi-component application built with FastAPI. It combines a classic RESTful API for managing a to-do list with background processes powered by Celery and Redis, and integrates a machine learning model to predict task priority.

The project is composed of the following services, all running within Docker containers:

  • trainer: Trains and saves the machine learning model. This service runs first.
  • api: The FastAPI application with core API endpoints and ML functionality.
  • worker: The Celery Worker for processing background tasks.
  • beat: The Celery Beat scheduler for running tasks on a schedule.
  • redis: The Celery task broker, also used for caching.
  • tests: A container for running automated unit tests.

How to Install and Run Docker

Docker is a platform for developing, shipping, and running applications in containers.

Windows

  1. Go to the official Docker website.
  2. Download Docker Desktop for Windows.
  3. Run the installer and follow the instructions. Docker Desktop includes the Docker Engine, Docker CLI, and Docker Compose.
  4. After installation, launch Docker Desktop.

macOS

  1. Go to the official Docker website.
  2. Download Docker Desktop for Mac.
  3. Double-click the downloaded .dmg file and drag the Docker icon into your Applications folder.
  4. Launch Docker Desktop from the Applications folder.

Linux (Ubuntu)

  1. Open your terminal.
  2. Update your package index: sudo apt-get update
  3. Install Docker Engine, Docker CLI, and Containerd: sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
  4. Add your user to the docker group to run commands without sudo: sudo usermod -aG docker $USER
  5. Log out and back in for the changes to take effect.
  6. Verify your Docker installation with: docker run hello-world

Project Setup and Launch

  1. Clone the repository. Open your terminal and use the following command to download the project: git clone https://github.com/OldFox7322/technical-task-keymark Then, navigate to the project's root directory: cd <your_project_directory>

  2. Navigate to the project's root directory.

  3. Start all services using Docker Compose. This will automatically build and launch all necessary containers and run the unit tests.

    docker-compose up --build

  4. Wait for all containers to start. The trainer service will run first to create the model, followed by the api, and then the tests will run once the api is ready. The process is complete when you see a message about the tests successfully passing.

  5. Once running, your API will be available at:

    • Base URL: http://localhost:8000
    • Interactive Docs (Swagger UI): http://localhost:8000/docs

API Endpoints

The project provides the following API endpoints:

  • GET /tasks: Retrieves a list of all tasks.
  • POST /tasks: Creates a new task.
  • PUT /tasks/{id}: Updates an existing task by its ID.
  • DELETE /tasks/{id}: Deletes a task by its ID.
  • POST /predict: Uses the machine learning model to predict a task's priority.
  • POST /sync-users: Launches a background task to synchronize user data from an external API.

Testing

Unit tests run automatically on startup. To run them manually, you can use:

docker-compose up --build --abort-on-container-exit tests

About

This project is a multi-component application developed using FastAPI. It combines a classic RESTful API for managing a task list with background processes using Celery and Redis, as well as integration with a machine learning model for predicting task priority.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published