1-
21# 🧩 TaskFlow API
32
4- A Django RESTful API for managing personal or team tasks — featuring PostgreSQL, RabbitMQ, Docker support , and developer/ production-ready configurations .
3+ A Django RESTful API for managing personal or team tasks — featuring PostgreSQL, RabbitMQ, Celery , and Nginx in a Dockerized production setup .
54
65---
76
87## 🚀 Features
98
109- ✅ Django 5 + Django REST Framework
11- - ✅ PostgreSQL database (via Docker)
12- - ✅ RabbitMQ for background tasks (Celery integrated)
13- - ✅ Asynchronous task logging using Celery
10+ - ✅ PostgreSQL database (Dockerized)
11+ - ✅ RabbitMQ for background tasks (Celery-integrated)
12+ - ✅ Celery task queue for async logging
13+ - ✅ Gunicorn for WSGI-based production serving
14+ - ✅ Nginx reverse proxy for HTTP routing and static file delivery
1415- ✅ Environment config with ` .env ` and ` python-decouple `
1516- ✅ Swagger UI for API documentation
16- - ✅ Containerized with Docker
17- - ✅ CLI scripts for development and production modes
18- - ✅ Pytest-based testing with coverage
17+ - ✅ Docker & Docker Compose for development and deployment
18+ - ✅ Pytest-based testing with coverage reporting
1919
2020---
2121
2222## 📁 Project Structure
2323
2424```
2525taskflow-api/
26- ├── taskflow_api/ # Django project (includes celery.py)
27- ├── tasks/ # App: task models, views, serializers, signals, celery tasks
28- ├── tests/ # Pytest tests for models, API, celery tasks
26+ ├── taskflow_api/ # Django project (with celery.py)
27+ ├── tasks/ # App: models, views, serializers, signals, celery tasks
28+ ├── tests/ # Pytest tests for models, views, celery
29+ ├── Dockerfile # Docker image for Django (Gunicorn inside)
30+ ├── docker-compose.yml # Full stack (Django, DB, Celery, Nginx, RabbitMQ)
31+ ├── nginx.conf # Nginx config for reverse proxy
32+ ├── .env # Environment variables
33+ ├── logs/ # Log folder (created if missing)
2934├── requirements.txt # Python dependencies
30- ├── Dockerfile # Production image for gunicorn
31- ├── docker-compose.yml # DB and RabbitMQ container setup
32- ├── .env # Environment configuration
33- ├── logs/ # Directory for activity logs (auto-created)
34- ├── run_server.sh # Run production server (Gunicorn)
35- ├── start-dev-services.sh # Run DB + RabbitMQ for development
36- ├── lint-clean.sh # Ruff lint & formatting script
35+ ├── run_server.sh # Start all services in production mode
36+ ├── start-dev-services.sh # Run only DB & RabbitMQ for local development
37+ ├── lint-clean.sh # Format & lint Python code using Ruff
3738└── pytest.ini # Pytest configuration
3839```
3940
@@ -43,21 +44,21 @@ taskflow-api/
4344
4445- Python 3.12+
4546- Docker & Docker Compose
46- - Virtualenv (optional but recommended)
47+ - (Optional) Virtualenv for local development
4748
4849---
4950
5051## 📦 Setup Instructions
5152
52- ### 🔧 1. Install Python Dependencies
53+ ### 🔧 1. Create Virtual Environment (Optional)
5354``` bash
5455python3 -m venv env
5556source env/bin/activate
5657pip install -r requirements.txt
5758```
5859
5960### 🔧 2. Configure Environment
60- Edit ` .env ` (already provided) :
61+ Edit the ` .env ` file :
6162``` dotenv
6263DEBUG=True
6364SECRET_KEY=your-secret-key
@@ -74,101 +75,100 @@ CELERY_BROKER_URL=amqp://guest:guest@localhost:5672//
7475
7576---
7677
77- ## 🧪 Development Mode
78+ ## 🧪 Development Mode (Local Python)
7879
79- Use this when you want to run Django locally ( ` runserver ` ) and containers only for DB/ RabbitMQ.
80+ Run Django and Celery locally. Use Docker for DB & RabbitMQ only .
8081
81- ### ▶️ Start Docker Services:
8282``` bash
83- ./start-dev-services.sh
83+ ./start-dev-services.sh # Start db + rabbitmq only
84+ python manage.py runserver # Run Django locally
85+ celery -A taskflow_api worker --loglevel=info # Start Celery
8486```
8587
86- > This will:
87- > - Start PostgreSQL and RabbitMQ containers
88- > - Stop and remove any running web container
89- > - Run DB migrations automatically
90-
91- ### ▶️ Then Run Django:
92- ``` bash
93- python3 manage.py runserver
94- ```
95-
96- ### ▶️ Run Celery Worker:
97- ``` bash
98- celery -A taskflow_api worker --loglevel=info
99- ```
100-
101- Open:
102- - Swagger docs: http://localhost:8000/docs/
103- - API root: http://localhost:8000/api/tasks/
88+ > Local URLs:
89+ > - API: http://localhost:8000/api/tasks/
90+ > - Docs: http://localhost:8000/docs/
10491
10592---
10693
107- ## 🧪 Run Tests and Coverage
94+ ## 🧪 Run Tests
10895
10996### ▶️ Run all tests
11097``` bash
11198pytest
11299```
113100
114- ### ▶️ Run tests ** with coverage** (after installing ` pytest-cov ` )
101+ ### ▶️ With coverage
115102``` bash
116103pytest --cov=. --cov-report=term-missing
117104```
118105
119- ### ▶️ (Optional) Generate HTML coverage report
106+ ### ▶️ (Optional) HTML Coverage Report
120107``` bash
121108pytest --cov=. --cov-report=html
122109# Open htmlcov/index.html in your browser
123110```
124111
125112---
126113
127- ## 🧩 Celery Logging Task
128-
129- When a task is created through the API, a Celery worker will automatically:
114+ ## 🧩 Celery Background Logging
130115
131- - Run ` log_task_action ` in the background using ` celery -A taskflow_api worker --loglevel=info `
132- - Write an entry like this to ` logs/task_activity.log ` :
116+ When a task is created via API, a background task (` log_task_action ` ) is triggered:
133117
118+ - Logs to ` logs/task_activity.log `
119+ - Format:
134120```
135121[2025-09-14 19:45:00] Task #12 ('Example Task') was created via Celery background task.
136122```
137123
138124---
139125
140- ## 🏭 Production Mode (Dockerized Web )
126+ ## 🏭 Production Mode (Dockerized Full Stack )
141127
142- ### ▶️ Build & Run All Services:
128+ ### ▶️ Start All Services
143129``` bash
144130./run_server.sh
145131```
146132
147- > This uses Docker to run:
148- > - Django (with Gunicorn)
149- > - PostgreSQL
150- > - RabbitMQ
133+ This command will:
134+ - Build the Docker image
135+ - Run Django with Gunicorn
136+ - Serve via Nginx on port ` 80 `
137+ - Collect static files into a volume
138+ - Expose the full app on http://localhost/
151139
152- You can also run manually :
140+ > Alternatively :
153141``` bash
154142docker compose up --build
155143```
156144
157145---
158146
147+ ## 🌐 Accessing App
148+
149+ - Web App: [ http://localhost/ ] ( http://localhost/ )
150+ - API: [ http://localhost/api/tasks/ ] ( http://localhost/api/tasks/ )
151+ - Swagger Docs: [ http://localhost/docs/ ] ( http://localhost/docs/ )
152+ - RabbitMQ UI: [ http://localhost:15672 ] ( http://localhost:15672 ) (user/pass: guest/guest)
153+
154+ ---
155+
159156## 🗃️ Tech Stack
160157
161- - ** Backend** : Django 5, DRF
162- - ** Database** : PostgreSQL (Docker)
163- - ** Broker** : RabbitMQ (Docker)
164- - ** Background Jobs** : Celery (activity logging)
165- - ** Containerization** : Docker, Docker Compose
166- - ** Testing** : Pytest, pytest-django, pytest-cov
167- - ** Linting** : Ruff
168- - ** CI-ready** : Gunicorn + environment-based config
158+ | Layer | Tech |
159+ | ---------------| -------------------------|
160+ | Backend | Django 5 + DRF |
161+ | Database | PostgreSQL |
162+ | Broker | RabbitMQ |
163+ | Async Tasks | Celery |
164+ | Server | Gunicorn + Nginx |
165+ | Containers | Docker Compose |
166+ | Testing | Pytest + pytest-cov |
167+ | Linting | Ruff |
168+ | Deployment | Shell scripts + volumes |
169169
170170---
171171
172172## 📜 License
173173
174- MIT © Omid Hashemzadeh
174+ MIT © Omid Hashemzadeh
0 commit comments