百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
K

kcal

> 数据库
开源

个人食物营养日志

350 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

个人食物营养日志

kcal – the personal food nutrition journal

Track nutritional information about foods and recipes, set goals, and record a food journal to help along the way. Kcal is a personal system that focuses on direct control of inputs (as opposed to unwieldy user generated datasets) and a minimal, easy to use recipe presentation for preparing meals.

Screenshots

Functionality

Kcal's primary functionality includes three main content categories -- journal, recipes, and foods -- and two per-user configurations -- goals and meals. Users can customize meals (up to eight per day) for meal planning, set multiple goals for tracking calories and macros (fat, carbohydrates, protein), enter food data with calories and macros, create recipes based on foods and other recipes, and record foods and recipes in a journal tracked against goals.

Foods

Foods are shared between all users.

Foods are the basis for recipes and calorie and macro calculations throughout the app. They can be added directly to journal entries and included in recipes that roll-up nutritional data per serving.

Food servings can be recorded using U.S. measure units (teaspoon, tablespoon, cup) and use a weight basis of grams. These units and weights are commonly used in the United States and required by law for most packaged foods. Kcal tries to make data entry as easy as possible by organization field order and units to match nutritional label configurations.

Food data does not (currently) make use of any API or service for retrieving information about food. While this may change in the future, there are a couple of reason this feature has been left out of kcal:

  • There is a very large volume of data in most food databases such that organizing, categorizing, and searching for the right food can be daunting.

  • Food databases that allow and include input from large groups of users can be inaccurate and counter-productive for users with calorie and/or macro goals.

  • Kcal's self-hostable nature is in part for privacy-conscious users so limiting interactions with third-party services is desirable (though adding APIs as an optional enhancement is not a major concern here).

Foods are taggable and tags can be used to filter and search for foods quickly.

Recipes

Recipes are shared between all users. They (currently) cannot be shared externally, but a feature enhancement to support optional, per-recipe public link creation is planned.

Configurable recipe metadata includes servings, weight, volume, timing, image, description, ingredients, and steps.

The recipe view is meant to be as uncluttered as possible, to support browser "reader mode", and to still provide nutritional metadata at a glance.

Recipes are taggable and tags can be used to filter and search for recipes quickly.

Journal entries

Journal entries are private. Each user has and can only see their own entries.

Planning and tracking calories and macros is the primary focus of journal entries. The journal section aggregates this information by day and by meal.

Recipes and foods can be added to journal entries in various quantities and configurations (depending on the associated serving data). Manual entries can also be used to record data for foods and recipes not in the kcal's database.

Journal entries are not editable. The calorie and macro information for each entry is recorded with the entry. This allows for recoding and maintaining journal entry data even as foods and recipes are updated.

Goals

Goals are private. Each user can create and see only their own goals.

Goals reflect daily calories and macros and are therefore closely related to journal entries.

Goals can be configured as "default" for specific days of the week but can also be overridden for individual days in the journal section.

There is no limit to the number of goals a user can create.

Meals

Meals are private. Each user can rename, arrange, and enable or disabled their own meals.

Meals are used to aggregate data within a day in the journal section and can be used for both meal planning and goal tracking.

There is a pre-configured maximum of eight meals for each user.

Use cases

Kcal's primary focus is tracking nutrition (recipe management is the most important secondary focus), so it should be a useful tool for anyone looking to implement a specific diet. Below are some (very) broad diet types and information about how kcal can be helpful. Kcal intentionally does not provide any specific dieting guidance or recommend any particular diet or type of diet. Individual users are expected to research and make their own plans and goals -- kcal is here to help record and organize the data.

Hypocaloric diets

Hypocaloric diets use calorie restriction for weight loss or other dietary management. Kcal users can create low calorie (relative to personal regular calorie) intake goals and use the detailed nutritional data of food and recipes and to plan meals and record caloric intake using journal entries.

Hypercaloric diets

Hypercaloric diets are used for weight gain and can be especially useful for building muscle in weight training. Kcal users can create calorie goals that exceed expected calorie burn on a day-to-day basis. For the weight training example users can create a goal for training days and separate, lower goal for rest days. The goals can be automated based on the day of the week and journal entries can be used to ensure that a proper macro balance is maintained. More meals may also be helpful on a hypercaloric diet and kcal supports up to eight meals per day.

Plant based diets (vegetarian, vegan, etc.)

Diets that exclude animal-based products may require special attention to ensure a proper balance of nutrients (particularly when transitioning). Kcal's goals and food nutritional data can help to make sure that appropriate fat, carbohydrate, and protein needs are met.

Low-X diets

Any diet that focuses on lowering a particular nutrient can be trackable with kcal. In addition to the macronutrients (fat, carbohydrates, and protein) foods support cholesterol and sodium data as well. Support for other common nutrients like saturated fats, trans fats, fiber, sugar, etc. may also be available in future iterations.

