@@ -9,7 +9,8 @@ A Django RESTful API for managing personal or team tasks — featuring PostgreSQ
99
1010- ✅ Django 5 + Django REST Framework
1111- ✅ PostgreSQL database (via Docker)
12- - ✅ RabbitMQ for background tasks (Celery-ready)
12+ - ✅ RabbitMQ for background tasks (Celery integrated)
13+ - ✅ Asynchronous task logging using Celery
1314- ✅ Environment config with ` .env ` and ` python-decouple `
1415- ✅ Swagger UI for API documentation
1516- ✅ Containerized with Docker
@@ -21,12 +22,13 @@ A Django RESTful API for managing personal or team tasks — featuring PostgreSQ
2122
2223```
2324taskflow-api/
24- ├── taskflow_api/ # Django project
25- ├── tasks/ # App: task models, views, serializers
25+ ├── taskflow_api/ # Django project (includes celery.py)
26+ ├── tasks/ # App: task models, views, serializers, signals, celery tasks
2627├── requirements.txt # Python dependencies
2728├── Dockerfile # Production image for gunicorn
2829├── docker-compose.yml # DB and RabbitMQ container setup
2930├── .env # Environment configuration
31+ ├── logs/ # Directory for activity logs (auto-created)
3032├── run_server.sh # Run production server (Gunicorn)
3133└── start-dev-services.sh # Run DB + RabbitMQ for development
3234```
@@ -79,20 +81,38 @@ Use this when you want to run Django locally (`runserver`) and containers only f
7981
8082> This will:
8183> - Start PostgreSQL and RabbitMQ containers
82- > - Stop and remove any running ` web ` container
84+ > - Stop and remove any running web container
8385> - Run DB migrations automatically
8486
8587### ▶️ Then Run Django:
8688``` bash
8789python3 manage.py runserver
8890```
8991
92+ ### ▶️ Run Celery Worker:
93+ ``` bash
94+ celery -A taskflow_api worker --loglevel=info
95+ ```
96+
9097Open:
9198- Swagger docs: http://localhost:8000/docs/
9299- API root: http://localhost:8000/api/tasks/
93100
94101---
95102
103+ ## 🧩 Celery Logging Task
104+
105+ When a task is created through the API, a Celery worker will automatically:
106+
107+ - Run ` log_task_action ` in the background using ` celery -A taskflow_api worker --loglevel=info `
108+ - Write an entry like this to ` logs/task_activity.log ` :
109+
110+ ```
111+ [2025-09-14 19:45:00] Task #12 ('Example Task') was created via Celery background task.
112+ ```
113+
114+ ---
115+
96116## 🏭 Production Mode (Dockerized Web)
97117
98118### ▶️ Build & Run All Services:
@@ -117,11 +137,12 @@ docker compose up --build
117137- ** Backend** : Django 5, DRF
118138- ** Database** : PostgreSQL (Docker)
119139- ** Broker** : RabbitMQ (Docker)
140+ - ** Background Jobs** : Celery (activity logging)
120141- ** Containerization** : Docker, Docker Compose
121142- ** CI-ready** : Gunicorn + environment-based config
122143
123144---
124145
125146## 📜 License
126147
127- MIT © Omid Hashemzadeh
148+ MIT © Omid Hashemzadeh
0 commit comments