Coder Social home page Coder Social logo

pkirilin / food-diary Goto Github PK

View Code? Open in Web Editor NEW
17.0 0.0 0.0 395.16 MB

A web application for tracking calories count for meals. Built with ASP.NET Core, React and Material UI

Home Page: https://pkirilin-food-diary-demo.netlify.app

C# 51.14% Dockerfile 0.09% HTML 0.11% TypeScript 47.49% JavaScript 1.17%
dotnet food-app healthcare material-ui react calories-calculator calories-tracker

food-diary's Introduction

food-diary

food-diary

Introduction

food-diary is a web application for tracking calories count for meals eaten daily. It represents an interactive diary, which is able to record notes about products and their quantities and calculate calories for each note (or group of notes) recorded.

Main idea and goal

The diary consists of pages. Each page is associated with some date and contains notes grouped by meal types (breakfast, lunch etc.). Note contains information about product and its quantity. Products are grouped by categories. Each product has name and calories cost per 100 g of product's quantity recorded. Using this information the application is capable of calculating calories count of:

  • single note
  • notes group (e.g. for specific meal type)
  • the entire page.

This information can be extremely useful for people who want to keep track of energy value of meals they eat every day.

Quick start (docker-compose)

  1. Setup Google OAuth 2.0 client you will use for sign in

  2. Create a copy of .env.example file and save it as .env:

    cat .env.example >> .env
  3. Fill your credentials, then run:

    docker-compose up -d
  4. Navigate to https://localhost:8080

Development

  1. Start PostgreSQL database:

    docker run -p 5432:5432 --name postgres \
        -e POSTGRES_USER=postgres \
        -e POSTGRES_PASSWORD=postgres \
        -e POSTGRES_DB=FoodDiary \
        -d postgres:15.1-alpine

    Optional: PgAdmin can be started like this:

    docker run -p 5050:80 --name pgadmin -e "[email protected]" -e "PGADMIN_DEFAULT_PASSWORD=postgres" -d dpage/pgadmin4
  2. Install .NET SDK 8.0.100 or higher

  3. Install Node.js 18.16.0 or higher

  4. Install yarn package manager

  5. Fill necessary secrets:

    dotnet user-secrets --project src/backend/src/FoodDiary.API set "Auth:AllowedEmails:0" "<your_email>"
    
    dotnet user-secrets --project src/backend/src/FoodDiary.API set "ConnectionStrings:Default" "<your_db_connection_string>"
    
    # Optional, used in recognize note by photo feature
    dotnet user-secrets --project src/backend/src/FoodDiary.API set "Integrations:OpenAI:ApiKey" "<your_OpenAI_api_key>"

    Allowed email should be compatible with Google Identity Provider

  6. Run migrations:

    dotnet run --project src/backend/src/FoodDiary.Migrator
  7. Start backend application:

    dotnet run --project src/backend/src/FoodDiary.API
  8. Start frontend application:

    cd src/frontend
    yarn start
  9. Navigate to https://localhost:8080

How to run frontend without backend

Go to frontend project directory:

cd src/frontend

Create local env config:

touch env.local

Fill env.local with this values:

VITE_APP_MSW_ENABLED=true
VITE_APP_FAKE_AUTH_ENABLED=true
VITE_APP_FAKE_AUTH_LOGIN_ON_INIT=true

Frontend environment variables

Name Type Description
VITE_APP_API_URL string Specifies a backend API base URL without a trim slash, e.g. https://localhost:8080
VITE_APP_AUTH_CHECK_INTERVAL number Specifies the auth status check interval in milliseconds to ensure that users with expired cookies will not be able to use the application without refreshing the page in the browser. Not used if VITE_APP_FAKE_AUTH_ENABLED is true
VITE_APP_DEMO_MODE_ENABLED boolean Enables demo mode. In demo mode, some features related to file system or external integrations are disabled
VITE_APP_FAKE_AUTH_ENABLED boolean Setups fake authentication flow without using a backend server and OAuth Identity provider. Used for local development
VITE_APP_FAKE_AUTH_LOGIN_ON_INIT boolean Defines whether the user is authenticated by default when using a fake authentication flow. Used for local development
VITE_APP_MSW_ENABLED boolean Enables mockServiceWorker to intercept and mock all API requests. Used for testing or local development purposes
VITE_APP_GOOGLE_ANALYTICS_ENABLED boolean Enables Google Analytics
VITE_APP_GOOGLE_ANALYTICS_MEASUREMENT_ID string Measurement (data stream) ID for Google Analytics
VITE_APP_MOCK_API_RESPONSE_DELAY number Sets delay (in milliseconds) before all mock API responses. Not used if VITE_APP_MSW_ENABLED is false

How to generate database migrations

dotnet ef migrations add <migration_name> \
    -s src/backend/src/FoodDiary.API \
    -p src/backend/src/FoodDiary.Infrastructure \
    -o Migrations

Copyright notes

Favicon

This favicon was generated using the following graphics from Twitter Twemoji:

food-diary's People

Contributors

dependabot[bot] avatar pkirilin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.