Skip to main content

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.

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.

Tech Stack

LayerTechnology
Frontend / UIStreamlit — Python-native web app framework
DatabaseMySQL 8.0+ — relational storage with InnoDB engine
DB Drivermysql-connector-python — official MySQL connector for Python
Data Displaypandas — DataFrames used to render query results
LanguagePython 3.8+

High-Level Architecture

The application is split into two top-level directories. The Project/ directory holds all Python source files; Backend/ holds the raw SQL scripts used to provision the schema.
PetrolPump-Management-System/
├── Project/
│   ├── app.py              # Streamlit entry point
│   ├── database.py         # All DB functions
│   ├── create.py           # Add record UI logic
│   ├── read.py             # View records UI logic
│   ├── update.py           # Edit records UI logic
│   ├── delete.py           # Delete records UI logic
│   └── Create_database.py  # One-time DB provisioning
└── Backend/
    ├── create_table.sql    # Table DDL + seed data
    ├── relation.sql        # Foreign key constraints
    └── querry.sql          # Joins, triggers, functions, procedures
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.
TablePurpose
SalesRecords daily nozzle readings, total sales volume, and sales amount for each pump.
OwnsComposite relationship table linking PetrolPump and Owners (one pump can have multiple owners).
ContactsStores one or more contact phone numbers per employee (multi-valued attribute).
ServesJunction table mapping which employees serve which customers.
Sales_ManageLinks 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 corresponding database.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.

Build docs developers (and LLMs) love