This repository is based on the Question Statement mentioned in the Question_Statement
file. The application is built using FastAPI and provides functionality for managing products, customers, orders, and carts in an e-commerce store.
- FastAPI: A modern, fast (high-performance) web framework for building APIs with Python.
- Uvicorn: An ASGI server for running FastAPI applications.
- Pytest: A framework for unit testing.
- Product Management
- Customer Management
- Cart Management
- Order Placement with Coupon Code Application
- Admin APIs for Generating Discount Codes and Listing Purchase Statistics
- Install
pipenv
:pip3 install pipenv
-
Install Dependencies:
pipenv install
-
Activate Virtual Environment:
pipenv shell
-
Run the Debugging Server:
pipenv run uvicorn app.main:app --reload
The application will be available at http://localhost:8000.
-
Execute Test Cases:
pipenv run pytest
- GET
/products/
: List all products. - GET
/products/{product_id}
: Get details of a specific product. - POST
/products/
: Create a new product. - GET
/customers/
: List all customers. - GET
/customers/{customer_id}
: Get details of a specific customer. - POST
/customers/
: Create a new customer. - POST
/cart/add/
: Add an item to the cart. - DELETE
/cart/remove/{product_id}/
: Remove an item from the cart. - POST
/cart/apply-coupon/
: Apply a coupon to the cart. - GET
/cart/
: View the cart. - POST
/orders/
: Place an order.
- POST
/admin/generate-discount-code/
: Generate a discount code by the admin. - GET
/admin/purchase-stats/
: List count of items purchased, total purchase amount, list of discount codes, and total discount amount.
Which can be added to this project
-
Authentication and Authorization: As its a demo project, to make it more secure, user authentication and authorization can be added.
-
Database Integration: As its a demo project, its used in-memory data structure, we can integrate it with a database for persistent storage.
-
Comprehensive Error Handling: As its a demo project, we can enhance error handling and validation across all endpoints.