Skip to content

FlavoGen Backend API is a DRF backend for an AI-powered recipe-sharing platform with a separate frontend. It offers intelligent recipe recommendations, user authentication, chatbot integration, and PostgreSQL support. Designed for seamless full-stack integration, it empowers food enthusiasts to explore, share, and discover culinary experiences.

Notifications You must be signed in to change notification settings

M-Husnain-Ali/FlavoGen-AI-Powered-Recipe-Sharing-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FlavoGen Backend API

Overview

This is the backend API service for the FlavoGen Recipe Sharing Platform. Built with Django and Django REST Framework, it provides a robust RESTful API that powers the FlavoGen Frontend.

System Architecture

  • Frontend: React.js (Repository Link)
  • Backend: Django REST Framework (This Repository)
  • Database: PostgreSQL
  • Authentication: Token-based Authentication
  • File Storage: Local Media Storage

API Features

πŸ” Authentication & Authorization

  • Token-based authentication system
  • User registration and login endpoints
  • Password change functionality
  • Permission-based access control

πŸ“‘ RESTful Endpoints

  • Recipe Management

    • CRUD operations for recipes
    • Image upload handling
    • Ingredient management
    • Recipe search functionality
  • User Interactions

    • Rating system
    • Comment management
    • Bookmark functionality
    • User feedback collection
  • AI Integration

    • Chatbot API endpoint
    • Recipe recommendations
    • Search optimization

πŸŽ› Admin Interface

The Django admin interface (/admin) provides:

  • User management dashboard
  • Content moderation tools
  • System monitoring
  • Data management capabilities

API Documentation

Authentication Endpoints

POST /auth/          # Obtain authentication token
POST /users/         # Register new user
POST /login/         # User login
POST /change-password/ # Change password

Recipe Endpoints

GET    /recipes/           # List all recipes
POST   /recipes/           # Create new recipe
GET    /recipes/{id}/      # Get recipe details
PUT    /recipes/{id}/      # Update recipe
DELETE /recipes/{id}/      # Delete recipe
GET    /recipe-search/     # Search recipes

Interaction Endpoints

POST /comments/            # Add comment
POST /ratings/            # Rate recipe
POST /bookmarks/          # Bookmark recipe
GET  /bookmarked-recipes/ # Get bookmarked recipes
POST /feedback/           # Submit feedback
POST /chatbot/           # Chat with AI assistant

Technical Stack

Core Technologies

  • Python 3.8+
  • Django 5.1
  • Django REST Framework
  • PostgreSQL
  • Token Authentication

Key Dependencies

Django>=5.1.3
djangorestframework>=3.14.0
django-cors-headers>=4.3.1
Pillow>=10.1.0
psycopg2-binary>=2.9.9
python-dotenv>=1.0.0
dj-database-url>=2.1.0

Getting Started

Prerequisites

  • Python 3.8+
  • PostgreSQL
  • pip

Local Development Setup

  1. Clone the repository:

    git clone <repository-url>
    cd Recipe_Sharing_Backend
  2. Create virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure environment:

    • Copy .env.example to .env
    • Update database and other settings in .env
  5. Database setup:

    python manage.py migrate
  6. Create admin user:

    python manage.py createsuperuser
  7. Run development server:

    python manage.py runserver

Server will be available at:

  • API: http://localhost:8000/
  • Admin Interface: http://localhost:8000/admin

Project Structure

api/
β”œβ”€β”€ api/                    # Project configuration
β”‚   β”œβ”€β”€ settings.py        # Django settings
β”‚   β”œβ”€β”€ urls.py           # Main URL routing
β”‚   └── wsgi.py           # WSGI configuration
β”œβ”€β”€ recipe_app/            # Main application
β”‚   β”œβ”€β”€ models.py         # Data models
β”‚   β”œβ”€β”€ views.py          # API views
β”‚   β”œβ”€β”€ serializers.py    # Data serializers
β”‚   β”œβ”€β”€ urls.py           # API endpoints
β”‚   └── chatbotservices.py # AI chatbot logic
β”œβ”€β”€ media/                 # Uploaded files
β”œβ”€β”€ manage.py             # Django CLI
└── requirements.txt      # Dependencies

