denisshevchenko / breadu.info

Bread Unit calculator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DEPRECATED!

THIS PROJECT IS CLOSED, PLEASE SEE A NEW VERSION OF CALCULATOR.

CircleCI    Code Climate

Bread Unit

What is it?

This is a bread unit calculator for diabetics. My son has type 1 diabetes (T1D), so I created this small service for our family as well as for other people who live with this condition.

1 bread unit (BU) corresponds to a quantity of food that contains 10-12 grams of digestible carbohydrates. Calculator converts quantity of particular food from grams to BU and vice versa. You can choose food from the list or just specify carbohydrate value (carb per 100g of food).

Also you can add few products and specify quantity for each of them (i.e. describe your dinner). In this case calculator will get you a total number of BU, it's useful for insulin therapy.

If you have any questions, critique or suggestions for this project - please email me.

Please note that I'm not endocrinologist and this service cannot be treated as an official medical nutrition guide for diabetics.

Common Food

Calculator works with a common list of food obtained from the food/common/*.csv files. Carbohydrate values are taken from the public medical resources and from products' labels.

Real-Life Haskell

Second purpose of this project is a practical programming learning. I use the Haskell programming language, all modules and configuration files contain a lot of comments to help students understand this small, but real-life Haskell web project. I suppose that you already familiar with Haskell (e.g. you have read LYAH book or my book). But don't be afraid!: this project is designed for novices, so basic knowledge of the Haskell and web development is quite enough.

You'll learn such things as:

Please feel free to open an issue if you found a bug or want to improve this project.

Project structure

Configuration

  • package.yaml - main configuration file. I use alternative configuration for Haskell projects, please see hpack.
  • stack.yaml - configuration file for Stack.
  • circle.yml - configuration file for CircleCI service.
  • .codeclimate.yml - configuration file for Code Climate service.

Source code overview

  • src/app/ - source code for a program.

    • CLI.hs - work with app's command line arguments.
    • Main.hs - app's main-function is defined here.
  • src/lib/ - source code for a library using by a program.

    • BreadU.hs - exposed module of the library.
      • BreadU/API.hs - web API, defines endpoints.
      • BreadU/Handlers.hs - handlers for endpoints.
      • BreadU/Server.hs - server that combines API with handlers.
      • BreadU/Types.hs - common types.
      • BreadU/Pages/ - modules for generate pages, in wide sence of word (HTML-markup, CSS, JS and DOM-parts).
      • BreadU/Tools/ - tools for parsing food, validating user's food data, calculating and suggestions.
  • src/update - source code for a program to update 'breadu-exe' server on production.

  • test/ - source code for test suite.

  • Setup.hs - autogenerated module, you haven't touch it.

Build artifacts

  • .stack-work/ - build artifacts: packages, autogenerated modules, executable file, Haddock-documentation, etc.

Misc

  • static/ - static web files (actually just images).
  • food/common/ - .csv-files with common food (default sets of food every user will see), localized versions.

Local build

You can build service locally. Assumed that you already have Haskell Stack. Do:

$ git clone git@github.com:denisshevchenko/breadu.info.git
$ cd breadu.info
$ stack setup
$ stack build

After that run it:

$ stack exec -- breadu-exe -p 3000

Then go to localhost:3000.

That's it. To see short help info do:

$ stack exec -- breadu-exe --help

About

Bread Unit calculator

License:MIT License


Languages

Language:Haskell 100.0%