Skip to content

Repository files navigation

Deficit-API

Deficit-API is a Django-based RESTful API designed to track and manage dietary intake, specifically focusing on caloric intake and expenditure. It allows users to maintain a log of foods consumed and exercises performed to manage their caloric deficit effectively.

Live Hosting

Features

  1. Food Management: Users can add, update, and delete food items along with their caloric values and units.
  2. Exercise Tracking: Allows users to log their physical activities along with calories burned.
  3. Caloric Deficit Calculation: Automatically calculates daily caloric deficits based on food intake and exercise.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

What things you need to install the software:

  • Python 3.x
  • Django
  • Django Rest Framework

Installing

A step-by-step series of examples that tell you how to get a development environment running:

  1. Clone the repository:

    git clone https://github.com/divyesh1099/Deficit-API.git
  2. Install required packages:

    pip install -r requirements.txt
  3. Migrate the database:

    python manage.py migrate
  4. Run the server:

    python manage.py runserver

Using the API

Here's a summary of the API endpoints for managing user-added foods and exercises, formatted in a tabular view. This table assumes you are running the Django server locally and using the default development URL (http://127.0.0.1:8000/). Adjust as necessary for your actual environment, especially when deployed:

Food Management

Method API Endpoint Body Headers Description
POST /userfoods/ { "food": 1, "amount": 100 } Authorization: Token <your_token>
Content-Type: application/json
Create a new user food entry.
GET /userfoods/ None Authorization: Token <your_token> Retrieve a list of all food entries for the authenticated user.
GET /userfoods/<int:id>/ None Authorization: Token <your_token> Retrieve a specific user food entry by its ID.
PUT /userfoods/<int:id>/ { "food": 1, "amount": 150 } Authorization: Token <your_token>
Content-Type: application/json
Update an entire specific user food entry.
PATCH /userfoods/<int:id>/ { "amount": 120 } Authorization: Token <your_token>
Content-Type: application/json
Partially update a specific user food entry.
DELETE /userfoods/<int:id>/ None Authorization: Token <your_token> Delete a specific user food entry.

Exercise Tracking

Method API Endpoint Body Headers Description
POST /userexercises/ { "exercise": 1, "duration": 30 } Authorization: Token <your_token>
Content-Type: application/json
Create a new user exercise entry.
GET /userexercises/ None Authorization: Token <your_token> Retrieve a list of all exercise entries for the authenticated user.
GET /userexercises/<int:id>/ None Authorization: Token <your_token> Retrieve a specific user exercise entry by its ID.
PUT /userexercises/<int:id>/ { "exercise": 1, "duration": 45 } Authorization: Token <your_token>
Content-Type: application/json
Update an entire specific user exercise entry.
PATCH /userexercises/<int:id>/ { "duration": 25 } Authorization: Token <your_token>
Content-Type: application/json
Partially update a specific user exercise entry.
DELETE /userexercises/<int:id>/ None Authorization: Token <your_token> Delete a specific user exercise entry.

Notes:

  • Replace <int:id> with the actual ID of the user food entry you want to interact with.
  • Replace <your_token> with the actual authentication token of the logged-in user.
  • The food value in the body should be the ID of an existing food in your database.
  • For Authorization, you might need to replace 'Token' with 'Bearer' or another prefix depending on your authentication setup.
  • The actual URL path may vary depending on your project's urls.py configuration.
  • This table assumes you are using token-based authentication. If you are using a different method, the Authorization header may vary.
  • The Content-Type: application/json header is important when sending a body payload; it tells the server to expect JSON data.

Deployment

Instructions on how to deploy the project on a live system like PythonAnywhere:

  1. Set up your PythonAnywhere account and web app.
  2. Upload your project files or clone your repository.
  3. Set up your virtual environment and install dependencies.
  4. Configure static and media files.
  5. Reload your web app.

Detailed instructions are available on PythonAnywhere Help.

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • Divyesh Vishwakarma's Body that said, ITS TIME TO FEEL GOOD BABY.
  • Moti❤️.

About

It's API for the Deficit App.

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages