Skip to content

a full stack application that allows users to select an event type and render a curated list of wines, spirits, and beers based on the event.

License

Notifications You must be signed in to change notification settings

yolisabam/alcohol-event-planner

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

this.event:choice app

User Story

As a person who attending or hosting an event, I am unsure of what alcohol is appropriate to bring to or provide at a given event. I want to see a recommended selection of choices for various events.

Synopsis

this.event:choice is an application that allows users to select an event type and render a curated list of wines, spirits, and beers based on the event. The user can then compile a list of their selections, and save their list for later use.

Motivation

Instead of the going through the hassle of decision making when going to an event, it would be great to have an app that provides recommendations.

Technologies:

  • Express.js
  • Node.js
  • Sequelize.js
  • Handlebars.js
  • HTML5
  • CSS
  • Javascript
  • MySQL

User Story

As a person who attends events often, sometimes I am unsure of what alcohol is appropriate to bring given an event. And sometimes I have no time for research and want something on the fly.

Synopsis

this.event:choice is an application that will allow users to select a chosen event and render a curated list of wines, spirits, and beers based on the event. The user can then compile a list of their selections, and save their list for later

Motivation

Instead of the going throught the hassle of decision making when going to an event, it would be great to have an app that would automatically make the decision for us

Technologies:

  • Express.js
  • Node.js
  • Sequelize.js- Models
  • Handlebars.js - Rendering
  • HTML5- Front-End Scripting
  • CSS- Front-End Scripting
  • Javascript- Back-End Scripting
  • mySQL- Database Management
  • mySQL2- Database Management

Installation

  1. Clone repo:

    git clone https://github.com/dbmarshall/alcohol-event-planner/
    cd /alcohol-event-planner/
    
  2. Create new local config file:

    cd /alcohol-event-planner/config/
    cp config-BKUP.json config.json
    

    Update mysql references in new config.json file to match your local environment.

  3. Create database in MySQL:

    cd /alcohol-event-planner/db/
    mysql -u root -p
    source schema.sql;
    exit;
    
  4. Start server to create tables from models:

    cd /alcohol-event-planner/
    node server.js
    
  5. Populate Alcohol table with data from LCBO API:

    cd db/
    cp lcbo-BKUP.js lcbo.json
    

    Update mysql references in new lcbo.js file to match your local environment.

    Run node lcbo.js

  6. Populate tables with data in MySQL:

    cd db/
    mysql -u root -p
    source seeds.sql;
    exit;
    
  7. Create new Google oAuth config file:

    cd config/
    cp keys-BKUP.js keys.json
    

    Update mysql references in new keys.js file to match your local environment.

Visual Application Walkthrough

this.event:choice walk-through

Code Examples

LCBO

var request = require("request");
var mysql = require("mysql2");

var connection = mysql.createConnection({
  host: "localhost",
  port: 3306,
  user: "root",
  password: "Candelabra01!",
  database: "alcohol_db"
});

connection.connect(function(err) {
  if (err) throw err;
  console.log("connected as id " + connection.threadId + "\n");
});

function getLcboData() {

  var qUrl = "https://lcboapi.com/products?per_page=100&access_key=MDpjOTBmZTUyMC1jMWNiLTExZTctYjg4MC02YmZmM2Y5NTY3NDE6VkxhMzdqNHcweFNhRkJrb3cyYXFpZVFxYW5JaklkUWZ4TDV5";

  request.get(qUrl, function(error, response,body) {

  if (error) throw error;
  
  var objBody = JSON.parse(body);
  var data = objBody.result;

  var arrayOfAlcohols = [];
  
  for(var i = 0; i < data.length; i++) {
    var beerBool = false;
    var liquirBool = false;
    var wineBool = false;

    if (data[i].primary_category === "Beer") {
      beerBool = true;
    } else if (data[i].primary_category === "Spirits") {
      liquirBool = true;
    } else if(data[i].primary_category === "Wine") {
      wineBool = true;
    }

    arrayOfAlcohols.push(
      [
        data[i].primary_category,
        data[i].name,
        data[i].image_thumb_url,
        data[i].tags,
        beerBool,
        liquirBool,
        wineBool
      ]
    );
  };

  var query = 'INSERT INTO Alcohol (type, name, image, tag, beerBool,liquirBool, wineBool) VALUES ?';
    connection.query(query, [arrayOfAlcohols], 
      function(err, res) {
      if (err) throw err;
        console.log(res.affectedRows + " products inserted!\n");
        connection.end();
    });
  });

}  

getLcboData();

Ocassions Route

app.post('/api/user/:id/event/:eventid/occasion', function(req, res) {

    // Write first to Occasions table
    db.Occasion.create({
      UserId: req.params.id,
      name: req.body[0].name,
    }).then(function(dbPost1) {

        // Assemble new array of objects with alcoholIds for this new occasionId
        var newEventAlcohols = [];
        for (var i = 0; i < req.body.length; i++) {
          newEventAlcohols.push(
            {
              OccasionId: dbPost1.id,
              AlcoholId: req.body[i].alcoholId
            }
          );
        }

      // Then write first to OccasionAlcohols model
      db.OccasionAlcohol.bulkCreate(newEventAlcohols)
      .then(function(dbOccasion) {

        res.json(dbOccasion);

      });
    });

  });

Available Node Commands and URLs

Local:

Heroku Deployment:

Misc Notes

  • Github master branch pushes autodeploy to Heroku (sweet).

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details

About

a full stack application that allows users to select an event type and render a curated list of wines, spirits, and beers based on the event.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 58.8%
  • JavaScript 35.9%
  • CSS 5.3%