Item CMS is a basic RESTful APIs framework design to manage items, the not typed structure is designed to be suitable for a wide range of products / items.
The tech stack will include:
-
SQLAlchemy ORM library.
-
Flask-Migrate for creating and running schema migrations.
-
Flask-CORS to handle cross origin requests.
Follow instructions to install the latest version of python for your platform in the python docs
Instructions for setting up a virtual environment for your platform can be found in the python docs
# https://linuxize.com/post/how-to-create-python-virtual-environments-on-ubuntu-18-04/
sudo apt install python3-venv
# Within the directory
python3 -m venv env
source env/bin/activate
With Postgres running, in terminal run:
# On Ubuntu 18.04
sudo -u postgres psql
create user billy password 'billy123';
create database itemcms owner billy;
With your virtual environment setup and running, install dependencies by running:
# with active virtual environment
pip3 install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt
file.
# -----------------------------------------------------------------------------
# gunicorn
# -----------------------------------------------------------------------------
# Heroku
web: gunicorn --bind 127.0.0.1:5000 --pythonpath backend/src wsgi:app
# Local
# NOTE change "billy" with your postgresql user
cd <mainDir>
source env/bin/activate
export DATABASE_URL="postgresql://billy:billy123@127.0.0.1:5432/itemcms" &&
export DEBUG=True &&
gunicorn --bind 127.0.0.1:5000 --pythonpath backend/src wsgi:app --reload --log-level debug
# -----------------------------------------------------------------------------
Got to: http://127.0.0.1:5000/reset-db
cd <mainDir>
source env/bin/activate
# run the tests
export DATABASE_URL="postgresql://billy:billy123@127.0.0.1:5432/itemcms" && export DEBUG=True && python backend/src/test_api.py
The authentication, related profiles, privileges and roles are implemented with Auth0
Actor | Role | CURD Privileges |
---|---|---|
Admin | Administrator (Login required) | All privileges |
User | User (Login required) | See the schema below |
Public | Public (NO login required) | See the schema below |
Tables | Create | Read | Update | Delete |
---|---|---|---|---|
items | False | True | False | False |
categories | False | True | False | False |
Tables | Create | Read | Update | Delete |
---|---|---|---|---|
items | False | True | True | False |
categories | False | True | True | False |
------------------------------------------
Admin:
------------------------------------------
email: -----> admin@itemcms.herokuapp.com
password: --> PoloCottoBene123
------------------------------------------
User
------------------------------------------
email: -----> user@itemcms.herokuapp.com
password: --> PolloCottoMale123
------------------------------------------
NOTE: Look on the address bar and grab your access token from the url
- Local base url: 127.0.0.1:5000/
- Remote base url: https://itemcms.herokuapp.com/
Endpoint | Method | Requires Auth |
---|---|---|
/categories | POST | create:category |
/categories | GET | None |
/categories/id | PATCH | update:category |
/categories/id | DELETE | delete:category |
/items | POST | create:item |
/items | GET | None |
/items/id | PATCH | update:item |
/items/id | DELETE | delete:item |