# muhammadmahi585/nust-e-bill-system architecture

> Architecture diagram of the GitHub repository muhammadmahi585/nust-e-bill-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammadmahi585/nust-e-bill-system
- Repository: https://github.com/muhammadmahi585/nust-e-bill-system

## Overview

##### Project Type & Purpose
- This is a full-stack web application called “NUST E-Bill System” for managing electricity billing for residential and commercial users.
- Frontend: Static HTML/CSS/JS pages for landing, login, user dashboard, admin dashboard, billing pages, customer management pages, meter & tariff configuration.
- Backend: Node.js with Express.js serving routes, business-logic modules, and static assets.
- Database: MySQL storing users, bills, tariffs, meter readings.

##### File Structure Analysis
- Top-level web pages & assets (HTML, CSS, JS) alongside server.js and business modules (`tarrif.js`, `billLog.js`, `prevPage.js`, `customerPage.js`, `loginPage.js`).
- `node_modules`, `package.json` → Node.js/Express server.
- `images/` contains screenshots for documentation.
- Duplicate `NUST_EBill-master/` folder appears to mirror the same pages; treat it as an archive or legacy copy.
- No formal MVC folders, but each JS file under root acts as a controller/business logic for its corresponding page.

##### Key README Insights
- Role-based authentication (users vs. admins).
- Dynamic tariff calculations based on consumption.
- SQL integration for persisting user, billing, and tariff data.
- No external third-party services (e.g., payment gateways) are shown in code; payments may be managed in SQL or stubbed.

a. Main Components:
- Web Browser (Client)
- Frontend Static Layer
- Landing, Login, Customer, Bill Log, Admin Menu, Add/Update/Delete Customer, Meter, Tariff pages
- Backend Application Server (Express.js)
- Route handlers: `server.js`
- Business modules: `loginPage.js`, `customerPage.js`, `billLog.js`, `tarrif.js`, etc.
- MySQL Database
b. Relationships & Data Flow:
- Browser ←→ Static HTML/CSS/JS (client-side routing or form submits)
- Browser JS issues HTTP requests (GET/POST) to Express API endpoints
- Express routes invoke business modules → perform SQL queries → respond to client
c. Architectural Patterns:
- Layered architecture: Presentation (HTML/CSS/JS) → Application (Express routes + JS modules) → Data (MySQL)
- Role-based access control enforced in route middleware (implied by login module)
d. Key Technologies:
- Express.js for HTTP server & routing
- Node.js modules for each functional area
- MySQL for relational persistence
- Vanilla JavaScript for frontend interactivity

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client Side"
        Browser("Web Browser"):::frontend
        subgraph "Public UI"
            LP["Landing Page"]:::frontend
            LoginUI["Login Page"]:::frontend
        end
        subgraph "User UI"
            CustUI["Customer Dashboard"]:::frontend
            BillLogUI["Bill Log Page"]:::frontend
            RecordLogUI["Record Log Page"]:::frontend
        end
        subgraph "Admin UI"
            AdminMenu["Admin Dashboard"]:::frontend
            AddCust["Add Customer Page"]:::frontend
            DelCust["Delete Customer Page"]:::frontend
            UpdCust["Update Customer Page"]:::frontend
            MeterConf["Meter Config Page"]:::frontend
            TarrifConf["Tariff Config Page"]:::frontend
        end
    end

    subgraph "Backend (Express.js)"
        Server("Express Server<br/>(server.js)"):::backend
        subgraph "Controllers / Business Logic"
            AuthMod["Authentication Module<br/>(loginPage.js)"]:::backend
            CustMod["Customer Module<br/>(customerPage.js)"]:::backend
            BillMod["Billing Module<br/>(billLog.js)"]:::backend
            TarrifMod["Tariff Module<br/>(tarrif.js)"]:::backend
            NavMod["Navigation Helper<br/>(prevPage.js)"]:::backend
        end
    end

    DB("MySQL Database"):::database

    Browser -->|"loads HTML/CSS/JS"| LP
    Browser -->|"loads HTML/CSS/JS"| LoginUI
    Browser -->|"loads HTML/CSS/JS"| CustUI
    Browser -->|"loads HTML/CSS/JS"| BillLogUI
    Browser -->|"loads HTML/CSS/JS"| RecordLogUI
    Browser -->|"loads HTML/CSS/JS"| AdminMenu
    Browser -->|"loads HTML/CSS/JS"| AddCust
    Browser -->|"loads HTML/CSS/JS"| DelCust
    Browser -->|"loads HTML/CSS/JS"| UpdCust
    Browser -->|"loads HTML/CSS/JS"| MeterConf
    Browser -->|"loads HTML/CSS/JS"| TarrifConf

    LoginUI -->|"POST /login"| Server
    CustUI -->|"GET /customer"| Server
    BillLogUI -->|"GET /bills"| Server
    RecordLogUI -->|"POST /bills"| Server
    AdminMenu -->|"GET /admin"| Server
    AddCust -->|"POST /customer/add"| Server
    DelCust -->|"POST /customer/delete"| Server
    UpdCust -->|"POST /customer/update"| Server
    MeterConf -->|"GET/POST /meter"| Server
    TarrifConf -->|"GET/POST /tariff"| Server

    Server --> AuthMod
    Server --> CustMod
    Server --> BillMod
    Server --> TarrifMod
    Server --> NavMod

    AuthMod -->|"SQL Queries"| DB
    CustMod -->|"SQL Queries"| DB
    BillMod -->|"SQL Queries"| DB
    TarrifMod -->|"SQL Queries"| DB
    NavMod -->|"SQL Queries"| DB

    click LP "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//landingPage.html"
    click LP "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//landingStyle.css"
    click LP "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//landingScript.js"
    click LoginUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//loginPage.html"
    click LoginUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//loginStyle.css"
    click LoginUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//loginPage.js"
    click CustUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//customerPage.html"
    click CustUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//customerStyle.css"
    click CustUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//customerPage.js"
    click AdminMenu "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//adminMenuPage.html"
    click AdminMenu "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//adminMenuStyle.css"
    click AddCust "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//addCuctomerPage.html"
    click AddCust "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//addCustomerStyle.css"
    click DelCust "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//deleteCustomerPage.html"
    click DelCust "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//deleteCustomerPage.css"
    click UpdCust "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//updateCustomerPage.html"
    click BillLogUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//billLogPage.html"
    click BillLogUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//billLogStyle.css"
    click BillLogUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//billLog.js"
    click RecordLogUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//recordLogPage.html"
    click RecordLogUI "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//recordLogStyle.css"
    click MeterConf "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//meterPage.html"
    click MeterConf "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//meterStyle.css"
    click TarrifConf "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//terrifPage.html"
    click TarrifConf "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//terrifStyle.css"
    click NavMod "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//prevPage.js"
    click Server "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//server.js"
    click AuthMod "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//loginPage.js"
    click CustMod "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//customerPage.js"
    click BillMod "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//billLog.js"
    click TarrifMod "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//tarrif.js"
    click DB "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//EBS.erd"
    click DB "https://github.com/muhammadmahi585/nust-e-bill-system/tree/main//node_modules/"
    click DB "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//package.json"
    click DB "https://github.com/muhammadmahi585/nust-e-bill-system/blob/main//package-lock.json"

    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef backend fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef database fill:#ffe0b2,stroke:#fb8c00,color:#e65100
```
