# chittun1810/library-book-management-system architecture

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

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

## Overview

##### Main Components
a. Client Layer
- Web Browser or API Consumer (e.g., Postman)
b. Presentation / Web Server
- Nginx or Apache (serving static assets from `/public`)
- PHP-FPM (executes Laravel)
c. Application Layer (Laravel MVC)
- HTTP Kernel & Middleware (authentication, rate-limiting, input sanitization)
- Routing (`routes/web.php` for Blade views, `routes/api.php` for JSON APIs)
- Controllers (e.g., `BookController`, `UserController`)
- Form Requests (validation classes under `app/Http/Requests`)
- Models & Eloquent ORM (`app/Models`, relationships to `books`, `authors`, `borrow_records`, `users`)
- Enums & Helpers (`app/Enums`, `app/Helpers/Response.php`)
- Service Providers (bootstrapping in `app/Providers`)
d. Persistence Layer
- Relational Database (MySQL/PostgreSQL) accessed via Eloquent
- Database Migrations & Seeders (`database/migrations`, `database/seeders`)
- Factories for testing (`database/factories`)
e. Infrastructure & Supporting Services
- Cache & Session Store (filesystem or Redis configured in `config/cache.php`, `config/session.php`)
- Queue / Jobs (database or Redis queues)
- Mail Service (SMTP or third-party via `config/mail.php`)
- File Storage (`storage/app/public`, local or S3 via `config/filesystems.php`)
f. Asset Pipeline
- Vite for compiling JS/CSS (`vite.config.js`, `resources/js`, `resources/css`)
g. CI/CD
- GitHub Actions workflows (`.github/workflows/laravel.yml`, `test.yml`)

##### Component Interactions and Data Flows
- Browser → HTTP Request → Web Server (Nginx/Apache) → PHP-FPM
- PHP-FPM → Laravel Kernel → Selected Middleware → Router → Controller
- Controller → Validate via Form Request → Interact with Eloquent Models → Query/Update Database
- Controller → Return Response (Blade View or JSON) → PHP-FPM → Web Server → Browser
- Events / Jobs dispatched by Controllers → Queue Backend → Worker → Business Logic → DB/Cache/Mail
- Asset Requests (CSS/JS/images) served directly from `/public` or via Vite dev server in development