Deployment

Docker is the recommended deployment method. See kcal-app/kcal-docker.

General requirements for any deployment are:

  • PHP 8.x with Composer 2.x and PHP extensions: bcmath, curl, gd, intl, mbstring, xml, zip.
  • Web server/proxy (Apache, nginx, etc.)
  • Database (MySQL/MariaDB, PostgreSQL, etc.)

Optional but useful additions are:

  • Search driver (Algolia, Elasticsearch, and database supported)
  • Redis
  • Media Storage (local or AWS S3 supported)

Docker

There is a Dockerfile and automated build process to create builds at kcalapp/kcal on Docker Hub. See the kcal-app/kcal-docker repository for a Docker Compose based template and instructions.

Manual

This deployment process has been tested with an Ubuntu 20.04 LTS instance with 2GB of memory which should be enough to host the app for a few regular users. The memory is primarily needed for Elasticsearch -- See the Search section for other options if lower memory support is needed.

  1. Add PHP 8.x repository.

    bash
    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/php
    
  2. Add Elasticsearch 7.x repository.

    bash
    wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
    echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee /etc/apt/sources.list.d/elastic-7.x.list
    
  3. Update available packages.

    bash
    sudo apt-get update
    
  4. Install dependencies.

    bash
    sudo apt-get install elasticsearch mysql-server-8.0 nginx-full php8.2 php8.2-bcmath php8.2-cli php8.2-curl php8.2-gd php8.2-intl php8.2-mbstring php8.2-mysql php8.2-redis php8.2-xml php8.2-zip redis php8.2-fpm
    
  5. Start Elasticsearch and configure to run at start up.

    bash
    sudo systemctl start elasticsearch
    sudo systemctl enable elasticsearch
    
  6. Install Composer.

    :rotating_light: This command runs code from a remote location as root. See Download Composer for alternative install options.

    bash
    curl -s https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin/ --filename=composer
    
  7. Clone the app repository.

    bash
    cd /var/www
    sudo mkdir kcal
    sudo chown $USER:`id -gn $USER` kcal
    cd kcal
    git clone https://github.com/kcal-app/kcal.git .
    
  8. Configure nginx to serve the app public files.

    bash
    sudo vim /etc/nginx/conf.d/kcal.conf
    
    sudo service nginx restart

    Example config:

    server {
        listen 80;
        server_name kcal.example.com;
        root /var/www/kcal/public;
        
        add_header X-Frame-Options "SAMEORIGIN";
        add_header X-Content-Type-Options "nosniff";
        
        index index.php;
        
        charset utf-8;
        
        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }
        
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
        
        error_page 404 /index.php;
        
        location ~ \.php$ {
           fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
           fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
           include fastcgi_params;
        }
        
        location ~ /\.(?!well-known).* {
           deny all;
        }
    }
    
  9. Create database user.

    bash
    sudo mysql -u root
    CREATE DATABASE `kcal`;
    CREATE USER 'kcal'@'localhost' IDENTIFIED BY RANDOM PASSWORD;
    GRANT ALL ON `kcal`.* TO 'kcal'@'localhost';
    FLUSH PRIVILEGES;

    :lock: Save the generated password output by the CREATE USER statement.

  10. Install dependencies and generate an app key to use in the next step.

    composer install --optimize-autoloader --no-dev
    php artisan --no-ansi key:generate --show
    
  11. Copy environment config file and adjust as desired.

    cp .env.example .env

    At a minimum:

    • Set APP_KEY to the value generated in the previous step.
    • Set APP_URL to match the host configured in nginx configuration.
    • Set the DATABASE_ values to the configured credentials.
  12. Run initial app installation/bootstrap commands.

    php artisan migrate
    php artisan elastic:migrate
    php artisan config:cache
    php artisan route:cache
    php artisan view:cache
    php artisan user:add --admin
    
  13. Allow web server to access required directories.

    bash
    sudo chown -R $USER:www-data {storage,public}
    sudo chmod g+s {storage,public}
    
  14. Visit the APP_URL and log in!

Configuration

Media Storage

Recipes and users can have associated media (images) that by default are stored on a local disk under the path {app}/public/media. If a local disk solution is not feasible, an AWS S3 bucket can be used instead.

AWS S3

Use the general guidance below to create an AWS S3 bucket and IAM user for media storage in AWS S3.

  1. Create a bucket that allows objects to be configured with public access.

  2. Create an IAM user with access to the bucket.

    Use this example policy to grant necessary permissions to a specific bucket:

    {
        "Version": "2012-10-17",
        "Stat

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPcalorie-trackerdiet-managmentfood-datafood-journal

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类数据库
定价开源

> 相关工具

P
PostgreSQL
功能强大的开源关系型数据库
R
Redis
内存数据结构存储,常用作缓存与队列
M
MySQL
广泛使用的开源关系型数据库