Skip to content

Program2113/image-processor

Repository files navigation

Image Processor

A system to process image data from CSV files asynchronously using FastAPI, Motor (async MongoDB), and Celery.

Setup

  1. Clone the repo: git clone https://github.com/program2113/image-processor.git
  2. Install dependencies: pip install -r requirements.txt
  3. Start services: docker-compose up
  4. Access APIs at http://localhost:8000

API Endpoints

This project provides two main APIs to upload and process image data from CSV files and check their status.

1. Upload API

  • Endpoint: POST /upload
  • Description: Uploads a CSV file containing product image data and optionally a webhook URL for completion notifications.
  • Request:
    • Method: POST

    • Content-Type: multipart/form-data

    • Body:

      • file: The CSV file (required). Format: S. No., Product Name, Input Image Urls (comma-separated URLs).
      • webhook_url: Optional string (URL to receive a POST callback when processing completes).
    • Example: curl -X POST "http://localhost:8000/upload"

      -F "file=@sample.csv"

      -F "webhook_url=http://example.com/webhook"

  • Response:
  • Status: 200 OK
  • Body:
    {
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "message": "File uploaded successfully, processing started"
    }

Errors:

400: "Only CSV files are allowed" (invalid file type)
400: "Invalid CSV format" (missing required columns)
  • Endpoint: GET /status/{request_id}
  • Description: Retrieves the processing status and results for a given request ID.
  • Request:
  • Status: 200 OK
  • Body:
    {
    "request_id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "completed",
    "products": [
        {
        "serial_number": 1,
        "product_name": "SKU1",
        "input_image_urls": ["https://www.public-image-url1.jpg"],
        "output_image_urls": ["http://localhost:8000/processed_images/1234.jpg"]
        }
    ],
    "webhook_url": "http://example.com/webhook",
    "created_at": "2025-02-25T12:00:00Z",
    "updated_at": "2025-02-25T12:01:00Z"
    }

Errors:

404: "Request not found" (invalid request_id)

Additional Placement: Postman Collection

  • Export the API details into the postman_collection.json file (already mentioned in the submission). Include descriptions, example requests, and responses for both endpoints there as well. This makes it interactive for testing.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published