A system to process image data from CSV files asynchronously using FastAPI, Motor (async MongoDB), and Celery.
- Clone the repo:
git clone https://github.com/program2113/image-processor.git - Install dependencies:
pip install -r requirements.txt - Start services:
docker-compose up - Access APIs at
http://localhost:8000
This project provides two main APIs to upload and process image data from CSV files and check their status.
- 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" }
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:
- Method: GET
- Path Parameter: request_id (UUID string returned from Upload API) Example: curl -X GET "http://localhost:8000/status/550e8400-e29b-41d4-a716-446655440000" Response:
- Method: GET
- 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" }
404: "Request not found" (invalid request_id)
- Export the API details into the
postman_collection.jsonfile (already mentioned in the submission). Include descriptions, example requests, and responses for both endpoints there as well. This makes it interactive for testing.