Giter VIP home page Giter VIP logo

rustybeer's Introduction

All Contributors

MIT License Contributors Issues PRs

RustyBeer is a CLI tool / web server written in Rust, to calculate values used in the process of brewing beer.

Live server running at https://rustybeer.herokuapp.com/

Installation

If you don't already have the toolset installed, you will first need to install Rust. From the root of the repository, run the following command:

cargo build

Running CLI

You can now run the CLI tool with:

cargo run --bin rustybeer <subcommand>

Running HTTP server

To start the server:

cargo run --bin rustybeer-server

You can access the OpenAPI UI from http://localhost:3000/docs. To change the port number, you can define environment variable PORT.

Testing

Tests can be ran by calling:

cargo test

If you would like to run only one test, you can do this by specifying the test name:

cargo test -- --nocapture <test name>

Files and Folders

  • rustybeer - The folder containing everything for the business logic
    • src - The folder containing the business logic source code
      • calculators - The folder containing calculators to be used in lib or CLI tool
    • Cargo.toml - The file containing build and dependency infomation
  • rustybeer-cli - The folder containing everything for the CLI
    • src - The folder containing the CLI source code
      • commands - The folder containing subcommands for CLI
      • main.rs - The file containing the main function
    • Cargo.toml- The file containing build and dependency infomation
  • rustybeer-server - The folder containing the HTTP server implementation
    • src - The folder containing server source code
    • Cargo.toml - The file containing server build and dependency information
  • Cargo.toml - The file containing build and dependency infomation
  • CONTRIBUTING.md - Contribution guidelines for this repository
  • LICENSE - The file containing the terms that this code package is released under
  • README.md - The file you are currently reading

Acronyms

Beer brewing has a lot of acronyms that have a meaning. This table is to help out with figuring out what everything means:

Acronum Description
ABV Alcohol By Volume
ABW Alcohol By Weight
OG Original Gravity
FG Final Gravity
SG Specific Gravity
IBU International Bittering Units

CLI Functionality

Below is a table of the features currently implemented.

