Skip to content

omidcodes/taskflow-api

Repository files navigation

🧩 TaskFlow API

A Django RESTful API for managing personal or team tasks β€” featuring PostgreSQL, RabbitMQ, Celery, and Nginx in a Dockerized production setup.

πŸ“ˆ View Test Coverage Report


πŸš€ Features

  • βœ… Django 5 + Django REST Framework
  • βœ… PostgreSQL database (Dockerized)
  • βœ… RabbitMQ for background tasks (Celery-integrated)
  • βœ… Celery task queue for async logging
  • βœ… Gunicorn for WSGI-based production serving
  • βœ… Nginx reverse proxy for HTTP routing and static file delivery
  • βœ… Environment config with .env and python-decouple
  • βœ… Swagger UI for API documentation
  • βœ… Docker & Docker Compose for development and deployment
  • βœ… Pytest-based testing with coverage reporting

πŸ“ Project Structure

taskflow-api/
β”œβ”€β”€ taskflow_api/           # Django project (with celery.py)
β”œβ”€β”€ tasks/                  # App: models, views, serializers, signals, celery tasks
β”œβ”€β”€ tests/                  # Pytest tests for models, views, celery
β”œβ”€β”€ Dockerfile              # Docker image for Django (Gunicorn inside)
β”œβ”€β”€ docker-compose.yml      # Full stack (Django, DB, Celery, Nginx, RabbitMQ)
β”œβ”€β”€ nginx.conf              # Nginx config for reverse proxy
β”œβ”€β”€ .env                    # Environment variables
β”œβ”€β”€ logs/                   # Log folder (created if missing)
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ run_server.sh           # Start all services in production mode
β”œβ”€β”€ start-dev-services.sh   # Run only DB & RabbitMQ for local development
β”œβ”€β”€ lint-clean.sh           # Format & lint Python code using Ruff
└── pytest.ini              # Pytest configuration

βš™οΈ Prerequisites

  • Python 3.12+
  • Docker & Docker Compose
  • (Optional) Virtualenv for local development

πŸ“¦ Setup Instructions

πŸ”§ 1. Create Virtual Environment (Optional)

python3 -m venv env
source env/bin/activate
pip install -r requirements.txt

πŸ”§ 2. Configure Environment

Copy the .env.example file and rename it to .env .


πŸ§ͺ Development Mode (Local Python)

Run Django and Celery locally. Use Docker for DB & RabbitMQ only.

make dev    # using Makefile to create development envionment
pre-commit install && pre-commit install --hook-type commit-msg -f
python manage.py runserver   # Run Django locally
celery -A taskflow_api worker --loglevel=info  # Start Celery

Local URLs:


πŸ§ͺ Run Tests

▢️ Run all tests

pytest

▢️ With coverage

pytest --cov=. --cov-report=term-missing

▢️ (Optional) HTML Coverage Report

pytest --cov=. --cov-report=html
# Open htmlcov/index.html in your browser

🧩 Celery Background Logging

When a task is created via API, a background task (log_task_action) is triggered:

  • Logs to logs/task_activity.log
  • Format:
[2025-09-14 19:45:00] Task #12 ('Example Task') was created via Celery background task.

🏭 Production Mode (Dockerized Full Stack)

▢️ Start All Services

./run_server.sh

This command will:

  • Build the Docker image
  • Run Django with Gunicorn
  • Serve via Nginx on port 80
  • Collect static files into a volume
  • Expose the full app on http://localhost/

Alternatively:

docker compose up --build

🌐 Accessing App


πŸ—ƒοΈ Tech Stack

Layer Tech
Backend Django 5 + DRF
Database PostgreSQL
Broker RabbitMQ
Async Tasks Celery
Server Gunicorn + Nginx
Containers Docker Compose
Testing Pytest + pytest-cov
Linting Ruff
Deployment Shell scripts + volumes

πŸ“œ License

MIT Β© Omid Hashemzadeh

Packages

 
 
 

Contributors