This project is a RESTful service managing relationships between two products.
This project is part of a course project that is the backend for an eCommerce website as a collection of RESTful services. The class is divided into 9 squads, and each squad develops and runs a service end-to-end. This repo belongs to the Recommendations Squad who is responsible for managing relationships between two products.
The repo contains the following:
.gitignore - this will ignore vagrant and other metadata files
.flaskenv - Environment variables to configure Flask
.gitattributes - File to gix Windows CRLF issues
.devcontainers/ - Folder with support for VSCode Remote Containers
dot-env-example - copy to .env to use environment variables
pyproject.toml - Poetry list of Python libraries required by the code
service/ - service python package
├── __init__.py - package initializer
├── config.py - configuration parameters
├── models.py - module with business models
├── routes.py - module with service routes
└── common - common code package
├── cli_commands.py - Flask command to recreate all tables
├── error_handlers.py - HTTP error handling code
├── log_handlers.py - logging setup code
└── status.py - HTTP status constants
tests/ - TDD test cases package
├── __init__.py - package initializer
├── test_cli_commands.py - test suite for the CLI
├── test_models.py - test suite for business models
└── test_routes.py - test suite for service routes
features/ - BDD test cases package
│ steps/ - test steps
│ ├── recommendations_steps.py - to be executed before every test
│ └── web_steps.py - implementation of test steps
├── environment.py - prepare the BDD testing environment
└── recommendations.feature - BDD tests
k8s/ - configuration files for kubernetes deployment
Column | Description |
---|---|
id | Integer, serves as the primary key |
likes | Integer no less than 0, reflects the popularity of a recommendation |
product_a_sku | String with no more than 10 characters, can not be null, represents product a |
product_b_sku | String with no more than 10 characters, can not be null, represents product b |
recommendation_type | one of {"UP_SELL", "CROSS_SELL", "ACCESSORY", "BUNDLE"}, denotes the relationship between product a and product b |
{'id': 526, 'likes': 0, 'product_a_sku': 'HYJtLnYf', 'product_b_sku': 'cUnyEDwP', 'recommendation_type': 'CROSS_SELL'}
Retrieves the Recommendation with the given id
.
Deletes the Recommendation with the given id
.
Increments the likes
field of the Recommendation with the given id
by 1.
Decrements the likes
field of the Recommendation with the given id
by 1. Likes cannot be lower than 0.
Retrieves all Recommendations from the database.
Retrieves all Recommendations whose product_a_sku
and / or recommendation_type
match the input.
Clears all inputs.
Creates a Recommendation in the database with the given product_a_sku
, product_b_sku
, recommendation_type
and likes
. The id
and likes
are automatically managed by the database.
The root URL returns the administration frontend described above.
Returns all of the Recommendations.
Creates a Recommendation based on the data in the posted body.
Retrieves a single Recommendation based on the id.
Deletes a Recommendation based on the id specified in the path.
Updates a Recommendation based on the posted body.
Increments likes for a Recommendation.
Decrement likes for a Recommendation.
The project is based on NYU DevOps Project Template
The TDD testing (pytest) is based on NYU DevOps Lab Flask TDD
The k8s templates are based on NYU DevOps Lab Kubernetes
The BDD testing (behave) is based on NYU DevOps Lab Flask BDD
The flask-restx implementation is based on NYU DevOps Lab Flask Rest Plus Swagger
Copyright (c) 2016, 2024 John Rofrano. All rights reserved.
Licensed under the Apache License. See LICENSE
This repository is part of the New York University (NYU) masters class: CSCI-GA.2820-001 DevOps and Agile Methodologies created and taught by John Rofrano, Adjunct Instructor, NYU Courant Institute, Graduate Division, Computer Science, and NYU Stern School of Business.