GithubHelp home page GithubHelp logo

catalog's Introduction

Catalog Project

Catalog Project for Udacity Full Stack Nanodegree.

This project is a python/flask application that supports CRUD operations against a sqlite database. The database contains items that might be stocked by a sporting goods store. The items can be filtered by category (Baseball, Football etc.) and the application allows users to add/edit/delete items as necessary. All changes to the data are persisted to the sqlite database using POST operations on the flask endpoints.

The database that this program queries contains three tables: user, categories and items. Categories and items have a foriegn key relationship to the user table, and items has a foriegn key relationship to the categories table.

The definitions of these tables is as follows:

user table definition:

    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    email = Column(String(250), nullable=False)
    picture = Column(String(250))

categories table definition:

    id = Column(Integer, primary_key=True)
    name = Column(String(250), nullable=False)
    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship(User)

items table definition

    id = Column(Integer, primary_key=True)
    title = Column(String(250), nullable=False)
    description = Column(String(500))
    cat_id = Column(Integer, ForeignKey('categories.id'))
    user_id = Column(Integer, ForeignKey('user.id'))
    user = relationship(User)
    categories = relationship(Categories)

How to run this code

Install the VM and Vagrant:

This project uses a virtual machine (VM) to run a SQL database server.

  1. If you don't already have virtual box on your machine, you can download it here:
  1. Download and install Vagrant (if you do not already have it installed). This is the software that configures the VM and allows the host (your machine) to talk to the VM:
  1. Clone this repository: https://github.com/jkolden/catalog.git to a directory on your local machine and then cd into this directory.
  2. cd into the vagrant subdirectory
  3. Bring the VM up with the command vagrant up
  4. Log into the VM with vagrant ssh

Create and populate the database (not required):

  1. This application will come with a prepopulated database named sportingequipment.db
  2. If required for this assignment you can delete the sportingequipment.db file from the catalog subdirectory and recreate it by running the following commands at the command line:
  • cd into the vagrant/catalog directory
  • vagrant@vagrant:/vagrant/catalog$ python database_setup1.py
  • vagrant@vagrant:/vagrant/catalog$ python categories.py
  • You should now see the sportingequipment.db file created inside your vagrant/catalog subdirectory.

Run the project.py file

  1. At the vagrant@vagrant:~$ prompt, cd into: /vagrant/catalog.
  2. In the /vagrant/catalog subdirectory run the project file:
  • vagrant@vagrant:/vagrant/catalog$ python project.py
  1. You can now access the running application on http://localhost:8000/

How to use the application

  1. The recommended browser is Google Chrome.
  2. The application homepage provides a list of categories and their respective items.
  3. Before you can perform any operations you will need to click the login link in the upper right corner.
  • You can login with your google sign in.
  • After successfully signing in you will be redirected to the catalog app homepage and your username will appear in the upper right corner.
  1. Select a category on the left to see the items that are in that category. The items will be displayed on the right.
  2. Select an item to see the details of that item.
  3. Click the create new item link to add a new item. You will be recorded as the owner of the item and you will have priviledges to edit and/or delete this item as well.
  4. To logout, simply click the logout link in the upper right corner.

How to use this application's data with another application

This catalog app provides three JSON endpoints that can be consumed as a GET request in any other application:

catalog's People

Contributors

forbiddenvoid avatar jkolden avatar karlud avatar lobrown avatar pmallory avatar runar-rkmedia avatar stevewooding avatar

Watchers

 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.