Implemented Function Description Usage
ABV Calculates ABV from OG and FG or FG from OG and ABV abv --og <Original gravity> (--fg <Final gravity>) (--abv <Alcohol by volume>)
ABV <-> ABW Calculates alcohol by weight (ABW) from alcohol by volume (ABV) abv_abw --percent <alcohol percentage> (--total_volume <total beer volume>) (--total_density <density of beer in g/cm³) (--reverse)
Beer style Finds beer styles matching given parameters beer_style (--og <Original gravity>) (--fg <Final gravity>) (--abv <Alcohol by volume>) (--ibu <International bittering units> (--color <SRM color>)
Boil-off Gravity Calculates the volume needed to be boiled down to for a desired SG `boil_off --current_gravity <current_gravity> --wort_volume <wort_volume> <--target_volume <target_volume>
Calories Calculates calories by volume from OG and FG or from ABV calories (--og <Original gravity>) (--fg <Final gravity>) (--abv <Alcohol by volume>) (--volume <Beer volume>)
Dilution Calculates the SG after dilution diluting --sg <Current specific gravity> --cv <Current volume> --tv <Target volume>
FG Calculates FG from OG and yeast attenuation fg --og <Original gravity> --att <Yeast attenuation>
Num Of Bottles Calculates the number of bottles required for a given volume num_of_bottles --volume <volume>
Priming Beer Priming Calculator priming --temp <Beer temperature> --amount <Beer volume> --co2_volumes <co2_volumes>
SG Correction Corrects SG reading for differences between measurement and calibration temperatures sg_correction --sg <Specific gravity reading> --ct <Calibration temperature> --mt <Measurement temperature>
Yeast Viability Estimates yeast viability based off production date yeast-viability --pd <Production date> --cc <Cell count> --f <Date format>

This list will expand as ideas and suggestions come in.

Other Tasks to Do

See Issues

Contributors ✨

Thanks goes to these wonderful people (emoji key):


drodil

💻

mlatief

💻

Joseph Russell

💻

flauntingspade4

💻

Ilakkiyan Jeyakumar

💻

Tom Milligan

💻

Roger Y

💻

Sampsa Sarjanoja

💻

Philip Golovin

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Contributing

See CONTRIBUTING.md

rustybeer's People

Contributors

1jz avatar allcontributors[bot] avatar dependabot[bot] avatar drodil avatar flauntingspade4 avatar i-jey avatar mlatief avatar programmerjoe93 avatar rogercyyu avatar sampas avatar tommilligan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

rustybeer's Issues

Tests appear to be wrong

The tests contained in rustybeer/tests/calculator.rs seem to be wrong, especially those in the boil_off test-the second and third tests have the same right hand side, but different left hand sides-is this intended, or is there an error included somewhere? (#81 will change this anyway, but that may have the wrong effect)

Refactor calorie counter

Refactor calorie counter to take the volume as input (relates also to #109 ). Remove the abv_calories.rs from the util library as the calorie count can be calculated for abv easily by multiplying the beers ABV % by a factor of ~2.5 and then multiplying that number by how many fluid ounces the bottle holds. To make this easier, the volume should come as measurements::Volume struct.

Fix clippy warnings

There is some warnings generated with cargo clippy --all-targets. Minor fixes but would be beneficial to be fixed before more code evolves.

Refactor beer styles, hops and yeasts

Hide the loading of data behind a function for example

fn get_beer_styles(criteria: Option<Criteria>) -> Vec<BeerStyle>

Move the filtering by criteria to these functions from the rustybeer-server and rustybeer-cli which both do the same thing for the list based on the criteria.

Add rustfmt check to workflow

To be able to verify follow of coding standards, add rustfmt check to the github action in .github/workflows/rust.yml

Additionally the code needs to be reformatted to get the PR through the check.

Add missing documentation

Add missing documentation especially for the calculators. What are the expected inputs and in which unit is crucial information for the user of the library.

Improve Github Pages

Current version of Github Pages is just rendering the README.md. To bring more life to the project, configure the Github pages properly to be able to use themes and also add extra content to it. See https://docs.github.com/en/pages for instructions

Plato to SG conversion

There should be possibility to input gravity with Plato or SG. This is why we need a way to convert between these two. Add new functionality to #25 (utils/conversions.rs) to figure out if the input is Plato or SG and allow converting between these two. See http://betatestbrewing.com/pages/plato_to_sg.html for formulas for this.

Additionally fix existing calculators to use the new conversion tool for input parameters (abv, sg_correction at least but check out commands that want to use gravity)

Tip: If the input ends with "P" it is definetly plato unit. Also if the decimal number is way over 1.5 it's most likely plato ;)

Add IBU calculator

Add possibility to calculate estimated IBU based on added hops. Global parameters needed are:

  • Pre Boil Size
  • Post Boil Size
  • Target OG
  • Hop Utilization Percentage

The user should be able to add multiple hops from the CLI interface (or by using the library). Each hop should have the following characterics:

  • Grams / Ounces (related to #10 )
  • Alpha Acids
  • Boil Time
  • Type of Hop (Whole/Plug)

The calculator should return estimated boil gravity and IBU.

Add keg carbonation calculator

Add new calculator to calculate what is the correct setting for the keg regulator to achieve given amount of CO2.
Input parameters should be

  • Amount of CO2 wanted
  • Temperature of the keg

And output should be the regulator pressure in psi.

Local database support

As it is very painful to keep the beer, hops and yeast data in Rust structs, find out if there is optional solution to store this data inside the executable/lib. For example file based database that could travel inside the package. See #23 #39 #41 #42 for use cases of this.

Yeast viability calculator

As yeasts go bad after a period of time, the viability should be calculated to pitch in the correct amount of yeast. See https://www.morebeer.com/content/yeast_viability_calculator as an example of calculating the yeast viability. Input should be initial cell count and production date and the output should contain viability in percent as well as how many cells are still viable.

Probably you will need a utility to parse date from the command line parameter of different date formats (dd.mm.YYYY or mm/dd/YYYY etc.)

Add also command to run this calculator from CLI

Add parameters and support for commands to select units

We need global parameters to select whether to use imperial or metric units for:

  • Temperature (C/F/K)
  • Weight (g, Kg, Oz...)
  • Volume (l, gallon...)

For all of these we should provide different parameter in the main program parameters. Additionally a conversion tool that can be used should be in place for the sub-commands to use.

Remove app_subcommand.rs

The trait defined in app_subcommand.rs (AppSubCommand) is never implemented, and redefined in main.rs
The only thing in app_subcommand.rs is the trait itself-if the trait is ever used in any way, it could be put in lib.rs, and app_subcommand.rs itself removed

Add yeast support

To be able to do more calculations add information about most known yeasts to the application. There should be at least the following information available:

  • Name (String)
  • Producer (String)
  • ID (String)
  • Attenuation (min u8/max u8, percentage)
  • Flocculation (low/medium-low/medium/high-medium/high/very high) (enum)
  • Optimum temperature (min/max), please use measurements::Temperature struct here (see #25 )
  • Alcohol tolerance (u8, percentage)

See https://www.brewersfriend.com/yeast/ for most known yeasts and add constants for those.

Additionally add command to find yeasts based on the yeast properties.

See #23 as an example.

Add bottling calculator

This should be an easy one. Single parameter of the volume to bottle and then show up how many bottles is needed to bottle the whole beer. The following bottles should be calculated:

  • 330ml bottle (330ml)
  • Twelve ounce bottle (355ml)
  • Groish bottle (450ml)
  • Half liter bottle (500ml)
  • Pint (568ml)
  • Graft bottle (650ml)
  • Wine bottle (750ml)
  • Grenade jug (946ml)
  • Growler jug (1893ml)
  • Gallon jug (3785ml)
  • 5 Liter mini keg (5000ml)

The number of bottles should be rounded up.

Why use futures?

This may be a stupid question, but why use the futures library? This doesn't seem like the kind of task that requires async programming, unless there's some requirement in the CLI app which I'm not aware of.
Would someone mind explaining to me why it's included?

Add boil-off calculator

We need a boil-off calculator to calculate how much you need to boil down your wort volume to hit a certain gravity. Parameters are volume of the wort, current gravity and desired gravity. The output shall be the the new wort volume as well as the difference. Calculation is:

new volume = ((current gravity-1) / (desired gravity-1)) * current volume

Create gravity unit

Currently only specific gravity (1.xxx) is allowed to be used as input for gravity calculations. Create a new struct for this that can handle the conversions and to and from different units (specific gravity, brix, plato). See example structs from the measurements crate here https://github.com/rust-embedded-community/rust-measurements/tree/master/src

See also these as reference:

Once you have struct in place, replace functions wanting gravity as value to use the new struct (also from CLI and server).

For extra points, include the new functionality also to that project for some good open source spirit!

Add Alcohol By Weight calculator

Add new calculator to calculate Alcohol By Weight <-> Alcohol By Volume. The conversion should be done as follows:

ABV (percentage) = ABW (grams) * 1.25
ABW (grams) = ABV (percentage) * 0.80

Additionally the calculator could optionally get volume of the beer (see #25 ) and show how many grams of alcohol it contains (ABW is grams of alcohol in 100 centilitres of beer).

Optionally original and final gravities could be used instead ABV (and use AbvCalculator with these)

Add color calculator

To be able to calculate SRM we need the fermentable information with color as well as batch size and amount of fermentable. See #44 for support of basic fermentables so the user does not need to input the color information for every fermentable. The formula for this can be found in http://beersmith.com/blog/2008/04/29/beer-color-understanding-srm-lovibond-and-ebc/

Additionally the calculator should give out SRM (Standard Reference Method), Degrees Lovibond and EBC (European Beer Color) and hex value for the color. See https://www.brewersfriend.com/color-calculator/ as an example of the conversion. The conversion should be placed in another calculator so that it can be used as its own command.

Create interactive Text UI

To be able to run this tool more than just from the subcommands, it would be beneficial to create a TUI for rustybeer. Maybe it could be done by utilizing the https://github.com/gyscos/cursive

The interactive tool would be very helpful in the brewery as you wouldn't need to remember all the subcommands and parameters.

Add support to use BeerXML files

To be able to calculate for example IBU or SRM we need the incredients from the recipe. Add support for parsing BeerXML to an internal representation of the recipe that can be used by the commands.

See specification here: http://www.beerxml.com/

Add fermentables support

To be able to do more calculations add information about most known fermentables to the application. There should be at least the following information available:

  • Name
  • Country (if applicable)
  • Category (grain/fruit/adjunct/sugar/liquid extract/dry extract)
  • Type (base malt/roasted malt/specialty malt/crystal malt/gluten-free malt/raw/fruit/juice/extract)
  • Color (°L)
  • PPG
  • Potential
  • Yield

Add the most used fermentables as constants (see #23 as an example) and command to find fermentables based on criteria. Also see #43 if it can bring any help to this.

For potential and yield you can find some information here https://www.homebrewtalk.com/wiki/index.php/Malts_Chart

Add dilution calculator

We need a dilution calculator to calculate how much you need to dilute your wort volume to hit a certain gravity. Parameters are volume of the wort, current gravity and target volume. The output shall be the the new gravity as well as the difference. Calculation is:

new gravity = (current gravity-1) * (current volume / target volume)

Create librustybeer

To be able to use this in drodil/rustybeer-aws-lambda project, a library of the rustybeer should be shipped as well. This should be easily done by changing the Cargo.toml file to describe the lib and bin like follows:

[lib]
name = "librustybeer"

[[bin]]
name = "rustybeer"

Maybe we need to create lib.rs for the library which exposes all the calculator functionality. See https://doc.rust-lang.org/cargo/guide/project-layout.html for more information.

Add releases

Few people will have rustc on their system, and that may put them off using the CLI-the project could be built with the --release tag and put in the releases tab of the main page to make it more accessible for people to download and use in their brewing projects

Add calorie calculalator

Add calculator to calculate calories in beer serving of different sizes or by custom volume (100ml by default). Use calculation formula example from here http://www.brewunited.com/beer_calorie_calculator.php

The calculator should take parameters for ABV or original+final gravity (use AbvCalculator to calculate ABV from those). It should report calories for all custom values given for volumes and additionally for different serving sizes done as part of #35

Calories should be reported in kcal and kJ per serving size. Additionally carbs amount would be interesting.

Add also command to run this calculator from CLI

Add hops support

To be able to use IBU calculator without need to set AA for all hops it would be beneficial to have most known hops in the app. Create new struct for hop and define constant hops from https://www.brewersfriend.com/hops/ . Each hop should have name, average AA and aroma/bittering(boil)/whirlpool/dry hop (enum) usage information.

Additionally create command to find hops based on their average AA with min and max values or with their usage type.

See #23 as an example.

Refactor rustybeer lib to use measurements library

Refactor rustybeer calculators to use measurements structs. This will standardize the API to accept input in any unit and also to return structs that can be converted to the users desired unit. At least the following calculators could take this into use:

  • Calorie counter
  • Alcohol volume weight
  • Diluting
  • IBU
  • Bottles calculator
  • Priming

At the moment the functions in these calculators take mixed units (from fahrenheit to grams to fluid ounces etc.)

Add Final Gravity calculator

Create a calculator to estimate final gravity based on original gravity and yeast attenuation. See https://www.northernbrewer.com/blogs/beer-recipes-ingredients/final-gravity for further details. Input parameters should be the original gravity and the attenuation of the yeast used. This change could use implementation of #41 to get the attenuation rates for specific yeasts so that user could just pass in the yeast they are using by name.

Additionally create CLI command to run the calculator.

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.