Skip to content

REST API for managing recipes, ingredients, and tags using Django, DRF, and Docker

Notifications You must be signed in to change notification settings

SheikhIshere/django-recipe-api

Repository files navigation

Recipe API 🍳

A robust, well-tested RESTful API for managing recipes with full CRUD operations, authentication, and image uploads.

Django DRF Docker PostgreSQL

✨ Features

Feature Description
🔐 Authentication Token-based auth with custom email user model
📝 Recipe Management Full CRUD with image uploads & filtering
🏷️ Tag System Organize recipes with customizable tags
🥗 Ingredient System Manage recipe ingredients efficiently
📚 API Documentation Interactive Swagger/OpenAPI docs
🐳 Docker Ready Production-ready containerization
Well Tested 1000+ lines of comprehensive tests

🚀 Quick Start

Prerequisites

  • Docker
  • Docker Compose

Installation

  1. Clone & Setup
git clone https://github.com/SheikhIshere/django-recipe-api
cd recipe_api
  1. Build & Run
docker-compose build
docker-compose up
  1. Access the API
  1. Create Superuser (optional)
docker-compose run --rm app sh -c 'python manage.py createsuperuser'

📁 Project Structure

recipe_api/
├── App/
│   ├── core/                 # Project settings & config
│   ├── users/               # Custom user model & auth
│   ├── recipe/              # Recipe, Tag, Ingredient models
│   └── test/               # 1000+ lines of comprehensive tests
├── docker-compose.yml       # Multi-service setup
├── Dockerfile              # App container definition
└── requirements.txt        # Python dependencies

🔌 API Endpoints

Method Endpoint Description
POST /api/users/ User registration
POST /api/users/token/ Get auth token
GET /api/recipes/ List recipes
POST /api/recipes/ Create recipe
GET /api/recipes/{id}/ Get recipe details
PUT /api/recipes/{id}/ Update recipe
DELETE /api/recipes/{id}/ Delete recipe
GET/POST /api/tags/ Manage tags
GET/POST /api/ingredients/ Manage ingredients

🛠️ Development

Running Tests

docker-compose run --rm app sh -c 'python manage.py test'

Database Migrations

docker-compose run --rm app sh -c 'python manage.py migrate'

Accessing Container Shell

docker-compose exec app sh

🎯 Key Features Deep Dive

🔐 Secure Authentication

  • Custom user model with email authentication
  • Token-based security for API access
  • Protected endpoints with DRF permissions

📝 Advanced Recipe Management

  • Image upload with UUID filename handling
  • Many-to-many relationships with Tags & Ingredients
  • Advanced filtering (?tags=1,2, ?ingredients=3)
  • assigned_only query parameter for clean responses

✅ Production Ready

  • PostgreSQL for production database
  • Docker containerization
  • Comprehensive test suite
  • Modular and scalable architecture

🚦 Example Usage

Create Recipe

POST /api/recipes/
Content-Type: application/json
Authorization: Token <your-token>

{
  "title": "Pasta Carbonara",
  "time_minutes": 30,
  "price": 12.50,
  "tags": [1, 2],
  "ingredients": [1, 3, 5]
}

Filter Recipes

GET /api/recipes/?tags=1&ingredients=3

📊 Testing Coverage

The project includes extensive testing with:

  • ✅ Model tests
  • ✅ API endpoint tests
  • ✅ Authentication tests
  • ✅ Serializer validation tests
  • ✅ Image upload tests
  • ✅ Filter and search tests

🔮 Future Enhancements

  • Recipe rating system
  • Advanced search with Elasticsearch
  • Social features (sharing, comments)
  • Meal planning functionality
  • Recipe import from URLs

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.


Built with ❤️ using Django REST Framework | 100% Test Coverage

About

REST API for managing recipes, ingredients, and tags using Django, DRF, and Docker

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published