# davidquicoc/biblioteca_mvc_coding architecture

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

- Interactive diagram: https://gitdiagram.com/davidquicoc/biblioteca_mvc_coding
- Repository: https://github.com/davidquicoc/biblioteca_mvc_coding

## Overview

Biblioteca_MVC_coding is a PHP MVC library-management application for user registration and login, book CRUD, loans and returns, and a dashboard of library and user-loan statistics. The main workflow starts at the front controller, routes an action to a controller, uses models for database operations, and renders a view; loan actions also update book availability. The README documents the CRUD domains, while the sampled source confirms routing and much of the runtime flow. Prestamo model and some views are indexed but not sampled, so their internal behavior is not expanded.

Main entry points: [`controllers/PrestamoController.php`](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/PrestamoController.php) (Loan controller), [`core/router.php`](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/core/router.php) (Action router), [`controllers/BookController.php`](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/BookController.php) (Book controller), [`models/Libro.php`](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Libro.php) (Book model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Application Core"]
  node_entry["Front controller<br/>[index.php]"]
  node_router["Action router<br/>[router.php]"]
  node_session["Session helpers<br/>[session.php]"]
  node_config["DB connection<br/>[config.php]"]
  node_dashboardctl["Dashboard controller"]
end

subgraph group_auth["Authentication"]
  node_authctl["Auth controller<br/>[AuthController.php]"]
  node_user_model["User model<br/>[Usuario.php]"]
end

subgraph group_catalog["Book Catalog"]
  node_bookctl["Book controller<br/>[BookController.php]"]
  node_book_model["Book model<br/>[Libro.php]"]
end

subgraph group_loans["Loan Management"]
  node_loanctl["Loan controller"]
  node_loan_model["Loan model<br/>[Prestamo.php]"]
end

subgraph group_ui["Views"]
  node_login_view["Login view<br/>[login.php]"]
  node_register_view["Registration view<br/>[register.php]"]
  node_book_list["Book list view<br/>[index.php]"]
  node_book_create["Book creation view<br/>[create.php]"]
  node_book_edit["Book edit view<br/>[edit.php]"]
  node_loan_view["Loan view<br/>[index.php]"]
  node_dashboard_view["Dashboard view<br/>[index.php]"]
  node_header["Shared header<br/>[header.php]"]
  node_footer["Shared footer<br/>[footer.php]"]
end

node_user(("Library user"))
node_database[("Biblioteca database")]

node_user -->|"requests pages"| node_entry
node_entry -->|"starts session"| node_session
node_entry -->|"loads routes"| node_router
node_router -->|"dispatches auth"| node_authctl
node_router -->|"dispatches books"| node_bookctl
node_router -->|"dispatches loans"| node_loanctl
node_router -->|"dispatches default"| node_dashboardctl
node_router -->|"loads helpers"| node_session
node_authctl -->|"checks or saves"| node_user_model
node_authctl -->|"renders login"| node_login_view
node_authctl -->|"renders registration"| node_register_view
node_bookctl -->|"requires login"| node_session
node_bookctl -->|"performs CRUD"| node_book_model
node_bookctl -->|"renders list"| node_book_list
node_bookctl -->|"renders form"| node_book_create
node_bookctl -->|"renders form"| node_book_edit
node_loanctl -->|"requires login"| node_session
node_loanctl -->|"loads users"| node_user_model
node_loanctl -->|"checks availability"| node_book_model
node_loanctl -->|"records loan"| node_loan_model
node_loanctl -->|"updates availability"| node_book_model
node_loanctl -->|"renders loans"| node_loan_view
node_loan_view -->|"submits loan actions"| node_user
node_dashboardctl -->|"loads book stats"| node_book_model
node_dashboardctl -->|"counts users"| node_user_model
node_dashboardctl -->|"loads loan stats"| node_loan_model
node_dashboardctl -->|"renders dashboard"| node_dashboard_view
node_dashboard_view -->|"includes header"| node_header
node_dashboard_view -->|"includes footer"| node_footer
node_book_model -->|"loads connection"| node_config
node_user_model -->|"loads connection"| node_config
node_loan_model -->|"loads connection"| node_config
node_config -->|"opens connection"| node_database
node_book_model -->|"queries books"| node_database
node_user_model -->|"queries users"| node_database
node_loan_model -.->|"queries loans"| node_database

click node_entry "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/index.php"
click node_router "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/core/router.php"
click node_session "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/core/session.php"
click node_config "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/config/config.php"
click node_authctl "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/AuthController.php"
click node_user_model "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Usuario.php"
click node_login_view "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/auth/login.php"
click node_register_view "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/auth/register.php"
click node_bookctl "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/BookController.php"
click node_book_model "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Libro.php"
click node_book_list "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/libros/index.php"
click node_book_create "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/libros/create.php"
click node_book_edit "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/libros/edit.php"
click node_loanctl "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/PrestamoController.php"
click node_loan_model "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Prestamo.php"
click node_loan_view "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/prestamos/index.php"
click node_dashboardctl "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/DashboardController.php"
click node_dashboard_view "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/index.php"
click node_header "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/layout/header.php"
click node_footer "https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/layout/footer.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_entry,node_router,node_session,node_config,node_dashboardctl,node_user toneBlue
class node_authctl,node_user_model,node_database toneAmber
class node_bookctl,node_book_model toneMint
class node_loanctl,node_loan_model toneRose
class node_login_view,node_register_view,node_book_list,node_book_create,node_book_edit,node_loan_view,node_dashboard_view,node_header,node_footer toneIndigo
```

## Components

### Application Core

- [Front controller](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/index.php): `index.php`
- [Action router](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/core/router.php): `core/router.php`
- [Session helpers](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/core/session.php): `core/session.php`
- [DB connection](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/config/config.php): `config/config.php`
- [Dashboard controller](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/DashboardController.php): `controllers/DashboardController.php`

### Authentication

- [Auth controller](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/AuthController.php): `controllers/AuthController.php`
- [User model](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Usuario.php): `models/Usuario.php`

### Book Catalog

- [Book controller](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/BookController.php): `controllers/BookController.php`
- [Book model](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Libro.php): `models/Libro.php`

### Loan Management

- [Loan controller](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/controllers/PrestamoController.php): `controllers/PrestamoController.php`
- [Loan model](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/models/Prestamo.php): `models/Prestamo.php`

### Views

- [Login view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/auth/login.php): `views/auth/login.php`
- [Registration view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/auth/register.php): `views/auth/register.php`
- [Book list view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/libros/index.php): `views/libros/index.php`
- [Book creation view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/libros/create.php): `views/libros/create.php`
- [Book edit view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/libros/edit.php): `views/libros/edit.php`
- [Loan view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/prestamos/index.php): `views/prestamos/index.php`
- [Dashboard view](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/index.php): `views/index.php`
- [Shared header](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/layout/header.php): `views/layout/header.php`
- [Shared footer](https://github.com/davidquicoc/biblioteca_mvc_coding/blob/main/views/layout/footer.php): `views/layout/footer.php`

### Other components

- **Library user**
- **Biblioteca database**

## Connections

- Library user → Front controller: requests pages (evidence: `index.php`)
- Front controller → Session helpers: starts session (evidence: `index.php`)
- Front controller → Action router: loads routes (evidence: `index.php`)
- Action router → Auth controller: dispatches auth (evidence: `core/router.php`)
- Action router → Book controller: dispatches books (evidence: `core/router.php`)
- Action router → Loan controller: dispatches loans (evidence: `core/router.php`)
- Action router → Dashboard controller: dispatches default (evidence: `core/router.php`)
- Action router → Session helpers: loads helpers (evidence: `core/router.php`)
- Auth controller → User model: checks or saves (evidence: `controllers/AuthController.php`)
- Auth controller → Login view: renders login (evidence: `controllers/AuthController.php`)
- Auth controller → Registration view: renders registration (evidence: `controllers/AuthController.php`)
- Book controller → Session helpers: requires login (evidence: `controllers/BookController.php`)
- Book controller → Book model: performs CRUD (evidence: `controllers/BookController.php`)
- Book controller → Book list view: renders list (evidence: `controllers/BookController.php`)
- Book controller → Book creation view: renders form (evidence: `controllers/BookController.php`)
- Book controller → Book edit view: renders form (evidence: `controllers/BookController.php`)
- Loan controller → Session helpers: requires login (evidence: `controllers/PrestamoController.php`)
- Loan controller → User model: loads users (evidence: `controllers/PrestamoController.php`)
- Loan controller → Book model: checks availability (evidence: `controllers/PrestamoController.php`)
- Loan controller → Loan model: records loan (evidence: `controllers/PrestamoController.php`)
- Loan controller → Book model: updates availability (evidence: `controllers/PrestamoController.php`)
- Loan controller → Loan view: renders loans (evidence: `controllers/PrestamoController.php`)
- Loan view → Library user: submits loan actions (evidence: `views/prestamos/index.php`)
- Dashboard controller → Book model: loads book stats (evidence: `controllers/DashboardController.php`)
- Dashboard controller → User model: counts users (evidence: `controllers/DashboardController.php`)
- Dashboard controller → Loan model: loads loan stats (evidence: `controllers/DashboardController.php`)
- Dashboard controller → Dashboard view: renders dashboard (evidence: `controllers/DashboardController.php`)
- Dashboard view → Shared header: includes header (evidence: `views/index.php`)
- Dashboard view → Shared footer: includes footer (evidence: `views/index.php`)
- Book model → DB connection: loads connection (evidence: `models/Libro.php`)
- User model → DB connection: loads connection (evidence: `models/Usuario.php`)
- Loan model → DB connection: loads connection (evidence: `models/Prestamo.php`)
- DB connection → Biblioteca database: opens connection (evidence: `config/config.php`)
- Book model → Biblioteca database: queries books (evidence: `models/Libro.php`)
- User model → Biblioteca database: queries users (evidence: `models/Usuario.php`)
- Loan model → Biblioteca database: queries loans
