# devil7645/library-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/devil7645/library-management-system
- Repository: https://github.com/devil7645/library-management-system

## Overview

##### Project type and purpose
- This is a monolithic, full‑stack PHP web application called “Library‑Management‑System.”
- It provides user login/signup, an admin dashboard for managing books (add, delete, export CSV), and a user dashboard.

##### File structure
- Top‑level entry‑points (index.php, login.php, dashboard.php, logout.php) act as controllers/views.
- includes/ holds shared modules: db.php (data‑access), auth.php (session check), header/footer templates.
- admin/ is a sub‑area for admin pages, actions, and assets.
- assets/ contains CSS/JS for styling and behavior; static files served directly.
- actions/ and admin/actions/ contain form handlers (login_action.php, signup_action.php, add_book_action.php, etc.).
- LMS_db.sql is the MySQL schema.

##### README for insights
- The README confirms the simple MVC‑style layering:
- Views: .php pages
- Controllers: entry‑point pages + action scripts
- Model: db.php, MySQL schema
- No external third‑party services beyond the database.

a. Client (Web Browser with HTML/CSS/JS)
b. Web Server + PHP Engine
- Router/Entry Points (index.php, login.php, etc.)
- Controllers/Actions (actions/*.php, admin/actions/*.php)
- View Templates (includes/header.php, footer.php, admin/includes/*)
- Data Access Layer (includes/db.php)
c. Database Server (MySQL using LMS_db.sql)
d. Static Asset Store (assets/css, assets/js, admin/assets)
e. Optional: CSV export module (exportCSV_books.php)

##### Relationships & data flows
- Browser → HTTP request → Web Server/PHP
- If it’s a form submit: routed to an action script → includes/db.php → MySQL
- On page loads: entry‑point .php loads includes/auth.php → queries DB → renders header, footer, page template → HTML back to browser
- Browser loads CSS/JS from assets directories (static GET requests)
- Admin area separated by URL path (e.g., /admin/*) guarded by auth.php

##### Architectural patterns & design principles
- Layered MVC style:
- Presentation: .php views + HTML/CSS/JS
- Business logic: action scripts
- Data access: single db.php
- DRY via includes for headers, footers, auth checks
- Single‑database monolith—no microservices

##### Technologies & frameworks
- PHP 7+ (server‑side scripting)
- MySQL (relational database)
- Apache/Nginx (web server)
- HTML5/CSS3, vanilla JavaScript
- CSV export via PHP file output

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    subgraph "Client"
        Browser["Web Browser"]:::frontend
    end

    %% Static Asset Store
    subgraph "Static Asset Store"
        assets_css["assets/css/"]:::assets
        assets_js["assets/js/"]:::assets
        admin_assets_css["admin/assets/css/"]:::assets
        admin_assets_js["admin/assets/js/"]:::assets
    end

    %% Web Server & PHP Engine
    subgraph "Web Server & PHP Engine"
        subgraph "Entry-Point Controllers"
            index_html["index.html"]:::server
            about_php["about.php"]:::server
            login_php["login.php"]:::server
            logout_php["logout.php"]:::server
            dashboard_php["dashboard.php"]:::server
            member_php["member.php"]:::server
            admin_index_php["admin/index.php"]:::server
            admin_add_books_php["admin/add_books.php"]:::server
            admin_book_details_php["admin/book_details.php"]:::server
            admin_manage_books_php["admin/manage-books.php"]:::server
            admin_setup_php["admin/setup.php"]:::server
        end
        subgraph "Action Handlers"
            add_book_action_php["admin/actions/add_book_action.php"]:::server
            delete_books_php["admin/actions/delete_books.php"]:::server
            exportCSV_books_php["admin/actions/exportCSV_books.php"]:::server
        end
        subgraph "Shared Includes"
            includes_db_php["includes/db.php"]:::server
            includes_auth_php["includes/auth.php"]:::server
            admin_includes_header_php["admin/includes/header.php"]:::server
            admin_includes_footer_php["admin/includes/footer.php"]:::server
            admin_includes_sidebar_php["admin/includes/sidebar.php"]:::server
        end
    end

    %% Database Server
    subgraph "Database Server"
        MySQL["MySQL Database"]:::db
        LMS_db_sql["LMS_db.sql"]:::db
    end

    %% Technologies Note
    Tech["Technologies:\n• PHP 7+\n• MySQL\n• Apache/Nginx\n• HTML5/CSS3\n• JavaScript"]:::note

    %% Flows
    Browser -->|"HTTP GET/POST"| index_html
    Browser -->|"HTTP GET/POST"| about_php
    Browser -->|"HTTP GET/POST"| login_php
    Browser -->|"HTTP GET/POST"| logout_php
    Browser -->|"HTTP GET/POST"| dashboard_php
    Browser -->|"HTTP GET/POST"| member_php
    Browser -->|"HTTP GET/POST"| admin_index_php
    Browser -->|"HTTP GET/POST"| admin_add_books_php
    Browser -->|"HTTP GET/POST"| admin_book_details_php
    Browser -->|"HTTP GET/POST"| admin_manage_books_php
    Browser -->|"HTTP GET/POST"| admin_setup_php

    index_html -->|"includes auth"| includes_auth_php
    admin_index_php -->|"includes auth"| includes_auth_php
    index_html -->|"SQL Query"| includes_db_php
    includes_db_php -->|"SQL"| MySQL
    includes_auth_php -->|"session check"| MySQL

    Browser -->|"POST /action"| add_book_action_php
    Browser -->|"POST /action"| delete_books_php
    Browser -->|"POST /action"| exportCSV_books_php

    add_book_action_php -->|"SQL"| includes_db_php
    delete_books_php -->|"SQL"| includes_db_php
    exportCSV_books_php -->|"SQL"| includes_db_php
    exportCSV_books_php -->|"CSV Response"| Browser

    Browser -->|"GET CSS/JS"| assets_css
    Browser -->|"GET CSS/JS"| assets_js
    Browser -->|"GET CSS/JS"| admin_assets_css
    Browser -->|"GET CSS/JS"| admin_assets_js

    %% Click Events
    click assets_css "https://github.com/devil7645/library-management-system/tree/main/assets/css/"
    click assets_js "https://github.com/devil7645/library-management-system/tree/main/assets/js/"
    click admin_assets_css "https://github.com/devil7645/library-management-system/tree/main/admin/assets/css/"
    click admin_assets_js "https://github.com/devil7645/library-management-system/tree/main/admin/assets/js/"
    click index_html "https://github.com/devil7645/library-management-system/blob/main/index.html"
    click about_php "https://github.com/devil7645/library-management-system/blob/main/about.php"
    click login_php "https://github.com/devil7645/library-management-system/blob/main/login.php"
    click logout_php "https://github.com/devil7645/library-management-system/blob/main/logout.php"
    click dashboard_php "https://github.com/devil7645/library-management-system/blob/main/dashboard.php"
    click member_php "https://github.com/devil7645/library-management-system/blob/main/member.php"
    click admin_index_php "https://github.com/devil7645/library-management-system/blob/main/admin/index.php"
    click admin_add_books_php "https://github.com/devil7645/library-management-system/blob/main/admin/add_books.php"
    click admin_book_details_php "https://github.com/devil7645/library-management-system/blob/main/admin/book_details.php"
    click admin_manage_books_php "https://github.com/devil7645/library-management-system/blob/main/admin/manage-books.php"
    click admin_setup_php "https://github.com/devil7645/library-management-system/blob/main/admin/setup.php"
    click add_book_action_php "https://github.com/devil7645/library-management-system/blob/main/admin/actions/add_book_action.php"
    click delete_books_php "https://github.com/devil7645/library-management-system/blob/main/admin/actions/delete_books.php"
    click exportCSV_books_php "https://github.com/devil7645/library-management-system/blob/main/admin/actions/exportCSV_books.php"
    click includes_db_php "https://github.com/devil7645/library-management-system/blob/main/includes/db.php"
    click includes_auth_php "https://github.com/devil7645/library-management-system/blob/main/includes/auth.php"
    click admin_includes_header_php "https://github.com/devil7645/library-management-system/blob/main/admin/includes/header.php"
    click admin_includes_footer_php "https://github.com/devil7645/library-management-system/blob/main/admin/includes/footer.php"
    click admin_includes_sidebar_php "https://github.com/devil7645/library-management-system/blob/main/admin/includes/sidebar.php"
    click LMS_db_sql "https://github.com/devil7645/library-management-system/blob/main/LMS_db.sql"

    %% Styles
    classDef frontend fill:#D6EAF8,stroke:#1B4F72,color:#1B2631
    classDef server fill:#D5F5E3,stroke:#196F3D,color:#145A32
    classDef db fill:#FAD7A0,stroke:#B9770E,color:#784212
    classDef assets fill:#FCF3CF,stroke:#B7950B,color:#7D6608
    classDef note fill:#E5E7E9,stroke:#A6ACAF,color:#1C2833
```
