Skip to content

Built a cloud-native microservice architecture for a DevOps-enabled shopping cart application πŸ›’β˜οΈ

License

Notifications You must be signed in to change notification settings

whykay-01/shopcarts-cloud-native-microservice

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NYU DevOps Cloud-native Shopcarts Microservice

License Python Build Status

Overview

This project contains code for shopcarts microservice. The /service folder contains your models/ folder for our models and a routes.py file for the shopcarts API service. The /tests folder has test cases for testing the model and the service separately. You can simply start the testing process once you clone the repository and reopen it in the container. After that is done, please run flask run for the local server to test the endpoints, or honcho start to test our UI integration with the API endpoints.

The following issues with functions described have been added to the model:

  • Query Capability: Model querying for items and shopcarts.
  • Code Refactoring: Improved code organization and readability, simplifying feature additions.
  • Item and Shopcart Querying: Feature for querying items by productID for detailed insights.
  • Shopcart Querying by ID: Detailed querying of shopcarts, showing items, quantities, and prices.
  • Shopcart Clear Functionality: Ability to clear all items from shopcarts in one action.
  • Item Quantity Incrementation: Updated functionality for adjusting item quantities in shopcarts.
  • Item Quantity Decrease: Enabled decreasing item quantities in shopcarts for shopping needs.

Contents

The project 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 your code

service/                   - service python package
β”œβ”€β”€ __init__.py            - package initializer
β”œβ”€β”€ config.py              - configuration parameters
β”œβ”€β”€ models/                - module with data models (Shopcart, Item models both are here)
β”œβ”€β”€ 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/                     - test cases package
β”œβ”€β”€ __init__.py            - package initializer
β”œβ”€β”€ factories.py           - factory faker file which generates data for our models
β”œβ”€β”€ test_cli_commands.py   - test suite for the CLI
β”œβ”€β”€ test_models.py         - test suite for data models
└── test_routes.py         - test suite for service routes

Models

Shopcart
Name Description Data type
id Unique ID for the shopcart. Integer
user_id Unique ID tying a User ID to the shopcart. String
items List of items in the shopcart items: List
Item
Name Description Data type
id Unique ID for the item. Integer
cart_id ID of the shopcart it belongs to Integer
product_name Name of the product String
product_id ID of the product Integer
quantity Quantity of the product in the cart Integer
product_price Price of the product when it was added Numeric

Routes

$ flask routes

Endpoint                       Methods  Rule
-----------------------------  -------  -----------------------------------------------------
index                          GET      /
health                         GET      /health      

create_shopcarts               POST     /api/shopcarts
get_shopcarts                  GET      /api/shopcarts/<int:shopcart_id
delete_shopcarts               DELETE   /api/shopcarts/<int:shopcart_id>
list_shopcarts                 GET      /api/shopcarts
update_shopcarts               PUT      /api/shopcarts/<int:shopcart_id>

delete_item                    DELETE   /api/shopcarts/<int:shopcart_id>/items/<int:product_id> 
delete_items                   DELETE   /api/shopcarts/<int:shopcart_id>/items              
list_items                     GET      /api/shopcarts/<int:shopcart_id>/items
create_item                    POST     /api/shopcarts/<int:shopcart_id>/items
get_item                       GET      /api/shopcarts/<int:shopcart_id>/items/<int:product_id>
update_shopcarts_item          PUT      /api/shopcarts/<int:shopcart_id>/items/<int:product_id>
clear_shopcart                 DELETE   /api/shopcarts/<int:shopcart_id>/items/clear
increment_item_quantity        PUT      /api//shopcarts/<int:shopcart_id>/items/<int:item_id>/increment
decrement_item_quantity        PUT      /api/shopcarts/<int:shopcart_id>/items/<int:item_id>/decrement           

License

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.

Releases

No releases published

Packages

No packages published

Languages

  • Python 68.7%
  • JavaScript 12.3%
  • HTML 7.1%
  • Gherkin 5.4%
  • Shell 3.4%
  • Makefile 2.2%
  • Other 0.9%