The PetrolPump Management System is a full-stack web application built with Python and MySQL that digitises the day-to-day operations of a petrol pump business. Through an interactive browser-based interface, operators can manage pumps, owners, employees, customers, invoices, and tankers — all backed by a relational MySQL database with referential integrity, a salary-guard trigger, and a stored function for calculating tanker revenue totals. Every entity supports the full Create, Read, Update, and Delete (CRUD) lifecycle without writing a single line of SQL by hand.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Adarsh275/PetrolPump-Management-System/llms.txt
Use this file to discover all available pages before exploring further.
Tech Stack
| Layer | Technology |
|---|---|
| Frontend / UI | Streamlit — Python-native web app framework |
| Database | MySQL 8.0+ — relational storage with InnoDB engine |
| DB Driver | mysql-connector-python — official MySQL connector for Python |
| Data Display | pandas — DataFrames used to render query results |
| Language | Python 3.8+ |
High-Level Architecture
The application is split into two top-level directories. TheProject/ directory holds all Python source files; Backend/ holds the raw SQL scripts used to provision the schema.
app.py is the single entry point. It renders the Streamlit sidebar, reads the user’s table and operation choice, then delegates to the appropriate function imported from create.py, read.py, update.py, or delete.py. All actual SQL execution lives inside database.py, which opens one shared mysql.connector connection at import time and exposes named functions (e.g. add_Employee_data, view_all_Invoice_data, edit_Tanker_data) that the UI modules call directly.
The Six Core Entities
The system revolves around six primary tables that model the real-world actors and documents of a petrol pump.PetrolPump
Represents a physical petrol pump station. Stores the registration number, pump name, parent company, opening year, and location (state and city). Acts as the central anchor that employees and tankers reference via
Petrolpump_No.Owners
Tracks the individuals who own one or more petrol pumps. Each owner record includes name, contact number, date of birth, gender, address, and their partnership percentage. Linked to pumps through the
Owns relationship table.Employee
Stores workforce details including employee ID, name, gender, designation, date of birth, salary, address, email, the pump they work at (
Petrolpump_No), and their reporting manager (Manager_ID). Contact numbers are stored separately in the Contacts table.Customer
Captures customer information: a unique customer code, name, phone number, email, gender, city, and age. Customers are linked to invoices they generate and to the employees who serve them via the
Serves table.Invoice
Records each fuel transaction: invoice number, date, payment type (Cash/UPI/Card), fuel amount (litres), fuel type, optional discount, total price, and the customer code of the purchaser.
Tanker
Represents a fuel tanker that supplies a pump. Attributes include tanker ID, tank capacity, pressure, fuel ID, current fuel amount, fuel name, price per unit, and the pump it supplies (
Petrolpump_No).Supporting Tables
In addition to the six core entities, the database includes several supporting tables that capture relationships and operational data.| Table | Purpose |
|---|---|
Sales | Records daily nozzle readings, total sales volume, and sales amount for each pump. |
Owns | Composite relationship table linking PetrolPump and Owners (one pump can have multiple owners). |
Contacts | Stores one or more contact phone numbers per employee (multi-valued attribute). |
Serves | Junction table mapping which employees serve which customers. |
Sales_Manage | Links employees to the sales records they are responsible for managing. |
Key Capabilities
CRUD Operations across all entities — Every core entity exposes Add, View, Update, and Remove operations through the Streamlit sidebar. The UI collects form inputs and calls the correspondingdatabase.py function, which executes a parameterised SQL statement and commits the transaction.
Salary Guard Trigger — A MySQL trigger on the Employee table fires before any UPDATE on the Salary column. If the new salary value is below ₹300,000, the trigger prevents the update, protecting employees from accidental under-payment entries.
TOTAL_AMOUNT Stored Function — A user-defined MySQL function (TOTAL_AMOUNT) accepts a Tanker_ID and returns the computed total monetary value of fuel held in that tanker (Fuel_Amount × Fuel_Price). It is exposed in the UI under Query → Function, where the operator enters a tanker ID and clicks RUN Function to see the result in a DataFrame.
Custom SQL Runner — The Query → Custom Query panel in the sidebar provides a free-text input field. The operator can type any valid SQL statement, click Run Query, and see the raw result set rendered as a st.dataframe. This gives power users direct ad-hoc access to the database from within the web UI.
The database connection in
database.py is configured with host="localhost", user="root", and password="" (empty string). Before running the application, update these values to match your actual MySQL credentials. Using an empty root password is not recommended for production or shared environments.