# adarsh275/petrolpump-management-system architecture

> Architecture diagram of the GitHub repository adarsh275/petrolpump-management-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/adarsh275/petrolpump-management-system
- Repository: https://github.com/adarsh275/petrolpump-management-system

## Overview

##### Project type and purpose
- This is a full-stack, database-driven web application called “PetrolPump-Management-System,” implemented in Python with a Streamlit front end and a MySQL back end, providing CRUD (Create, Read, Update, Delete) operations on petrol-pump related tables.

##### File structure
- Top-level directories and files:
- Backend/ — raw SQL scripts for table creation, data population, and relationships (create_table.sql, querry.sql, relation.sql)
- Project/ — Python application code for database setup (create_database.py), Streamlit UI (app.py), and module files for CRUD logic (create.py, read.py, update.py, delete.py, database.py)
- Design & Architecture/ — (presumably holds architecture docs or sketches)
- README.md, LICENSE, Report/ — ancillary documentation
- Patterns:
- Three-tier separation: Presentation (app.py/Streamlit), Business Logic (database.py + CRUD modules), Data Definition (SQL scripts + MySQL)
- Triggers and user-defined functions exist inside the DB layer (trigger on salary update, function to calculate total price).

##### Extract insights from the README
- Front end: Streamlit, leverages pandas, NumPy, etc., to display tables and accept user input
- Back end: Python scripts use mysql-connector and Pandas, SQL scripts for initial schema/data
- Operation flow: run create_database.py → install dependencies → run “streamlit run app.py”

##### Main components and their relationships
a. Presentation Tier
- Streamlit App (app.py) – the UI layer users interact with in a browser
b. Application/Business Logic Tier
- database.py – abstraction layer over MySQL connector, exposes generic query methods
- CRUD modules (create.py, read.py, update.py, delete.py) – implement specific table operations, call database.py
c. Data Tier
- MySQL Database “Petrolpump_Management”
– Tables created by Backend/*.sql and create_database.py
– a SQL trigger on Employee.salary (enforces minimum salary of 300,000)
– a user-defined function to compute TotalPrice in Tanker table
d. External services/libraries
- MySQL Server
- Python libs: streamlit, pandas, mysql-connector-python

##### Architectural patterns/design principles
- Three-tier architecture (UI, logic, data)
- Single responsibility: each CRUD module handles one type of DB operation
- Loose coupling: Streamlit UI calls high-level functions rather than embedding SQL
- DB-centric business rules: triggers and functions enforce constraints at the data layer

##### Tooling recommendations
- Export to PNG/PDF and include in “Design & Architecture” folder alongside code

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External User
    User["User (Browser)"]:::external

    %% Presentation Tier
    subgraph "Presentation Tier"
        UI["Streamlit UI (app.py)"]:::frontend
    end

    %% Business Logic Tier
    subgraph "Business Logic Tier"
        DAL["database.py (DAL)"]:::logic
        Create["Create Module (create.py)"]:::logic
        Read["Read Module (read.py)"]:::logic
        Update["Update Module (update.py)"]:::logic
        Delete["Delete Module (delete.py)"]:::logic
    end

    %% Database Tier
    subgraph "Database Tier"
        DB[(MySQL DB: Petrolpump_Management)]:::data
        Trigger["Salary Trigger"]:::data
        UDF["TotalPrice UDF"]:::data
    end

    %% Initialization & Schema
    subgraph "Initialization & Schema Definition"
        Init["Database Init (Create_database.py)"]:::logic
        SQL1["create_table.sql"]:::data
        SQL2["querry.sql"]:::data
        SQL3["relation.sql"]:::data
    end

    %% Documentation
    subgraph "Documentation & Misc"
        Docs1["Design & Architecture/"]:::docs
        Docs2["README.md"]:::docs
        Docs3["Report/Final_Report.docx"]:::docs
        Docs4["LICENSE"]:::docs
    end

    %% Flow Connections
    User --> UI
    UI -->|creates/reads/updates/deletes| Create
    UI -->|creates/reads/updates/deletes| Read
    UI -->|creates/reads/updates/deletes| Update
    UI -->|creates/reads/updates/deletes| Delete

    Create --> DAL
    Read --> DAL
    Update --> DAL
    Delete --> DAL

    DAL -->|SQL queries| DB
    DB -->|enforces| Trigger
    DB -->|calculates| UDF
    DB -->|responses| DAL

    Init --> SQL1
    Init --> SQL2
    Init --> SQL3

    SQL1 --> DB
    SQL2 --> DB
    SQL3 --> DB

    %% Click Events
    click UI "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/app.py"
    click DAL "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/database.py"
    click Create "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/create.py"
    click Read "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/read.py"
    click Update "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/update.py"
    click Delete "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/delete.py"
    click Init "https://github.com/adarsh275/petrolpump-management-system/blob/main/Project/Create_database.py"
    click SQL1 "https://github.com/adarsh275/petrolpump-management-system/blob/main/Backend/create_table.sql"
    click SQL2 "https://github.com/adarsh275/petrolpump-management-system/blob/main/Backend/querry.sql"
    click SQL3 "https://github.com/adarsh275/petrolpump-management-system/blob/main/Backend/relation.sql"
    click Docs1 "https://github.com/adarsh275/petrolpump-management-system/tree/main/Design & Architecture/"
    click Docs2 "https://github.com/adarsh275/petrolpump-management-system/blob/main/README.md"
    click Docs3 "https://github.com/adarsh275/petrolpump-management-system/blob/main/Report/Final_Report.docx"
    click Docs4 "https://github.com/adarsh275/petrolpump-management-system/tree/main/LICENSE"

    %% Styles
    classDef frontend fill:#E3F2FD,stroke:#1E88E5,color:#0D47A1
    classDef logic fill:#E8F5E9,stroke:#43A047,color:#1B5E20
    classDef data fill:#FFF3E0,stroke:#FB8C00,color:#E65100
    classDef docs fill:#ECEFF1,stroke:#607D8B,color:#263238
    classDef external fill:#F3E5F5,stroke:#8E24AA,color:#4A148C
```
