Nutrition tracking software that uses machine learning to help you reach your body composition goals.

Overview

LogSmarter - Machine Learning Nutrition Tracker

header

Description

LogSmarter LogSmarter™ is not just another calorie counter. It is an AI nutrition coach that uses machine learning to help people reach and sustain their health goals. You tell us your demographic information and whether you want to gain muscle or lose fat. From there our proprietary machine learning algorithm will generate a goal calorie intake that fits your individual needs. As you progress towards your goal of gaining muscle or losing fat, your metabolism will change. Based on daily records of your calorie intake and body weight, our algorithm will update your goal calorie intake appropriately to make sure you are optimizing your nutrition. As our algorithm learns more about you, it will provide feedback to make sure you are following the latest evidence based nutrition recommendations

bulk

Open Source Changes

The open source project has some minor changes to the paid application. The biggest is that the initial prediction from the machine learning model has been removed, the rest of the algorithm remains as it was, but we have not yet released the code or documentation around that model. The only other large difference is that we've disabled payment processing and given everyone the highest level of permissions within the system as the default when they create their account. That way, anyone who sets up the project doesn't need to worry about subscription state.

phones

Architecture

architecture

Technical Warning

The code in this project is far from perfect. Like I said above, I started writing the code with ZERO web dev experience and learned as I went. There was no real planning for the first year or so. The first lines of Angular I ever wrote are still in this codebase. The plan was just to work as hard as I can and I'll figure it out later. If I could do it again, maybe I would have planned things cleaner from a technical perspective, but depending on what the goal was, maybe I would have done it the same all over again. We were a cash flow positive business with more users than most college start ups will ever have. If you are looking for what cleaner code might have looked like within this project, take a look at a project I worked on that rips out all of the nutrition stuff from LogSmarter and cleans up the code to create an app skeleton with a working authentication system https://github.com/RyanLefebvre/FAngS

Technologies Used

Technology Version
Angular ^8.2
Node 12.22.5
Firebase Functions ^3.6.2

Getting Started

The following guide walks you through setup for the web application. Getting the project set up is simple and will only take a few minutes. The mobile setup is more complex and I have not included it here, but if I get enough requests then I will. Reach out to me if you would be interested in that. Last thing before we start is that this guide assumes you have an understanding of git. Check out the git documentation if you don't.

  1. The first thing to do is clone the project. I would recommend forking the project first, then cloning if you plan to use it as a base for your next project.
    git clone https://github.com/RyanLefebvre/LogSmarter
  1. Next you'll need to download and install node. Try to match or exceed the version the project is currently using. To verify that you have successfully installed node, you can check the version from the command line.
    node --version
  1. The next step is to create a Firebase Project. Go to the Firebase console and click on the Add project button.

  2. Once your project is created, you will be redirected to that project's management console. You have some set up that needs to be taken care of. First, go to the authentication tab underneath build. You can see it on the sidenav on the left side of the window. Then click on the Set up sign-in method button. At a minimum, select the option called Email/Password and enable it.

  3. Next is your database, go to the Firestore Database tab underneath build. You can see it on the sidenav on the left side of the window. Click on the Create Database button.

  4. Now that the database is created, we need to add the Users table. Click on start collection and create collections with the following names Users, AutoGold, EmailFeedback, IAB, IAP, NutritionLogs,PromoCodes, Social. It will force you to create a document within the collection but its okay to just use the auto-id button and delete the document after if you don't want the one junk document in your database. Depending on which parts of the codebase you choose to explore beyond this getting started guide, you may never touch some of these tables.

db

To set up the Social table, you will need to add a document called social-dashboard and add the following properties

    owners:[
                {
                    "id": "0000",
                    "displayName": "LogSmarter",
                    "themeColor": ""
                }
           ]