Environment Variables

Required environment variables in .env:

# Django Settings
DEBUG=True
SECRET_KEY=your-secret-key

# Database
DB_NAME=flavo_data_base
DB_USER=postgres
DB_PASSWORD=your_password
DB_HOST=localhost
DB_PORT=5432

# CORS Settings
CORS_ALLOWED_ORIGINS=http://localhost:3000

Security Considerations

  • Set DEBUG=False in production
  • Use strong SECRET_KEY
  • Configure proper CORS settings
  • Secure database credentials
  • Implement rate limiting
  • Regular security updates

Development Guidelines

  1. Follow Django REST Framework best practices
  2. Write tests for new features
  3. Document API changes
  4. Use meaningful commit messages
  5. Follow PEP 8 style guide

Production Deployment

  • Configure production-grade web server (e.g., Gunicorn)
  • Set up proper static/media file serving
  • Configure SSL/TLS
  • Set up proper database backup
  • Configure error logging

Contributing

  1. Fork the repository
  2. Create feature branch
  3. Commit changes
  4. Push to branch
  5. Create Pull Request

License

MIT

Related Projects

πŸ“Š Architecture, Sequence, and Class Diagrams

This repository includes detailed sequence and class diagrams to illustrate the backend architecture and major workflows of the FlavoGen platform. These diagrams are located in the Sequence and Design Class Diagram/ folder.

Included Diagrams

  • Design Class Diagram: High-level overview of backend classes and their relationships (Design Class Diagram.jpg and .drawio.xml)
  • Sequence Diagrams: Step-by-step flows for key features:
    • Add Recipe
    • Add Review
    • Bookmark Recipe
    • Manage User Generated Content
    • Rate Recipe
    • Recipe Recommendation
    • Search Recipe
    • Share Recipe
    • User Management
    • View Recipe

Each diagram is available as a .jpg image for quick viewing and as a .drawio.xml file for editing in draw.io.

Folder structure:

Sequence and Design Class Diagram/
β”œβ”€β”€ Add Recipe.jpg
β”œβ”€β”€ Add Review.jpg
β”œβ”€β”€ Bookmark Recipe.jpg
β”œβ”€β”€ Design Class Diagram.jpg
β”œβ”€β”€ Manage User Generated Content.jpg
β”œβ”€β”€ Rate Recipe.jpg
β”œβ”€β”€ Recipe Recommendation.jpg
β”œβ”€β”€ Search Recipe.jpg
β”œβ”€β”€ Share Recipe.jpg
β”œβ”€β”€ User Management.jpg
β”œβ”€β”€ View Recipe.jpg
└── Xml file/
    β”œβ”€β”€ Add Recipe.drawio.xml
    β”œβ”€β”€ Add Review.drawio.xml
    β”œβ”€β”€ Bookmark Recipe.drawio.xml
    β”œβ”€β”€ Design Class Diagram.drawio.xml
    β”œβ”€β”€ Manage User Generated Content.drawio.xml
    β”œβ”€β”€ Rate Recipe.drawio.xml
    β”œβ”€β”€ Recipe Recommendation.drawio.xml
    β”œβ”€β”€ Search Recipe.drawio.xml
    β”œβ”€β”€ Share Recipe.drawio.xml
    β”œβ”€β”€ User Management.drawio.xml
    └── View Recipe.drawio.xml

These diagrams are useful for understanding the backend logic, data flow, and system design. You can open the .drawio.xml files in draw.io for further editing or customization.

About

FlavoGen Backend API is a DRF backend for an AI-powered recipe-sharing platform with a separate frontend. It offers intelligent recipe recommendations, user authentication, chatbot integration, and PostgreSQL support. Designed for seamless full-stack integration, it empowers food enthusiasts to explore, share, and discover culinary experiences.

Topics

Resources

Stars

Watchers

Forks

Languages