This repository contains a Flask-based Product Catalog Service allowing management of products through various endpoints.
Before you can run the application, ensure you have the following prerequisites and dependencies:
- Docker: Used for containerizing the application.
- bin: Contains the setup script
setup.sh
for setting up the project. - app: Directory for the Flask application.
- init.py: Initializes the Flask app, configures SQLAlchemy, and sets up routes.
- config.py: Holds configurations for the Flask app and tests.
- models: Includes the
Product
model for database operations. - routes: Defines endpoints for product management.
- tests: Contains unit tests for the product endpoints.
- run.py: Entry point to run the Flask application.
- Dockerfile: Docker configuration for containerizing the application.
- .env: Environment variables configuration file.
- LICENCE: License file for the project.
- pytest.ini: Configuration for pytest.
-
Clone the repository:
git clone https://github.com/munuhee/product-catalog-service.git cd product-catalog-service
-
Grant execution permissions to the setup script:
chmod +x bin/setup.sh
-
Run the setup script to build the Docker image and start the Flask app:
./bin/setup.sh
-
Access the application:
- Locally: https://localhost:8080
- Remotely: https://YOUR_SERVER_IP:8080
-
Health Status:
/status
- Example:
GET /status
- Retrieves the health status of the service.
- Example:
-
Create Product:
/product-create
(POST)- Example:
POST /product-create
- Creates a new product.
- Example:
-
Get Products:
/products
(GET)- Example:
GET /products
- Retrieves a list of all products.
- Example:
-
Get Product by ID:
/products/<product_id>
(GET)- Example:
GET /products/123
- Retrieves product details with ID 123.
- Example:
-
Update Product by ID:
/products/<product_id>/update
(PUT)- Example:
PUT /products/123/update
- Updates product details with ID 123.
- Example:
-
Delete Product by ID:
/products/<product_id>/delete
(DELETE)- Example:
DELETE /products/123/delete
- Deletes product with ID 123.
- Example:
Refer to the product_routes.py
file in app/routes
for detailed endpoint implementations.
The docker-img.yml
file in the repository sets up CI/CD using GitHub Actions for continuous integration and deployment of the Docker image.
The app/tests
directory contains comprehensive unit tests (test_product_endpoints.py
) for various product-related endpoints. The tests cover functionalities such as health status, product creation, retrieval, update, and deletion.
Contributions are welcome! Feel free to open issues or pull requests for any improvements, bug fixes, or new features.