and

    owners:[
            {
                "type": "YOUTUBE",
                "title": "What is TDEE?",
                "data": "6Dniijit0d4",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "What is LogSmarter™?",
                "data": "DsgYFm-DABA",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "Importance of Maintenance",
                "data": "RlLP_EfbWZ8",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "How To Use LogSmarter™",
                "data": "ndhiL91lkUg",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "What Are Macros?",
                "data": "QN560FYJ6ro",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "Activity Level",
                "data": "Ll7o4BNC7zI",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "Tracking Calories",
                "data": "1XNRFVqF5rA",
                "ownerId": "0000"
            },
            {
                "type": "YOUTUBE",
                "title": "Tracking Weight",
                "data": "GpJ1uS-v-6U",
                "ownerId": "0000"
            }
        ]
  1. Go back to the Project Overview by clicking on the house icon above the Build section on the sidenav. You have to add an app to the project to generate client secrets. Choose the web option. During this process you'll be given a Firebase Config object in JSON format. Save this as we will need it again later. It should look something like below.
    const firebaseConfig = {
            apiKey: "XXXXXXXXXXXXXXXXXXX",
            authDomain: "XXXXXXXXXXXXXXXXXXX",
            projectId: "XXXXXXXXXXXXXXXXXXX",
            storageBucket: "XXXXXXXXXXXXXXXXXXX",
            messagingSenderId: "XXXXXXXXXXXXXXXXXXX",
            appId: "XXXXXXXXXXXXXXXXXXX",
    };
  1. Go back to the project you cloned in Step 1. Navigate to the app/web/src directory and create a subdirectroy called environments. In the environments subdirectory create a file called environment.ts. In this file create an object named environment that is exported. The object should have a key called production which is either true or false and one called firebase. The value of the firebase key in the environment object should be the contents of the firebase config object from step 7.
    cd LogSmarter/app/web/src
    mkdir environments
    cd environments
    touch environment.ts

So inside environment.ts you would have

    export const environment = {
    production: false,
    firebase: {
        apiKey: 'XXXXXXXXXXXXXXXXXXX',
        authDomain: 'XXXXXXXXXXXXXXXXXXX',
        projectId: 'XXXXXXXXXXXXXXXXXXX',
        storageBucket: 'XXXXXXXXXXXXXXXXXXX',
        messagingSenderId: 'XXXXXXXXXXXXXXXXXXX',
        appId: 'XXXXXXXXXXXXXXXXXXX',
      },
    };
  1. Now install the projects frontend dependencies using NPM
    npm ci
  1. Verify that the frontend unit tests work and show 100% testing coverage using the command below. The output from karma will show you the coverage in your terminal. You should also see a coverage directory that was generated inside the app directory. It contains an istanbul report with more information. If you open the index.html file inside the coverage directory in a browser you can see exactly which files are covered.
    npm run testWithCoverage
  1. Verify that the frontend documentation works and show 100% coverage using the command below. You should see a documentation directory that was generated inside the app directory. If you open the index.html file inside the documentation directory in a browser you can access the projects documentation.
    npm run doc
  1. Now that the frontend is good to go, you need to set up the firebase cloud functions for the project. This is most easily done using the firebase-cli. If you haven't already, install the cli which is part of the firebase-tools package. Using the CLI, you will have to login, choose to use the project, then initialize cloud functions. When prompted, be sure to choose TypeScript as the functions language and be absolutely sure not to overwrite any existing files when it asks you. That will definitely break things if you start overwriting those files. If you aren't sure what your Project ID is, you can run the command firebase projects:list to see all your projects and find the one with the correct ID.
    cd LogSmarter/app/web/functions
    npm install -g firebase-tools
    firebase login
    firebase projects:list
    firebase use YOUR_PROJECT_ID
    firebase init functions
  1. Now install the projects cloud function dependencies using NPM
    cd LogSmarter/cloud-functions/functions
    npm ci
  1. For the cloud functions to work, they need to be deployed. Run the following command. It might take a minute, but your cloud functions will be ready to go.
    firebase deploy --only functions
  1. Verify that the backend unit tests work and show 100% testing coverage using the command below. We had to use a different testing framework than the frontend because cloud functions don't like karma/jasmine :(
    npm run test
  1. At this point the project should be all set up for local development. Navigate to the frontend portion of the project (i.e. the app directory) and use the npm start command to run the project locally. Once the build finishes you can access the project on localhost:4200

Great Success

  1. DISCLAIMER - This isn't a step thats necessary, but it is worth mentioning. For some reason, cloud functions won't always work the first time they are deployed and will make it look like there are cors errors. If you run into that issue, then you will need to go into the GCP project for your firebase project and assign the allUsers service account a role of Cloud Functions Invoker. A better explanation can be found here.

Origin Story

LogSmarter used to be a pay to use web and mobile application with a few thousand users. The reason I've decided to open source it is because the team and I just don't have the bandwidth to maintain it any more. We've all moved on to bigger and better opportunities. My hope is that by open sourcing it, technical members of the community could spin up their own instances following our getting started guide and create their own personal 'servers' kind of like minecraft servers. That way the project lives on and spreads (like a disease). Although the payment processing system is disabled with a simple code change, all of that is still in the codebase and we have no problem with people enabling the payment processing to fund their servers or fund new features they wish to add. Basically do whatever you want and have fun, we don't care.

It's kind of nuts how far the project even went. I started working on it in 2019 when I had just finished my Sophomore year of college and I was living alone in Connecticut in a one bedroom apartment for my first internship.

apartment

At the time I had ZERO web dev experience and believe it or not, the first lines of code I ever wrote in Angular are actually still in this project. All summer I crammed in development when I could while working a full time job. Eventually I had cobbled something usable together and I made a few reddit posts about it. To my surprise, hundreds of people signed up for my project that was just supposed to be a resume booster and everything exploded from there. https://www.reddit.com/r/nSuns/comments/cpytvh/tdee_estimation_web_app_logsmarter/

At that point I was really really motivated. When I got back to college, I slowly built a team of people I trusted and I traded balance in my lifestyle for an investment in my own human capital and the success of my business. I consistently woke up early, stayed up late and stayed in on the weekends so I could work on LogSmarter while maintaining my performance in my classes. Everything I did revolved around what I call the three Fs, Family, Fitness and Finance. If something I was doing didn’t seem like it was going to lead to a positive outcome for my family and friends, my physical fitness or the financial situation of myself and the people I love, I cut it out of my life. I vividly remember some of the worst moments, like staying up for 3 days in a row during finals my junior year so I could juggle working on LogSmarter and studying.

dead

All in all, everything worked out pretty well, the team and I accomplished a lot and I would not be working on the things I am at the time of writing this if it weren't for what I learned building LogSmarter. I also won some competitions and awards which I am pretty proud of. I learned a ton, not just about software development, but finance, marketing, management, communication etc. We actually got a few offers to buy our codebase, but nothing ever panned out, so if you're interested in buying it, we may be interested in selling it. Contact [email protected] for more information.

prize

You might also like...

e-ONG, an authorial project, whose objective is to help ONGs to find people who need help or would like to help them

This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: npm start Runs the app in the developmen

Nov 11, 2022

A planetary body simulator with a HTML5/CSS3/JS frontend and simulated using Rust WebAssembly.

A planetary body simulator with a HTML5/CSS3/JS frontend and simulated using Rust WebAssembly.

Solar Sim 🪐 A planetary body simulator with a HTML5/CSS3/JS frontend and simulated using Rust WebAssembly. Try the latest version here! Built with 🦀

Jun 15, 2022

JavaScript package for predictive data analysis and machine learning

scikit.js JavaScript package for predictive data analysis and machine learning. Generic math operations are powered by Tensorflowjs core layer. We are

Jan 6, 2023

Repository for machine learning research.

Machine-Learning A simple project created with django containing links and a chatbot to demonstrate how Choice Coin can be used for eLearning #how to

Oct 21, 2022

Inferrd makes Machine Learning deployment easy and scalable.

Inferrd makes Machine Learning deployment easy and scalable.

Introduction ML Deployment made simple, scalable and collaborative The new open-source standard to deploy, monitor and secure Machine Learning service

Dec 16, 2022

DialogFlow Machine Learning Chatbot

 DialogFlow Machine Learning Chatbot

DialogFlow Machine Learning Chatbot Project Overview This repository contains a backend service for an intelligent chatbot that onboards clients, answ

Jul 21, 2022

Tutorials for MATH 4432 Statistical Machine Learning, HKUST, Fall 2022

Tutorials for MATH 4432 Statistical Machine Learning Course information MATH 4432 Statistical Machine Learning Instructor: Prof. YANG Can Teaching ass

Dec 1, 2022

About Introduction to Machine Learning for the Arts, IMA, Tisch School of the Arts, New York University, Fall 2022

Introduction to Machine Learning for the Arts About Introduction to Machine Learning for the Arts, IMA, Tisch School of the Arts, New York University,

Nov 4, 2022

An AWS Cloud Native application using CDK that defines a Serverless Event Driven application for interacting with Twitter and utilising Machine Learning / AI as a Service.

An AWS Cloud Native application using CDK that defines a Serverless Event Driven application for interacting with Twitter and utilising Machine Learning / AI as a Service.

AWS Serverless Event Driven Twitter Bot An AWS Cloud Native application using CDK (Written in TypeScript) that defines a Serverless Event Driven appli

Dec 18, 2022
Owner
Ryan Lefebvre
Better Every Day
Ryan Lefebvre
How often do you get asked about the gadgets or software that you use? If the answer is quite often, you should be trying show off out. Curate the list of gadgets and software and share it with your fans and followers.

Show Off - Showcase your setup! How often do you get asked about the gadgets or software that you use? If the answer is quite often, you should be try

Adithya Sreyaj 15 Nov 24, 2022
DevArms - a collection of developer utils that gives you extra arms to reach more in your tasks

DevArms is a collection of developer utils that gives you extra arms to reach more in your tasks. It runs completely offline, and cross-platform across Windows, Mac and Linux. Written in Rust, React. Powered by Tauri.

Qiushi Pan 82 Dec 18, 2022
🏆Open source, free project management/issue tracking software to manage your work and projects

WorkClever ?? Open source, free project management/issue tracking software to manage your work and projects Features General Free to use, open source

WorkClever 11 Dec 27, 2022
Composition API & Yup Powered Form Validation

vue-yup-form Composition API & Yup Powered Form Validation. This tiny library allows Vue and Yup to be a best friend. Requirements The following versi

Masaki Koyanagi 12 Dec 26, 2022
This project is in developer-preview status and will reach the beta in 2023 Q1

rescoped.io This project is in developer-preview status and will reach the beta in 2023 Q1. Currently, the datagrid is under massive refactoring, and

avodaq AG 7 Dec 30, 2022
Storybook Addon Root Attributes to switch html, body or some element attributes (multiple) at runtime for you story

Storybook Addon Root Attributes What is this This project was inspired by le0pard/storybook-addon-root-attribute The existing library received only on

정현수 5 Sep 6, 2022
LayerX-AI is a comprehensive platform to annotate and manage your machine learning data.

The AI Data Platform Annotate, Manage and Deploy Training Data The end-to-end AI data management platform that helps ML teams annotate, manage and dep

LayerX.ai 15 Dec 18, 2022
Solana blockchain candy machine app boilerplate on top of Metaplex Candy Machine. NextJS, Tailwind, Anchor, SolanaLabs.React, dev/mainnet automation scripts.

NFT Candy Factory NOTE: This repo will prob only work on unix-based environments. The NFT Candy Factory project is designed to let users fork, customi

Kevin Faveri 261 Dec 30, 2022
Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

Complete Open Source Front End Candy Machine V2 Minter dAPP Built For The Frog Nation NFT Solana Project. Built With React, Candy Machine V2, Typescript

null 17 Sep 24, 2022
three.js examples. if you are first in learning three.js , this will give you much help.

three-projected-material Three.js Material which lets you do Texture Projection on a 3d Model. Installation After having installed three.js, install i

null 22 Nov 2, 2022