File size: 2,129 Bytes
ef8b3c2
 
 
 
 
 
 
 
 
 
 
af48aca
3c88e9f
af48aca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b5edbe6
 
 
af48aca
 
b5edbe6
 
af48aca
 
b5edbe6
 
af48aca
b5edbe6
af48aca
b5edbe6
af48aca
 
b5edbe6
af48aca
b5edbe6
 
 
af48aca
b5edbe6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
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**:
   ```bash
   git clone https://github.com/prathameshks/FoodAnalyzer-API.git
   ```

2. **Navigate to the project directory**:
   ```bash
   cd FoodAnalyzer-API
   ```

3. **Create a virtual environment**:
   ```bash
   python -m venv venv
   ```

4. **Activate the virtual environment**:
   - On Windows:
     ```bash
     venv\Scripts\activate
     ```
   - On macOS/Linux:
     ```bash
     source venv/bin/activate
     ```

5. **Install dependencies**:
   ```bash
   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**:
   ```bash
   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.

<!-- ### Product Data
- `GET /api/extract_product_info`: Extract product information from a barcode.
- `POST /api/fetch_product_data`: Fetch product data for a list of barcodes. -->


## Alembic migrations

### To create a new migration, run the following command:
```bash
alembic init migrations
```

### To generate a new migration file, run:
```bash
alembic revision --autogenerate -m "Message"
```

### To apply the migration, run:
```bash
alembic upgrade head
```

### To downgrade the migration, run:
```bash
alembic downgrade -1
```

### To view the current migration version, run:
```bash
alembic current
```