Skip to content

a-hussien/coffee_shop_full_stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Coffee Shop Full Stack

About the project:

A new digitally enabled cafe for students to order drinks, socialize, and study hard.

  1. Display graphics representing the ratios of ingredients in each drink.
  2. Allow public users to view drink names and graphics.
  3. Allow the shop baristas to see the recipe information.
  4. Allow the shop managers to create new drinks and edit existing drinks.

This project demonstrate the following :

  • Implementing authentication and authorization in Flask
  • Designing against key security principals
  • Implementing role-based control design patterns
  • Securing a REST API
  • Applying software system risk and compliance principles

PIP Dependencies

Once you have your virtual environment setup and running, install dependencies by naviging to the /backend directory and running:

pip install -r requirements.txt

This will install all of the required packages we selected within the requirements.txt file.

Key Dependencies
  • Flask is a lightweight backend microservices framework. Flask is required to handle requests and responses.

  • SQLAlchemy and Flask-SQLAlchemy are libraries to handle the lightweight sqlite database. Since we want you to focus on auth, we handle the heavy lift for you in ./src/database/models.py. We recommend skimming this code first so you know how to interface with the Drink model.

  • jose JavaScript Object Signing and Encryption for JWTs. Useful for encoding, decoding, and verifying JWTS.

Securing the application with :

auth0

Auth0 Account configuration variables:

  • AUTH0_DOMAIN = 'pixelcode.us.auth0.com'
  • ALGORITHMS = ['RS256']
  • API_AUDIENCE = 'Coffee-Shop'

Application URI:

https://pixelcode.us.auth0.com/authorize?response_type=token&client_id=iIuKpv3cETqwNZw2gaiCCUkjPVxPy1gG&redirect_uri=http://127.0.0.1:8100/tabs/user-page&audience=Coffee-Shop

Manager Access_token

eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IjIwcWhpd3ViZTZtOWR0NDM5NGE3cSJ9.eyJpc3MiOiJodHRwczovL3BpeGVsY29kZS51cy5hdXRoMC5jb20vIiwic3ViIjoiYXV0aDB8NWYzZjAxYmY0NzY2ODMwMDY3ZWFmMWM4IiwiYXVkIjoiQ29mZmVlLVNob3AiLCJpYXQiOjE1OTgyODExMTEsImV4cCI6MTU5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2IMnQTrp7sxPM60ljNit5BOnmcu7ldQvt2gpzEem1stI6M56x579LcFqUrtGqxomelDusc_Jt1IWB_3BsKisrbkC0RKGCnw3iix3Ve-Rw_CNKW3PEfyj3EtOiffQ9IGFcL4-w_DUHmrtTPuuOG8D3Tv1wMj0yHL33vnSx4P0rsr1NN86X2Fx9SCbB_yA

Backend:

  • Added Auth0 functionalities on auth.py
  • Implemented RESTful endpoints on api.py
  • Implemented error handlers 400, 404, 405, 422 on api.py
  • Implemented Autherror handlers with appropriate status code indicating reason for failure on api.py

Running the server

From within the ./src directory first ensure you are working using your created virtual environment.

Each time you open a new terminal session, run:

export FLASK_APP=api.py;

To run the server, execute:

flask run --reload

The --reload flag will detect file changes and restart the server automatically.

Integration test with Postman :

  • Exported collection with configured tokens can be found at: /backend/udacity-fsnd-udaspicelatte.postman_collection.json

  • Test results containing 20 successful cases: /backend/Results_udacity-fsnd-udaspicelatte.postman_collection.json

Frontend

The ./frontend directory contains a complete Ionic frontend to consume the data from the Flask server.

View the README.md within ./frontend for more details.

About

New digitally enabled cafe for students to order drinks, socialize, and study hard.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published