Giter VIP home page Giter VIP logo

breadu.info's Introduction

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 [email protected]: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

breadu.info's People

Watchers

Yarunina Anastasiya 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.