https://github.com/nikhil25803/track-calories
Backend for calorie tracking application using NLP-powered Nutritionix API to fetch calories from the text. In this RESTful API, multiple-level authentication, SQLite DB, OAuth, etc. are implemented.
https://github.com/nikhil25803/track-calories
fastapi pytest python3 sqlite
Last synced: about 1 year ago
JSON representation
Backend for calorie tracking application using NLP-powered Nutritionix API to fetch calories from the text. In this RESTful API, multiple-level authentication, SQLite DB, OAuth, etc. are implemented.
- Host: GitHub
- URL: https://github.com/nikhil25803/track-calories
- Owner: nikhil25803
- License: gpl-3.0
- Created: 2023-07-17T12:09:38.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-17T12:16:57.000Z (about 3 years ago)
- Last Synced: 2025-04-08T01:34:12.528Z (over 1 year ago)
- Topics: fastapi, pytest, python3, sqlite
- Language: Python
- Homepage:
- Size: 29.3 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Tech Stack 🖥️
  
## Commands to set up the repo (dependencies etc.) 💁♂️
- Clone the working branch
Copy the URL of the forked repository and clone it, as of now it is as follows (may vary, please check once)
```bash
git clone https://github.com/nikhil25803/track-calories.git
```
- Change the directory
```bash
cd track-calories
```
- Download Virtualenv package
```bash
pip install virtualenv
```
- Create a virtual environment
```bash
python -m venv env
```
- Activate the virtual environment
```bash
source env/scripts/activate
```
- Install the dependencies
```powershell
pip install -r requirements.txt
```
- The project setup has been completed. Before running the server, make sure to add a `.env` file with the following contents
```
OAUTH2_SECRET_KEY =
ADMIN_USERNAME =
ADMIN_PASSWORD =
MANAGER_USERNAME =
MANAGER_PASSOWRD =
NUTRITIONIX_APIKEY =
NUTRITIONIX_APPID =
```
- OAUTH2_SECRET_KEY can be generated by running the command `openssl rand -hex 32`
- Add credentials of your choice for Admin and Managers which you will use to access admin and manager level endpoints
- `NUTRITIONIX_APIKEY` and `NUTRITIONIX_APPID` needs to be generated from **nutritionix.com**. You can get them [here](https://developer.nutritionix.com/admin/access_details)
## Commands to run the API server ⚡
```bash
python main.py
```
- You will find the server running on `http://127.0.0.1:8000/`.
- You can also route to `http://127.0.0.1:8000/docs` for a user-friendly UI provided by **SwaggerUI** to interact with endpoints
**Note**
- Running the server will make a `sqlite_database.db` locally for database operations
- To run the unit and e2e test, it is important first to run the server
## Commands to run the test suite 📟
- As the `/test` directory is in the root path. You can run the test suit by running the following command
```bash
pytest
```
> Just to remind | Adding the `.env` file with the requested field is important, else some endpoints may throw some error
---