<commit_before>---
layout: post
title:  PuckerUp - My SPA Built With AngularJS and a Rails API
date:   2016-10-06 20:49:05 -0400
---

<p>
  <span style="text-align:center; display: block;">
    <iframe type="text/html" width="682" height="414" src="https://www.youtube.com/embed/9N_rNwhFwl0?version=1&amp;rel=1&amp;fs=1&amp;autohide=2&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent" allowfullscreen="true" style="border:0;">
    </iframe>
  </span>
</p>

Learning AngularJS was amazing, plain and simple.  It was incredible to finally see how you could plan out and engineer a single-page application (SPA) with a dynamic AngularJS frontend that communicates with a Rails API backend.  I understood how you could split up architecting between frontend and backend teams.

But let's get into the project.

## Idea
PuckerUp is my latest application and it's a SPA! It brings together my excitement for AngularJS, Rails and sour beers.  The goal of PuckerUp is to provide users with the ultimate, crowd-sourced list of sour beer breweries across the USA.  Everywhere you go, PuckerUp will help you locate your next sour brew.

My first Rails application is AllergyFree Meals (AFM), a web application that helps you find delicious and healthy recipes contributed by a community of allergy-conscious users.  All code is publicly available at [GitHub](https://github.com/agdavid/allergy-free-meals-rails-application).  Checkout a video walkthrough of AFM above, and overview of the development process below. Enjoy!

**Inspiration for AllergyFree Meals**
Cooking is one of the daily experiences I really enjoy - it is family-centric, relaxing, but also builds up with excitment to the point of eating!  However, with a sibling managing celiac disease and a nephew severely allergic to five of the "big eight" allergens, I am also trying to make sure that dining experiences as a family are always inclusive and allergy conscious.  AFM aims to help us eat smart, eat delicious, but also eat allergy-free.

**Key Database Relationships**
AFM began as a simple application, but as the features I wanted to create grew, it blossomed into a database with nine (9) tables, including four (4) join tables.  The key join-relationships are outlined below:

*Items - Ingredients - Recipes*
This is the heart of the application, managing the feature that most users might look for - the ability to create a recipe. A Recipe and Item are connected through the join-table of Ingredients, and the join-table contains the extra attribute of "quantity".  As explained further in "Highlights of Coding Challenges" (below), this relationship led to a deeply-nested form and required a custom writer in the Recipe model to handle Ingredients and Items when instantiating a new Recipe.  The model relationships were as follows:

```
class Recipe < ActiveRecord::Base
  has_many :ingredients
  has_many :items, through: :ingredients
  accepts_nested_attributes_for :ingredients, allow_destroy: true
  accepts_nested_attributes:for :items
end
```

```
class Ingredient < ActiveRecord::Base
  belongs_to :recipe
  belongs_to :item 
  accepts_nested_attributes_for :item
end
```
<commit_msg>add content<commit_after>---
layout: post
title:  PuckerUp - My SPA Built With AngularJS and a Rails API
date:   2016-10-06 20:49:05 -0400
---

<p>
  <span style="text-align:center; display: block;">
    <iframe type="text/html" width="682" height="414" src="https://www.youtube.com/embed/9N_rNwhFwl0?version=1&amp;rel=1&amp;fs=1&amp;autohide=2&amp;showsearch=0&amp;showinfo=1&amp;iv_load_policy=1&amp;wmode=transparent" allowfullscreen="true" style="border:0;">
    </iframe>
  </span>
</p>

Learning AngularJS was amazing, plain and simple.  It was incredible to finally see how you could plan out and engineer a single-page application (SPA) with a dynamic AngularJS frontend that communicates with a Rails API backend.  I understood how you could split up architecting between frontend and backend teams.

But let's get into the project.

# Idea
PuckerUp is my latest application and it's a SPA! It brings together my excitement for AngularJS, Rails and sour beers.  The goal of PuckerUp is to provide users with the ultimate, crowd-sourced list of sour beer breweries across the USA.  Everywhere you go, PuckerUp will help you locate your next sour brew.

My first Rails application is AllergyFree Meals (AFM), a web application that helps you find delicious and healthy recipes contributed by a community of allergy-conscious users.  All code is publicly available at [GitHub](https://github.com/agdavid/allergy-free-meals-rails-application).  Checkout a video walkthrough of AFM above, and overview of the development process below. Enjoy!

**Inspiration for AllergyFree Meals**
Cooking is one of the daily experiences I really enjoy - it is family-centric, relaxing, but also builds up with excitment to the point of eating!  However, with a sibling managing celiac disease and a nephew severely allergic to five of the "big eight" allergens, I am also trying to make sure that dining experiences as a family are always inclusive and allergy conscious.  AFM aims to help us eat smart, eat delicious, but also eat allergy-free.

**Key Database Relationships**
AFM began as a simple application, but as the features I wanted to create grew, it blossomed into a database with nine (9) tables, including four (4) join tables.  The key join-relationships are outlined below:

*Items - Ingredients - Recipes*
This is the heart of the application, managing the feature that most users might look for - the ability to create a recipe. A Recipe and Item are connected through the join-table of Ingredients, and the join-table contains the extra attribute of "quantity".  As explained further in "Highlights of Coding Challenges" (below), this relationship led to a deeply-nested form and required a custom writer in the Recipe model to handle Ingredients and Items when instantiating a new Recipe.  The model relationships were as follows:

```
class Recipe < ActiveRecord::Base
  has_many :ingredients
  has_many :items, through: :ingredients
  accepts_nested_attributes_for :ingredients, allow_destroy: true
  accepts_nested_attributes:for :items
end
```

```
class Ingredient < ActiveRecord::Base
  belongs_to :recipe
  belongs_to :item 
  accepts_nested_attributes_for :item
end
```

{'fraction_non_alphanumeric': 0.06854901960784314, 'fraction_numerical': 0.011294117647058824, 'mean_word_length': 4.871086556169429, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5524096', 'n_tokens_mistral': 1832, 'n_tokens_neox': 1717, 'n_words': 839}