fsteamcepz/Bonfie-Food

C#

0

36 commits

updated Jun 6, 2025

See the code

README

Bonfie Food

Authentication

login form

Main menu

main menu

Food Analysis

Technologies Used

Google Cloud Vision API

  • Used for basic image analysis and determining whether food is present in an image.

Clarifai API

  • Used for accurate recognition of food items and dishes in images.
  • The model food-item-v1-recognition classifies over 500 types of food products.

Edamam API

Used for retrieving nutritional information about food products. Edamam provides a comprehensive, ready-to-use food database and nutrition analysis service:

  • Food Database API: Free access to a database with close to 900,000 foods and over 680,000 unique UPC codes.
  • Recipe Search API: Over 2.3 million recipes by diets, calories and nutrient ranges.
  • Nutrition Analysis API: Instantly analyzes the nutrition of any recipe from plain text input.

photo upload
result

Chatbot

Technologies Used

Hugging Face API

  • The chatbot uses the HuggingFaceH4/zephyr-7b-beta model for generating human-like, context-aware responses.

history with chatbot

Reset Password

Technologies Used

Gmail API

  • The «Forgot Password» feature uses the Gmail API to send password reset emails securely.
  • It leverages «OAuth 2.0» for authentication, ensuring secure access to the user's email account without exposing sensitive credentials.

OAuth 2.0

  • OAuth 2.0 is used to authenticate and authorize the application to interact with the Gmail API.
  • A JSON key file is utilized to store client secrets, and tokens are securely stored using FileDataStore:
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
      return await GoogleWebAuthorizationBroker.AuthorizeAsync(
                   GoogleClientSecrets.FromStream(stream).Secrets,
                   new[] { GmailService.Scope.GmailSend },
                   "user",
                   CancellationToken.None,
                   new FileDataStore(TOKEN_USER, true));
}

MIME (Multipurpose Internet Mail Extensions)

  • The email content is formatted using the MIME standard, which structures the email headers (To, Subject, Content-Type) and body for proper delivery and rendering by email clients:
string mimeMessage = $"To: {emailUser}\r\n" +
                     $"Subject: {subject}\r\n" +
                     "Content-Type: text/plain; charset=utf-8\r\n" +
                     "\r\n" +
                     $"{body}";

Base64 Encoding

  • The email content is encoded in Base64 format before being sent via the Gmail API. This encoding is a requirement of the Gmail API to ensure the safe transmission of email data over the network:
private string Base64UrlEncode(string input)
{
      var inputBytes = Encoding.UTF8.GetBytes(input);
      return Convert.ToBase64String(inputBytes)
                    .Replace('+', '-')
                    .Replace('/', '_')
                    .Replace("=", "");
}

Random Password Generation

  • A temporary password is generated to ensure the user can regain access to their account securely:
private string GenerateRandomPassword(int length)
{
      string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";
      Random random = new Random();

      char[] pass = new char[length];

      for (int i = 0; i < length; i++)
      {
            pass[i] = chars[random.Next(chars.Length)];
      }
      return new string(pass);
}

forgot password form

Calculation TDEE

The TDEE Calculation feature estimates how many calories a user needs per day to maintain their current weight. It uses the «Mifflin-St Jeor Equation», one of the most accurate formulas for calculating Basal Metabolic Rate (BMR), and adjusts it based on the user’s Physical Activity Level (PAL) to determine Total Daily Energy Expenditure (TDEE).

Algorithm

1. Basal Metabolic Rate (BMR)

The BMR represents the number of calories your body needs at rest to perform basic life-sustaining functions.

  • Boys:
        BMR = (10 × weight in kg) + (6.25 × height in cm) − (5 × age) + 5
  • Girls:
        BMR = (10 × weight in kg) + (6.25 × height in cm) − (5 × age) − 161

2. Physical Activity Level (PAL)

The PAL is a multiplier based on how physically active the user is:

Activity LevelDescriptionPAL Value
SedentaryLittle or no exercise1.2
Lightly ActiveLight exercise/sports 1–3 days/week1.375
Moderately ActiveModerate exercise/sports 3–5 days/week1.55
Very ActiveHard exercise/sports 6–7 days/week1.725
Extra ActiveVery hard exercise, physical job or training 2×/day1.9

3. Total Daily Energy Expenditure (TDEE)

Once BMR and PAL are determined, the TDEE is calculated:
                 TDEE = BMR × PAL
This value represents the total number of calories needed per day to maintain the user's current body weight.

Calculation TDEE

