Giter Site home page Giter Site logo

express-project-organizer's Introduction

Express Project Organizer

To practice N:M associations, we'll be adding the ability to categorize projects in an existing project organizer.

Backstory: Project Organizer

Keeping track of projects is a necessary part of peoples' personal lives and businesses. Another individual has created a project organizer that allows you to create and view projects, but it'd be nice to categorize projects. Let's add this functionality!

Getting Started

We'll be using an existing application that includes one model, a few routes, and a few views.

  • Fork and clone this repository
  • Run npm install to install dependencies from the existing package.json file
    • Use nodemon to start your application
  • Setup your database (this app already has one existing model)
    • Run createdb project_organizer_development to create the database
    • Run sequelize db:migrate to run migrations
    • Run sequelize db:seed:all to populate the database with 4 projects from previous Seattle cohorts.

Read the Code

After setup, STOP. You're using an existing application, so make sure to read the code and ensure what the application does. Here is some information about the current setup.

  • Routes
    • GET / - home page that lists all projects
    • POST /projects - creates a new project, then redirects back to GET /
    • GET /projects/new - page that has a form for creating a new project
    • GET /projects/:id - page that shows a specific project
  • Models
    • project
    • Attributes: name, githubLink, deployedLink, description

User Stories

  • As a user, I want to categorize projects using different names. For example, all of my Node projects will be under the category "Node".
  • As a user, I want to assign multiple categories to a single project.
  • As a user, I want to view a list of categories I've assigned.
  • As a user, I want to view projects associated with a category I've selected.

Requirements

Part 1: Create a Category model

In order to add categories, create a Sequelize model to store categories. It's recommended that you name this model category. It will store one attribute: the name of the category (a string).

Once this model has been created, run the migration for the model and test the model's functionality. This can be done in a separate file. An example:

dbTest.js

var db = require('./models')

db.category.create({
  name: 'node'
}).then(function(category) {
  console.log(category.id)
})

Part 2: Create a Join model

In order to associate a category to many projects, and a project to many categories, we'll need to create an intermediate model. It's recommended that you name this model categoriesProjects. It will store two attributes: the id of a category (an integer) and the id of a project (an integer).

Once created, add the associations need to create a many-to-many association between categories and projects, using the join table you just created. Be sure to test this functionality by creating categories and projects, then seeing if you can include them in different queries.

var db = require('./models')

db.project.findOne({
  where: { id: 1 },
  include: [db.category]
}).then(function(project) {
  // by using eager loading, the project model should have a categories key
  console.log(project.categories)

  // addCategory function should be available to this model
  project.addCategory({ name: 'node' }).then(function(category) {
    console.log(category.id)
  })
})

Note that these are two possible queries you can perform. There are others that you'll want to test.

Part 3: Integrate the model with the app

Now that the models have been created, you'll want to add the ability to create categories, view categories, and view projects by category to the rest of the application. Here is an approach you can take:

  • Add a field to GET /projects/new that accepts a category, then save the category on POST /projects
    • Keep in mind that categories should be associated with projects
    • Category names should be unique; the category model should have no duplicates (hint, use findOrCreate)
  • Create the following routes for viewing categories and viewing projects by category:
    • GET /categories - show all the categories that exist
    • GET /categories/:id - show a specific category and all the projects with that category

Part 4: Styling

When finished with the above, style the application appropriately with CSS. Try using a CSS framework you haven't used before, or a CSS syntax like BEM or OOCSS.

Bonuses

  • Add the ability to edit and delete projects
  • Add the ability to input and assign multiple tags via a comma separated list.
    • Example: Inputting node, pizza, music would add all three tags to a project at once.
    • You'll notice that this will require multiple queries, dependent on how many tags you're adding. Look into using the async module in order to run multiple asynchronous functions and send a response at the correct time.

Deliverables

Here are some example screenshots. Your finished deliverable will differ and include the desired functionality.

New Project Page w/Categories

Example Project w/Categories

Categories Page

Example Categories Page

Categories Show Page

Example Categories Show Page


Licensing

  1. All content is licensed under a CC-BY-NC-SA 4.0 license.
  2. All software code is licensed under GNU GPLv3. For commercial use or alternative licensing, please contact [email protected].

express-project-organizer's People

Contributors

bhague1281 avatar brandiw avatar 009kings avatar connorjclark avatar melissay94 avatar

Watchers

James Cloos 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.