Coder Social home page Coder Social logo

item-catalog's Introduction

Item Catalog

Web application that provides a list of items within a category.

Requirements

  • Python > 3
  • Postgresql > 9.6
  • node.js

In production, you will also need to have

  • nginx
  • Phusion passenger

Installation

Clone or download this repo to a directory.

git clone https://github.com/akhilharihar/Udacity-Item-Catalog.git

Rename .env.example to .env and fill in the required configuration. Refer configuration section for more details.

Install dependencies

pip install -r requirements
npm install

Generate static assets dependencies

npm run dev

Migrate db schema to postgres database

flask db init
flask db migrate
flask db upgrade

To serve app:

flask run

To serve app with ssl:

flask run --cert=cert.pem --key=key.pem

If you do not have the data for category and item, please refer database seeding section on how to add fake date for item and category.

Deployment

Rename catalog.conf.example to catalog.conf and fill in the required configuration. Refer nginx configuration

If you've spun up a new server for deployment, you can automate the installation of this project dependencies with the provided install.sh and setup.sh script files.

Automated

The install.sh will install python3, nginx, passenger module, postgres, nodejs and setup firewall to only allow ssh, http and https ports.

The setup.sh file will help you in creating a postgres user and database and add this application to nginx sites.

chmod +x install.sh
chmod +x setup.sh
sudo ./install.sh
sudo ./setup.sh

Manual

Install nginx, libnginx-mod-http-passenger. Refer https://www.phusionpassenger.com/docs/advanced_guides/install_and_upgrade/nginx/install/oss/stretch.html on how to integrate phusion passenger with nginx.

Copy the catalog.conf to nginx sites directory. Usually, it is /etc/nginx/sites-enabled/

cp catalog.conf /etc/nginx/sites-enabled/catalog.conf

After copying, test if the configuration specified is correct.

nginx -t

Finally restart nginx for the changes to take effect.

Configuration

Environment

  • FLASk_ENV - The environment the app is running in. values - development or production
  • APP_KEY - Flask secret key. Please make sure that this value stays the same in production environment. Refer secret key.
  • SERVER_NAME - The name and port of the server. eg: 127.0.0.1:5000, example.com
  • STATIC_URL_PATH - Used to specify a different path for the static files on the web. In development, this value does not effect the url of the static files. Refer flask application object
  • DB_URI - Sqlalchemy database connection url - Refer Sqlalchemy database urls.
  • USERS_SALT, CATEGORY_SALT, ITEM_SALT - A random string to make hash of users, catgory, item id's unique. Please make sure that this value stays the same in production environment.
  • *_CLIENT_ID, *_CLIENT_SECRET - Respective oauth providers client id and secret.

Nginx

Database Seeding

Open flask shell in terminal and run below commands.

from catalog.seeder import CategorySeeder, ItemSeeder

CategorySeeder.run(count=15)
ItemSeeder.run(count=100)

count - number of rows to insert to database

item-catalog's People

Contributors

akhilharihar avatar

Watchers

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