food-analyzer-API / README.md
prathameshks's picture
Update README.md
ef8b3c2
metadata
license: mit
title: Food Analyzer API
sdk: docker
emoji: 🔥
colorFrom: red
colorTo: purple
pinned: true
short_description: Fast API

FoodAnalyzer-API

Installation and Setup

  1. Clone the repository:

    git clone https://github.com/prathameshks/FoodAnalyzer-API.git
    
  2. Navigate to the project directory:

    cd FoodAnalyzer-API
    
  3. Create a virtual environment:

    python -m venv venv
    
  4. Activate the virtual environment:

    • On Windows:
      venv\Scripts\activate
      
    • On macOS/Linux:
      source venv/bin/activate
      
  5. Install dependencies:

    pip install -r requirements.txt
    
  6. Set up environment variables: Copy the .env.example file to .env and fill in the required values, including API keys for Hugging Face Transformers.

  7. Run the application:

    uvicorn main:app --reload
    

API Endpoints

Authentication

  • POST /api/auth/register: Register a new user.
  • POST /api/auth/login: Login and obtain an access token.
  • GET /api/auth/user: Get the current user's information.

Ingredient Analysis

  • POST /api/analyze/analyze_ingredients: Analyze a list of ingredients.
  • GET /api/analyze/personalized_recommendations: Get personalized ingredient recommendations.

Scan History

  • POST /api/history/scan: Record a new scan.
  • GET /api/history/scan/{user_id}: Retrieve the scan history for a user.

Alembic migrations

To create a new migration, run the following command:

alembic init migrations

To generate a new migration file, run:

alembic revision --autogenerate -m "Message"

To apply the migration, run:

alembic upgrade head

To downgrade the migration, run:

alembic downgrade -1

To view the current migration version, run:

alembic current