##### Architectural Patterns & Principles
- MVC (Model-View-Controller) separation
- RESTful resource controllers (`AuthorController`, `BookController`, etc.)
- Layered architecture (presentation / application / domain / infrastructure)
- Dependency injection (via Service Providers)
- Single Responsibility (form requests isolate validation, helpers isolate common logic)
- Convention-over-configuration (Laravel folder conventions)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"  
        direction TB
        Browser["Web Browser / API Consumer"]:::client
    end

    %% Presentation Layer
    subgraph "Presentation Layer"  
        direction TB
        WebServer["Nginx / Apache"]:::presentation
        PHPFPM["PHP-FPM"]:::presentation
    end

    %% Laravel Application
    subgraph "Laravel Application"
        direction TB
        subgraph "HTTP Layer"
            direction TB
            Kernel["HTTP Kernel"]:::app
            Middleware["Middleware (Auth, Rate Limit)"]:::app
            RouterWeb["Router (routes/web.php)"]:::app
            RouterAPI["Router (routes/api.php)"]:::app
        end
        subgraph "Business Layer"
            direction TB
            Controllers["Controllers"]:::app
            FormRequests["Form Requests"]:::app
            Helpers["Helpers & Enums"]:::app
            ServiceProviders["Service Providers"]:::app
        end
        subgraph "Data Layer"
            direction TB
            Models["Eloquent Models"]:::app
        end
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        Database["Relational DB (MySQL/PostgreSQL)"]:::database
        Migrations["Migrations & Seeders"]:::database
        Factories["Factories"]:::database
    end

    %% Infrastructure & Supporting Services
    subgraph "Infrastructure & Supporting Services"
        direction TB
        Cache["Cache / Session Store"]:::infra
        Queue["Queue / Jobs"]:::infra
        Mail["Mail Service"]:::infra
        Storage["File Storage"]:::infra
    end

    %% Asset Pipeline
    subgraph "Asset Pipeline"
        direction TB
        Vite["Vite"]:::pipeline
        Assets["JS/CSS Assets"]:::pipeline
    end

    %% CI/CD
    subgraph "CI/CD"
        direction TB
        Workflows["GitHub Actions"]:::cicd
    end

    %% Connections
    Browser -->|HTTP Request| WebServer
    WebServer -->|Pass to| PHPFPM
    PHPFPM -->|Boot| Kernel
    Kernel -->|Process| Middleware
    Middleware -->|Route| RouterWeb
    Middleware -->|Route| RouterAPI
    RouterWeb --> Controllers
    RouterAPI --> Controllers
    Controllers -->|Validate| FormRequests
    Controllers -->|Use| ServiceProviders
    Controllers -->|Call| Models
    Models -->|Query/Update| Database
    Controllers -->|Dispatch| Queue
    Controllers -->|Send Email| Mail
    Controllers -->|Store Files| Storage
    Vite -->|Compile| Assets
    Assets -->|Serve| WebServer
    Workflows -->|Deploy| WebServer

    %% Click Events
    click WebServer "https://github.com/chittun1810/library-book-management-system/blob/main/public/index.php"
    click WebServer "https://github.com/chittun1810/library-book-management-system/blob/main/public/.htaccess"
    click RouterWeb "https://github.com/chittun1810/library-book-management-system/blob/main/routes/web.php"
    click RouterAPI "https://github.com/chittun1810/library-book-management-system/blob/main/routes/api.php"
    click Kernel "https://github.com/chittun1810/library-book-management-system/blob/main/bootstrap/app.php"
    click Middleware "https://github.com/chittun1810/library-book-management-system/tree/main/app/Http/Middleware"
    click Controllers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Controllers/AuthorController.php"
    click Controllers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Controllers/BookController.php"
    click Controllers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Controllers/BorrowRecordController.php"
    click Controllers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Controllers/UserController.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/BorrowBookRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/CreateLibrarianRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/LoginRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/SearchBookRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/StoreAuthorRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/StoreBookRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/StoreUserRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/UpdateAuthorRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/UpdateBookRequest.php"
    click FormRequests "https://github.com/chittun1810/library-book-management-system/blob/main/app/Http/Requests/UpdateUserRequest.php"
    click Models "https://github.com/chittun1810/library-book-management-system/blob/main/app/Models/Author.php"
    click Models "https://github.com/chittun1810/library-book-management-system/blob/main/app/Models/Book.php"
    click Models "https://github.com/chittun1810/library-book-management-system/blob/main/app/Models/BorrowRecord.php"
    click Models "https://github.com/chittun1810/library-book-management-system/blob/main/app/Models/User.php"
    click Helpers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Enums/BookStatus.php"
    click Helpers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Enums/UserRole.php"
    click Helpers "https://github.com/chittun1810/library-book-management-system/blob/main/app/Helpers/Response.php"
    click ServiceProviders "https://github.com/chittun1810/library-book-management-system/blob/main/app/Providers/AppServiceProvider.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/0001_01_01_000000_create_users_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/0001_01_01_000001_create_cache_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/0001_01_01_000002_create_jobs_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/2024_09_06_184807_create_personal_access_tokens_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/2024_09_06_184859_create_books_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/2024_09_06_184900_create_authors_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/migrations/2024_09_06_184902_create_borrow_records_table.php"
    click Migrations "https://github.com/chittun1810/library-book-management-system/blob/main/database/seeders/DatabaseSeeder.php"
    click Factories "https://github.com/chittun1810/library-book-management-system/blob/main/database/factories/AuthorFactory.php"
    click Factories "https://github.com/chittun1810/library-book-management-system/blob/main/database/factories/BookFactory.php"
    click Factories "https://github.com/chittun1810/library-book-management-system/blob/main/database/factories/BorrowRecordFactory.php"
    click Factories "https://github.com/chittun1810/library-book-management-system/blob/main/database/factories/UserFactory.php"
    click Cache "https://github.com/chittun1810/library-book-management-system/blob/main/config/cache.php"
    click Cache "https://github.com/chittun1810/library-book-management-system/blob/main/config/session.php"
    click Queue "https://github.com/chittun1810/library-book-management-system/blob/main/config/queue.php"
    click Mail "https://github.com/chittun1810/library-book-management-system/blob/main/config/mail.php"
    click Storage "https://github.com/chittun1810/library-book-management-system/blob/main/config/filesystems.php"
    click Vite "https://github.com/chittun1810/library-book-management-system/blob/main/vite.config.js"
    click Assets "https://github.com/chittun1810/library-book-management-system/blob/main/resources/js/app.js"
    click Assets "https://github.com/chittun1810/library-book-management-system/blob/main/resources/js/bootstrap.js"
    click Assets "https://github.com/chittun1810/library-book-management-system/blob/main/resources/css/app.css"
    click Workflows "https://github.com/chittun1810/library-book-management-system/blob/main/.github/workflows/laravel.yml"
    click Workflows "https://github.com/chittun1810/library-book-management-system/blob/main/.github/workflows/test.yml"

    %% Styles
    classDef client fill:#AED6F1,stroke:#1B4F72,color:#1B2631
    classDef presentation fill:#ABEBC6,stroke:#196F3D,color:#1B2631
    classDef app fill:#F9E79F,stroke:#B7950B,color:#1B2631
    classDef database fill:#D2B4DE,stroke:#6C3483,color:#1B2631
    classDef infra fill:#D5D8DC,stroke:#2C3E50,color:#1B2631
    classDef pipeline fill:#FAD7A0,stroke:#CA6F1E,color:#1B2631
    classDef cicd fill:#F5B7B1,stroke:#922B21,color:#1B2631
```
