This is a demo project that implements a REST API for a "pretty simple shop" using:
- Python3
- Flask 1.0
- SQLAlchemy
- Marshmallow 3
- factoryboy
- pytest
- CircleCI
- Flake8
Besides CRUD functionality the API also exposes statistics, produced with custom SQLAlchemy queries
- Products count by category
- Customers count by country
- Orders count by status
- Products sells
- Units delivered by product by country
Complete REST api documentation can be found in the openapi.yaml
file. Use
http://editor.swagger.io to load the yaml file and play with de API (point line 8 of openapi.yaml
to your server, ex: url: 'http://localhost:5000/api'
.
- Model diagram
python3 -m venv venv
. ./venv/bin/activate
pip install -r requirements.txt
pip install -e .
app db upgrade
app populate-db
. ./venv/bin/activate
app run
. ./venv/bin/activate
pytest
docker build . -t example-shop-py
An example docker-compose.yml is provided. It creates two containers, the app and a PostgreSQL database.
Try it running:
docker-compose up
App will be published at http://localhost:5000/