r/PythonProjects2 • u/Ok_Meet_1645 • May 27 '26
Inventory Control System with AI Analytics
Facts
The program is a command-line inventory management system written in Python.
It uses a dataclass
Productto store product data such as ID, name, stock, code, and price.Products exist only in memory during runtime unless written to file.
The system supports full CRUD operations:
Add new products
Display products in a formatted table
Update stock levels up or down
Edit product name, code, and price
Remove products
It tracks purchased products in a CSV file named
BoughtProducts.csv.Each purchase appends product data to the file with fields:
ID, Name, Stock, Code, Price
It uses pandas to load CSV data for analysis.
It uses matplotlib to visualize:
Price distribution per product code
Total money sold as a bar chart
The system includes an AI agent powered by a local LLM endpoint:
Uses
requests.postto communicate withhttp://localhost:11434/api/generateSupports three modes:
Warehouse policy analysis
General question answering
Curve and trend analysis
The AI prompts enforce strict rules:
No assumptions
No trend analysis without time data
Only data-driven conclusions
Risk levels: low, medium, high
Stock management rules are embedded:
Stock below 5 is considered high risk
Stock above 20 is considered low risk
Negative stock is flagged as invalid
File operations include:
Appending purchases to CSV
Reading CSV for AI analysis
Saving AI reports to text files
The system runs in an infinite loop menu until exit is selected.
External libraries used:
pandas for data handling
matplotlib for visualization
numpy for numeric arrays
requests for AI communication
fitz imported but not used
dataclasses for structured product objects