The Lifestyle Tracker
HTML Ruby CSS JavaScript Vue
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
app
asset-sources
bin
config
db
lib
log
public
test
vendor/assets
webpack
.byebug_history
.codeclimate.yml
.csslintrc
.eslintignore
.eslintrc
.gemrc
.gitignore
.rubocop.yml
.travis.yml
CHECKS
Gemfile
Gemfile.lock
LICENSE
Procfile
Procfile.dev
README.md
Rakefile
app.json
config.ru
contributors.txt
crontab
hologram_config.yml
outfile
package.json

README.md

w8mngr | The Lifestyle Tracker

Travis CI Build Code Climate Test Coverage

The source for my side project, a lifestyle and fitness tracker. I want users to be able to track their calories, food intake, fitness, weight, and other variables that affect their health. The current version, w8mngr.com was originally coded in 2009. Back then, I was interested in super high-performance PHP. It is based on super simple architecture, raw queries, and PHP templates. As expected, it was quick to code but tough to maintain. So with this version I'm testing out Ruby on Rails.

It's my first Rails project, but I'm learning very quickly due to how mature Rails is as a framework.

Architecture

I'm using PostgreSQL, Ruby on Rails, Javascript (vanilla), Vue.js, and nginx. The entire stack is new to me, so I'm learning a ton. To further improve my devops in hopes of becoming a well-rounded full stack developer, I'm using Amazon Web Services.

The frontend is based on CSS and Javascript. Although the day of hardcore progressive enhancement seems to be waning (or at least isn't as popular as full JS apps), I'm sticking to my guns. The entire app works without Javascript -- but it really helps to have CSS enabled -- and I hope to turn certain pages into full-featured applications on their own.

For example, the food log will incorporate its own recipe and food search, navigating across days, and so on. But I want to do this in a lightweight manner with a small footprint, rather than incorporate the behemoth JS frameworks like Angular.

I settled on Vue.js because it's beautiful, and is easy to use with Rails. More on that in upcoming versions. React is great, so I will eventually use it on a project or two, but Vue.js struck me as the perfect tool for this job.

Demo

The site is now live! Check it out at w8mngr.com.

Contributing

I'm not accepting contributions without very good reasoning at the moment. I'm using this as a learning project, so open an issue that hints at the problem, point me toward a solution or two, and I will address it.

Deploy and Development Aliases and Environment Variables

For testing and deployment, you need the following environment variables set:

  • W8MNGR_API_KEY_POSTMARK - API key for Postmark, our email provider
  • W8MNGR_API_KEY_USDA - Our USDA API key, for nutritional info
  • DATABASE_URL - The URL of your database connection. E.g., postgres://username:password@127.0.0.1. (Only needed for production. Development and test use local databases.)

Development

alias prep_dev="sudo service redis-server start && sudo service postgresql start"
alias start_dev="prep_dev && foreman start -f Procfile.dev"

To start developing, add these two lines to your .bash_aliases file and start the appropriate services by running start_dev. It will start Redis, PostgreSQL, and run our development Procfile using Foreman.

To compile your styleguide, use the following bash alias:

alias _hologram="echo 'Clearing old stylesheets...' && rm -f ~/workspace/public/*.css* && echo 'Compiling assets...' && rake assets:precompile && echo 'Compiling Hologram styleguide...' && hologram"

This command, _hologram will clear your assets of CSS files, recompile them, and recompile the styleguide using Hologram.

Deployment

alias clear_assets="echo 'Clearing old assets...' && rm -f ~/workspace/public/webpack/* && rm -f -r ~/workspace/public/assets/*"
alias precompile="echo 'Running deployment script...' && clear_assets && echo 'Precompiling rake assets...' && RAILS_ENV=production rake assets:precompile && echo 'Compiling webpack assets...' && rake webpack:compile && echo 'Compiling Hologram styleguide...' && hologram && echo 'Adding compiled assets to the repo...' && git add . && git commit -a -m 'Precompile assets and styleguide for deploy'"
alias deploy="precompile && echo 'Pushing to Dokku...' && git push && git push dokku master"

These aliases clear the old assets out of our public folder, runs our Rake and webpack tasks to precompile new assets (including our styleguide), adds them via git commit, and pushes it all up to our Github account and Dokku.

Note: you must be on your master branch for this to work properly with Dokku. You may also need to change the path of your public folder so this script can properly clear your assets.

To deploy, pull your changes to master and run the deploy alias in your development terminal. It clears local assets, recompiles them, pushes them to master, and then pushes them to your Dokku server.