Skip to content

MuchiraIrungu/Extract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FitMart Product API & Inventory Report Generator This project provides two key functionalities:

A FastAPI-based REST API to serve product data from an Excel sheet.

A Django-integrated inventory report generator that exports styled Excel reports from a PostgreSQL database.

πŸ”§ Tech Stack Python 3.x FastAPI Pandas OpenPyXL Pillow PostgreSQL Django (for database access) Uvicorn (for running FastAPI server)

πŸ“ File Structure bash Copy Edit β”œβ”€β”€ sample.py # FastAPI backend to serve Excel product data β”œβ”€β”€ report2.py # Generates formatted inventory Excel reports β”œβ”€β”€ Product data.xlsx # Sample product data file (used by sample.py) β”œβ”€β”€ logo.png # Logo used in the Excel report β”œβ”€β”€ report.xlsx # Auto-generated styled inventory report πŸš€ 1. FastAPI Product API (sample.py) πŸ“ Description Serves product data from an Excel file (Product data.xlsx) through a REST API at /products/.

πŸ“¦ How to Run pip install fastapi uvicorn pandas openpyxl pillow uvicorn sample:app --reload

πŸ”— API Endpoint GET /products/: Returns a JSON array of product objects with:

Name Brand Category Price Discount Stock Quantity Size

πŸ“Š 2. Inventory Report Generator (report2.py) πŸ“ Description Fetches product data from a PostgreSQL database via Django ORM and exports a fully formatted Excel report (report.xlsx) with a logo, summary stats, and product listings.

βš™οΈ Prerequisites Django project set up with a products app and Product model. PostgreSQL database with valid credentials.

πŸ“¦ How to Run pip install openpyxl pillow pandas psycopg2 django python report2.py ⚠️ Make sure logo.png exists in the same directory.

βœ… Output report.xlsx β€” Includes:

Logo Title and date Total number of products and categories Product table with ID, Name, Quantity, and Price Styled headers, borders, and column widths

πŸ›  Configuration Notes Update the PostgreSQL connection credentials in report2.py:

conn_params = { 'host': 'localhost', 'database': 'fitmart_db', 'user': 'postgres', 'password': 'your_password', } Ensure your Django settings and model paths are correctly defined for importing.

πŸ“Έ Sample Preview A screenshot or sample of report.xlsx would go here.

✨ Future Improvements Add authentication to the API

Upload new products via API

Automate daily report generation with cron or Django management command

Deploy the FastAPI service

πŸ“ License This project uses open-source components and is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages