# jhonkizzersanchez-ui/booksphere architecture

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

- Interactive diagram: https://gitdiagram.com/jhonkizzersanchez-ui/booksphere
- Repository: https://github.com/jhonkizzersanchez-ui/booksphere

## Overview

BookSphere is a plain-PHP school library application. Users enter through the web front controller, which dispatches API requests or page requests; the page path renders role-specific experiences such as authentication, catalog search, student borrowing views, and librarian management. Persistent MySQL authentication and staff approvals coexist with demo-backed catalog, loans, reviews, and reports. The graph preserves these documented capabilities, but several runtime links are omitted or marked unverified because their implementation excerpts were not provided.

Main entry points: [`backend/src/pages.php`](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/pages.php) (Page dispatch), [`backend/public/index.php`](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/public/index.php) (Request entry), [`backend/src/api.php`](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/api.php) (API dispatch), [`backend/views/layout.php`](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/layout.php) (Signed-in layout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_front["Request entry<br/>[index.php]"]
  node_router["Dev server router<br/>[router.php]"]
  node_page_dispatch["Page dispatch<br/>[pages.php]"]
  node_api_dispatch["API dispatch<br/>[api.php]"]
  node_bootstrap["App bootstrap<br/>[bootstrap.php]"]
end

subgraph group_accounts["Accounts and access"]
  node_auth["Authentication<br/>[auth.php]"]
  node_admin["Account administration<br/>[admin.php]"]
  node_mysql[("MySQL database")]
end

subgraph group_library["Library experience"]
  node_demo_data["Demo library data<br/>[data.php]"]
  node_catalog_view["Catalog and search<br/>[search.php]"]
  node_book_details["Book details<br/>[book-details.php]"]
  node_student_views["Student library views"]
  node_my_books["My books<br/>[my-books.php]"]
  node_teacher_view["Teacher dashboard"]
end

subgraph group_staff["Staff operations"]
  node_librarian_panel["Librarian panel"]
  node_admin_view["Admin dashboard"]
  node_reports_view["Library reports<br/>[reports.php]"]
  node_book_modal["Book editor modal<br/>[book-modal.php]"]
end

subgraph group_presentation["Page presentation"]
  node_layout["Signed-in layout<br/>[layout.php]"]
  node_head["Page head<br/>[head.php]"]
  node_toasts["Toast presentation<br/>[toasts.php]"]
end

node_visitor(("Browser user"))

node_visitor -->|"requests pages"| node_router
node_router -->|"forwards requests"| node_front
node_front -->|"loads runtime"| node_bootstrap
node_front -->|"dispatches API"| node_api_dispatch
node_front -->|"dispatches pages"| node_page_dispatch
node_auth -->|"reads and writes"| node_mysql
node_admin -.->|"manages accounts"| node_mysql
node_page_dispatch -.->|"renders pages"| node_layout
node_api_dispatch -.->|"handles account actions"| node_auth
node_api_dispatch -.->|"handles admin actions"| node_admin
node_catalog_view -->|"filters books"| node_demo_data
node_librarian_panel -->|"loads library data"| node_demo_data
node_librarian_panel -->|"includes modal"| node_book_modal
node_layout -->|"includes head"| node_head
node_layout -->|"includes toasts"| node_toasts
node_page_dispatch -.->|"selects view"| node_catalog_view
node_page_dispatch -.->|"selects view"| node_book_details
node_page_dispatch -.->|"selects view"| node_student_views
node_page_dispatch -.->|"selects view"| node_my_books
node_page_dispatch -.->|"selects view"| node_teacher_view
node_page_dispatch -.->|"selects view"| node_librarian_panel
node_page_dispatch -.->|"selects view"| node_admin_view
node_page_dispatch -.->|"selects view"| node_reports_view

click node_front "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/public/index.php"
click node_router "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/public/router.php"
click node_page_dispatch "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/pages.php"
click node_api_dispatch "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/api.php"
click node_bootstrap "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/bootstrap.php"
click node_auth "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/auth.php"
click node_admin "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/admin.php"
click node_demo_data "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/data.php"
click node_catalog_view "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/search.php"
click node_book_details "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/book-details.php"
click node_student_views "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/student-dashboard.php"
click node_my_books "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/my-books.php"
click node_teacher_view "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/teacher-dashboard.php"
click node_librarian_panel "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/librarian-panel.php"
click node_admin_view "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/admin-dashboard.php"
click node_reports_view "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/librarian/reports.php"
click node_layout "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/layout.php"
click node_head "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/partials/head.php"
click node_toasts "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/partials/toasts.php"
click node_book_modal "https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/librarian/book-modal.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_page_dispatch,node_api_dispatch,node_bootstrap,node_visitor toneBlue
class node_auth,node_admin,node_mysql toneAmber
class node_demo_data,node_catalog_view,node_book_details,node_student_views,node_my_books,node_teacher_view toneMint
class node_librarian_panel,node_admin_view,node_reports_view,node_book_modal toneRose
class node_layout,node_head,node_toasts toneIndigo
```

## Components

### Web runtime

- [Request entry](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/public/index.php): `backend/public/index.php`
- [Dev server router](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/public/router.php): `backend/public/router.php`
- [Page dispatch](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/pages.php): `backend/src/pages.php`
- [API dispatch](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/api.php): `backend/src/api.php`
- [App bootstrap](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/bootstrap.php): `backend/src/bootstrap.php`

### Accounts and access

- [Authentication](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/auth.php): `backend/src/auth.php`
- [Account administration](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/admin.php): `backend/src/admin.php`
- **MySQL database**

### Library experience

- [Demo library data](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/src/data.php): `backend/src/data.php`
- [Catalog and search](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/search.php): `backend/views/search.php`
- [Book details](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/book-details.php): `backend/views/book-details.php`
- [Student library views](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/student-dashboard.php): `backend/views/student-dashboard.php`
- [My books](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/my-books.php): `backend/views/my-books.php`
- [Teacher dashboard](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/teacher-dashboard.php): `backend/views/teacher-dashboard.php`

### Staff operations

- [Librarian panel](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/librarian-panel.php): `backend/views/librarian-panel.php`
- [Admin dashboard](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/admin-dashboard.php): `backend/views/admin-dashboard.php`
- [Library reports](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/librarian/reports.php): `backend/views/librarian/reports.php`
- [Book editor modal](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/librarian/book-modal.php): `backend/views/librarian/book-modal.php`

### Page presentation

- [Signed-in layout](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/layout.php): `backend/views/layout.php`
- [Page head](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/partials/head.php): `backend/views/partials/head.php`
- [Toast presentation](https://github.com/jhonkizzersanchez-ui/booksphere/blob/main/backend/views/partials/toasts.php): `backend/views/partials/toasts.php`

### Other components

- **Browser user**

## Connections

- Browser user → Dev server router: requests pages (evidence: `backend/public/router.php`)
- Dev server router → Request entry: forwards requests (evidence: `backend/public/router.php`)
- Request entry → App bootstrap: loads runtime (evidence: `backend/public/index.php`)
- Request entry → API dispatch: dispatches API (evidence: `backend/public/index.php`)
- Request entry → Page dispatch: dispatches pages (evidence: `backend/public/index.php`)
- Authentication → MySQL database: reads and writes (evidence: `backend/src/auth.php`)
- Account administration → MySQL database: manages accounts
- Page dispatch → Signed-in layout: renders pages
- API dispatch → Authentication: handles account actions
- API dispatch → Account administration: handles admin actions
- Catalog and search → Demo library data: filters books (evidence: `backend/views/search.php`)
- Librarian panel → Demo library data: loads library data (evidence: `backend/views/librarian-panel.php`)
- Librarian panel → Book editor modal: includes modal (evidence: `backend/views/librarian-panel.php`)
- Signed-in layout → Page head: includes head (evidence: `backend/views/layout.php`)
- Signed-in layout → Toast presentation: includes toasts (evidence: `backend/views/layout.php`)
- Page dispatch → Catalog and search: selects view
- Page dispatch → Book details: selects view
- Page dispatch → Student library views: selects view
- Page dispatch → My books: selects view
- Page dispatch → Teacher dashboard: selects view
- Page dispatch → Librarian panel: selects view
- Page dispatch → Admin dashboard: selects view
- Page dispatch → Library reports: selects view