fsteamcepz/Bonfie-Food

C#

0

36 commits

updated Jun 6, 2025

See the code

README

Bonfie Food

Authentication

login form

Main menu

main menu

Food Analysis

Technologies Used

Google Cloud Vision API

  • Used for basic image analysis and determining whether food is present in an image.

Clarifai API

  • Used for accurate recognition of food items and dishes in images.
  • The model food-item-v1-recognition classifies over 500 types of food products.

Edamam API

Used for retrieving nutritional information about food products. Edamam provides a comprehensive, ready-to-use food database and nutrition analysis service:

  • Food Database API: Free access to a database with close to 900,000 foods and over 680,000 unique UPC codes.
  • Recipe Search API: Over 2.3 million recipes by diets, calories and nutrient ranges.
  • Nutrition Analysis API: Instantly analyzes the nutrition of any recipe from plain text input.

photo upload
result

Chatbot

Technologies Used

Hugging Face API

  • The chatbot uses the HuggingFaceH4/zephyr-7b-beta model for generating human-like, context-aware responses.

history with chatbot

Reset Password

Technologies Used

Gmail API

  • The «Forgot Password» feature uses the Gmail API to send password reset emails securely.
  • It leverages «OAuth 2.0» for authentication, ensuring secure access to the user's email account without exposing sensitive credentials.

OAuth 2.0

  • OAuth 2.0 is used to authenticate and authorize the application to interact with the Gmail API.
  • A JSON key file is utilized to store client secrets, and tokens are securely stored using FileDataStore:
using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
{
      return await GoogleWebAuthorizationBroker.AuthorizeAsync(
                   GoogleClientSecrets.FromStream(stream).Secrets,
                   new[] { GmailService.Scope.GmailSend },
                   "user",
                   CancellationToken.None,
                   new FileDataStore(TOKEN_USER, true));
}

MIME (Multipurpose Internet Mail Extensions)

  • The email content is formatted using the MIME standard, which structures the email headers (To, Subject, Content-Type) and body for proper delivery and rendering by email clients:
string mimeMessage = $"To: {emailUser}\r\n" +
                     $"Subject: {subject}\r\n" +
                     "Content-Type: text/plain; charset=utf-8\r\n" +
                     "\r\n" +
                     $"{body}";

Base64 Encoding

  • The email content is encoded in Base64 format before being sent via the Gmail API. This encoding is a requirement of the Gmail API to ensure the safe transmission of email data over the network:
private string Base64UrlEncode(string input)
{
      var inputBytes = Encoding.UTF8.GetBytes(input);
      return Convert.ToBase64String(inputBytes)
                    .Replace('+', '-')
                    .Replace('/', '_')
                    .Replace("=", "");
}

Random Password Generation

  • A temporary password is generated to ensure the user can regain access to their account securely:
private string GenerateRandomPassword(int length)
{
      string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*";
      Random random = new Random();

      char[] pass = new char[length];

      for (int i = 0; i < length; i++)
      {
            pass[i] = chars[random.Next(chars.Length)];
      }
      return new string(pass);
}

forgot password form

Calculation TDEE

The TDEE Calculation feature estimates how many calories a user needs per day to maintain their current weight. It uses the «Mifflin-St Jeor Equation», one of the most accurate formulas for calculating Basal Metabolic Rate (BMR), and adjusts it based on the user’s Physical Activity Level (PAL) to determine Total Daily Energy Expenditure (TDEE).

Algorithm

1. Basal Metabolic Rate (BMR)

The BMR represents the number of calories your body needs at rest to perform basic life-sustaining functions.

  • Boys:
        BMR = (10 × weight in kg) + (6.25 × height in cm) − (5 × age) + 5
  • Girls:
        BMR = (10 × weight in kg) + (6.25 × height in cm) − (5 × age) − 161

2. Physical Activity Level (PAL)

The PAL is a multiplier based on how physically active the user is:

Activity LevelDescriptionPAL Value
SedentaryLittle or no exercise1.2
Lightly ActiveLight exercise/sports 1–3 days/week1.375
Moderately ActiveModerate exercise/sports 3–5 days/week1.55
Very ActiveHard exercise/sports 6–7 days/week1.725
Extra ActiveVery hard exercise, physical job or training 2×/day1.9

3. Total Daily Energy Expenditure (TDEE)

Once BMR and PAL are determined, the TDEE is calculated:
                 TDEE = BMR × PAL
This value represents the total number of calories needed per day to maintain the user's current body weight.

Calculation TDEE

Languages

C#

100.0%