# iyinoluwagideon/library-mvc architecture

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

- Interactive diagram: https://gitdiagram.com/iyinoluwagideon/library-mvc
- Repository: https://github.com/iyinoluwagideon/library-mvc

## Overview

Library MVC is a framework-free PHP/MySQL library application. A browser request enters the front controller, which configures the custom router and its routes; handlers perform authentication, catalog, borrowing, return, profile, and administrative work through models, while view controllers render pages. The README documents inventory, search, image uploads, and overdue fines. Some controller-to-model wiring is visible in the SOURCE INDEX rather than excerpts; links to unsampled subsystems are included only where routes or documented capabilities support them.

Main entry points: [`public/index.php`](https://github.com/iyinoluwagideon/library-mvc/blob/main/public/index.php) (Front controller), [`core/Router.php`](https://github.com/iyinoluwagideon/library-mvc/blob/main/core/Router.php) (Custom router), [`src/Controllers`](https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Controllers) (Account handlers), [`src/Models/Book.php`](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/Book.php) (Book and inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Request routing"]
  node_front["Front controller<br/>[index.php]"]
  node_router["Custom router<br/>[Router.php]"]
  node_dbconn["PDO connection<br/>[Database.php]"]
end

subgraph group_identity["Accounts and profiles"]
  node_identity_handlers["Account handlers"]
  node_identity_views["Account pages"]
  node_user_model["User model<br/>[User.php]"]
  node_profile_views["Profile views<br/>[userprofile.php]"]
end

subgraph group_catalog["Catalog and inventory"]
  node_catalog_handlers["Catalog handlers"]
  node_catalog_views["Catalog pages"]
  node_book_model["Book and inventory<br/>[Book.php]"]
  node_image_upload["Image upload helper<br/>[upload.php]"]
end

subgraph group_circulation["Borrowing and records"]
  node_circulation_handlers["Circulation handlers"]
  node_return_handler["Return handler<br/>[HandleReturn.php]"]
  node_borrow_model["Borrowing records<br/>[Borrow.php]"]
  node_dashboard["Dashboard and records<br/>[dashboard.php]"]
  node_user_records["User records page<br/>[userrecord.php]"]
end

node_visitor(("Library visitor"))
node_mysql[("MySQL database")]

node_visitor -->|"sends request"| node_front
node_front -->|"opens connection"| node_dbconn
node_front -->|"registers routes"| node_router
node_front -->|"dispatches request"| node_router
node_router -->|"dispatches account routes"| node_identity_handlers
node_router -->|"dispatches catalog routes"| node_catalog_handlers
node_router -->|"dispatches circulation routes"| node_circulation_handlers
node_dbconn -->|"connects PDO"| node_mysql
node_front -->|"creates with PDO"| node_user_model
node_front -->|"creates with PDO"| node_book_model
node_front -->|"creates with PDO"| node_borrow_model
node_identity_handlers -->|"uses account data"| node_user_model
node_identity_handlers -.->|"uploads profile image"| node_image_upload
node_identity_handlers -.->|"serves account pages"| node_identity_views
node_identity_handlers -->|"loads profile"| node_profile_views
node_catalog_handlers -->|"manages books"| node_book_model
node_catalog_handlers -->|"uploads book image"| node_image_upload
node_catalog_handlers -.->|"serves catalog pages"| node_catalog_views
node_circulation_handlers -->|"creates borrow record"| node_borrow_model
node_circulation_handlers -->|"checks availability"| node_book_model
node_return_handler -->|"updates return and fine"| node_borrow_model
node_return_handler -->|"restores inventory"| node_book_model
node_circulation_handlers -.->|"redirects after borrow"| node_dashboard
node_router -->|"renders dashboard"| node_dashboard
node_router -->|"routes records page"| node_user_records
node_book_model -->|"queries catalog"| node_mysql
node_borrow_model -->|"queries borrow records"| node_mysql
node_user_model -->|"queries users"| node_mysql

click node_front "https://github.com/iyinoluwagideon/library-mvc/blob/main/public/index.php"
click node_router "https://github.com/iyinoluwagideon/library-mvc/blob/main/core/Router.php"
click node_dbconn "https://github.com/iyinoluwagideon/library-mvc/blob/main/core/Database.php"
click node_identity_handlers "https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Controllers"
click node_identity_views "https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Views"
click node_user_model "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/User.php"
click node_profile_views "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Views/userprofile.php"
click node_catalog_handlers "https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Controllers"
click node_catalog_views "https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Views"
click node_book_model "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/Book.php"
click node_image_upload "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/helper/upload.php"
click node_circulation_handlers "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Controllers/HandleBorrowBook.php"
click node_return_handler "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Controllers/HandleReturn.php"
click node_borrow_model "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/Borrow.php"
click node_dashboard "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Views/dashboard.php"
click node_user_records "https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Views/userrecord.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_front,node_router,node_dbconn toneBlue
class node_identity_handlers,node_identity_views,node_user_model,node_profile_views,node_mysql toneAmber
class node_catalog_handlers,node_catalog_views,node_book_model,node_image_upload toneMint
class node_circulation_handlers,node_return_handler,node_borrow_model,node_dashboard,node_user_records toneRose
class node_visitor toneIndigo
```

## Components

### Request routing

- [Front controller](https://github.com/iyinoluwagideon/library-mvc/blob/main/public/index.php): `public/index.php`
- [Custom router](https://github.com/iyinoluwagideon/library-mvc/blob/main/core/Router.php): `core/Router.php`
- [PDO connection](https://github.com/iyinoluwagideon/library-mvc/blob/main/core/Database.php): `core/Database.php`

### Accounts and profiles

- [Account handlers](https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Controllers): `src/Controllers`
- [Account pages](https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Views): `src/Views`
- [User model](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/User.php): `src/Models/User.php`
- [Profile views](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Views/userprofile.php): `src/Views/userprofile.php`

### Catalog and inventory

- [Catalog handlers](https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Controllers): `src/Controllers`
- [Catalog pages](https://github.com/iyinoluwagideon/library-mvc/tree/main/src/Views): `src/Views`
- [Book and inventory](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/Book.php): `src/Models/Book.php`
- [Image upload helper](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/helper/upload.php): `src/helper/upload.php`

### Borrowing and records

- [Circulation handlers](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Controllers/HandleBorrowBook.php): `src/Controllers/HandleBorrowBook.php`
- [Return handler](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Controllers/HandleReturn.php): `src/Controllers/HandleReturn.php`
- [Borrowing records](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Models/Borrow.php): `src/Models/Borrow.php`
- [Dashboard and records](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Views/dashboard.php): `src/Views/dashboard.php`
- [User records page](https://github.com/iyinoluwagideon/library-mvc/blob/main/src/Views/userrecord.php): `src/Views/userrecord.php`

### Other components

- **Library visitor**
- **MySQL database**

## Connections

- Library visitor → Front controller: sends request (evidence: `public/index.php`)
- Front controller → PDO connection: opens connection (evidence: `public/index.php`)
- Front controller → Custom router: registers routes (evidence: `public/index.php`)
- Front controller → Custom router: dispatches request (evidence: `public/index.php`)
- Custom router → Account handlers: dispatches account routes (evidence: `core/Router.php`)
- Custom router → Catalog handlers: dispatches catalog routes (evidence: `core/Router.php`)
- Custom router → Circulation handlers: dispatches circulation routes (evidence: `core/Router.php`)
- PDO connection → MySQL database: connects PDO (evidence: `core/Database.php`)
- Front controller → User model: creates with PDO (evidence: `public/index.php`)
- Front controller → Book and inventory: creates with PDO (evidence: `public/index.php`)
- Front controller → Borrowing records: creates with PDO (evidence: `public/index.php`)
- Account handlers → User model: uses account data (evidence: `src/Controllers/HandleRegistration.php`)
- Account handlers → Image upload helper: uploads profile image (evidence: `src/Controllers/HandleEditProfile.php`)
- Account handlers → Account pages: serves account pages (evidence: `src/Controllers/ViewDashboard.php`)
- Account handlers → Profile views: loads profile (evidence: `src/Controllers/ViewUserProfile.php`)
- Catalog handlers → Book and inventory: manages books (evidence: `src/Controllers/HandleAddbook.php`)
- Catalog handlers → Image upload helper: uploads book image (evidence: `src/Controllers/HandleAddbook.php`)
- Catalog handlers → Catalog pages: serves catalog pages (evidence: `src/Controllers/ViewDashboard.php`)
- Circulation handlers → Borrowing records: creates borrow record (evidence: `src/Controllers/HandleBorrowBook.php`)
- Circulation handlers → Book and inventory: checks availability (evidence: `src/Controllers/HandleBorrowBook.php`)
- Return handler → Borrowing records: updates return and fine (evidence: `src/Controllers/HandleReturn.php`)
- Return handler → Book and inventory: restores inventory (evidence: `src/Controllers/HandleReturn.php`)
- Circulation handlers → Dashboard and records: redirects after borrow (evidence: `src/Controllers/HandleBorrowBook.php`)
- Custom router → Dashboard and records: renders dashboard (evidence: `core/Router.php`)
- Custom router → User records page: routes records page
- Book and inventory → MySQL database: queries catalog (evidence: `src/Models/Book.php`)
- Borrowing records → MySQL database: queries borrow records (evidence: `src/Models/Borrow.php`)
- User model → MySQL database: queries users (evidence: `src/Models/User.php`)
