An asynchronous task processing microservice built with FastAPI.
This project demonstrates how to accept incoming work, dispatch it to background
tasks, and expose simple HTTP endpoints for checking task status.
It is intentionally small and easy to read so it can be used as a teaching / portfolio project for backend + async patterns in Python.
/tasksendpoint to enqueue work using FastAPIBackgroundTasks- In-memory task store for demo purposes (no external queue required)
/tasks/{task_id}endpoint to check the task status/healthendpoint for simple health checking- Clean separation between request models, task processor, and status store
async-task-processor/
ββ app/
β ββ main.py # FastAPI app + background task processing
ββ requirements.txt # Python dependencies
ββ README.md # Project documentation
# 1. Clone the repository
git clone https://github.com/YOUR_USERNAME/async-task-processor.git
cd async-task-processor
# 2. Create a virtual environment (optional, but recommended)
python3 -m venv venv
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# 3. Install dependencies
pip install -r requirements.txt
# 4. Start the FastAPI server
uvicorn app.main:app --reload{
"task_type": "send_email",
"payload": {
"to": "[email protected]",
"subject": "Welcome",
"body": "Thanks for signing up!"
}
}{
"task_id": "task_1",
"status": "queued"
}GET /tasks/task_1{
"task_id": "task_1",
"status": "processing"
}{ "status": "ok" }To make it production-ready you could integrate:
- Redis + RQ / Celery workers
- A message broker like RabbitMQ or Kafka
- A database table to persist task status
The API contract can stay the same while the internal implementation improves underneath.
- Python 3.10+
- FastAPI
- Pydantic
- Uvicorn(ASGI server)