# carloskapaza/laboratorio-5-6-biblioteca-en-grupo architecture

> Architecture diagram of the GitHub repository carloskapaza/laboratorio-5-6-biblioteca-en-grupo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo
- Repository: https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo

## Overview

1. **Overall shape**
   - This is a classic browser + PHP + database CRUD app, but implemented as a SPA-like experience.
   - The browser loads one shell page, and JavaScript swaps in server-rendered fragments instead of doing full page reloads.

2. **Frontend shell**
   - The main entry point is the page shell (`index.html` in the tree; the README refers to it as `index.php`).
   - It contains the sidebar navigation, the main content container, and a separate modal container used for forms.

3. **Client-side controller**
   - `app.js` is the central orchestrator.
   - It handles menu clicks, fetches HTML fragments for views, fetches JSON for record data, updates the DOM, and opens/closes Bootstrap modals.

4. **Dynamic content boundary**
   - The main content area is a placeholder for server-generated HTML.
   - `libros/lista.php` and `usuarios/lista.php` are meant to return table markup that gets injected into this area.
   - This keeps navigation asynchronous while still letting PHP render the table structure.

5. **Modal/form boundary**
   - `libros/registro.php` and `usuarios/registro.php` act as form templates.
   - They are fetched on demand and injected into the modal container, so the same form can be reused for create and edit flows.

6. **Libro CRUD backend**
   - The `libros/` folder is split into:
     - HTML-producing scripts: `lista.php`, `registro.php`
     - JSON endpoints: `create.php`, `get.php`, `update.php`, `delete.php`
   - This separation is important: views return HTML, while operations return JSON status/data.

7. **Libro data flow**
   - List: `app.js` fetches `libros/lista.php` and injects the returned table into the main container.
   - Create: `app.js` loads `registro.php`, submits form data to `create.php`, then reloads the list.
   - Edit: `app.js` loads the form, requests a single record from `get.php?id=...`, fills the inputs, then submits to `update.php`.
   - Delete: `app.js` confirms with the user, posts the id to `delete.php`, then refreshes the list.

8. **Shared database access**
   - `conexion.php` is the shared server-side connection module.
   - All PHP scripts that touch the database depend on it, so the DB connection is centralized rather than duplicated.

9. **Usuarios subsystem**
   - The `usuarios/` directory mirrors the same CRUD-oriented structure as `libros/`, but the tree shows fewer files.
   - It likely reuses the same architectural pattern: list view, form template, and server-side create/list operations.

10. **Styling and UI dependencies**
   - `estilos.css` is the app’s custom visual layer on top of Bootstrap.
   - Bootstrap provides layout, modal behavior, and responsive structure; the custom CSS defines the project’s identity and overrides defaults.
   - The README also indicates Google Fonts are part of the presentation stack.

11. **External-facing technologies**
   - The implementation relies on vanilla JavaScript with `fetch()`, PHP endpoints, Bootstrap, and a relational database accessed through server-side PHP.
   - The key architectural constraint is that the frontend never talks to the database directly; all data access goes through PHP.

12. **Diagram boundaries to show**
   - Browser UI shell
   - JavaScript controller layer
   - PHP HTML fragment endpoints
   - PHP JSON CRUD endpoints
   - Shared DB connection module
   - Database persistence layer

Main entry points: [`app.js`](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/app.js) (App logic), [`conexion.php`](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/conexion.php) (DB connect), [`estilos.css`](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/estilos.css) (Theme CSS), [`index.html`](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/index.html) (Shell page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client UI"]
  node_index["Shell page<br/>html entry<br/>[index.html]"]
  node_appjs["App logic<br/>js controller<br/>[app.js]"]
  node_styles["Theme CSS<br/>style<br/>[estilos.css]"]
  node_bootstrap["Bootstrap<br/>ui framework"]
  node_fonts["Google Fonts<br/>font service"]
end

subgraph group_libros["Libros"]
  node_lib_lista["Libro list<br/>html fragment<br/>[lista.php]"]
  node_lib_registro["Libro form<br/>html fragment<br/>[registro.php]"]
  node_lib_create["Libro create<br/>json endpoint<br/>[create.php]"]
  node_lib_get["Libro fetch<br/>json endpoint<br/>[get.php]"]
  node_lib_update["Libro update<br/>json endpoint<br/>[update.php]"]
  node_lib_delete["Libro delete<br/>json endpoint<br/>[delete.php]"]
end

subgraph group_usuarios["Usuarios"]
  node_usr_lista["Usuario list<br/>html fragment<br/>[lista.php]"]
  node_usr_registro["Usuario form<br/>html fragment<br/>[registro.php]"]
  node_usr_create["Usuario create<br/>json endpoint<br/>[create.php]"]
end

subgraph group_server["Server Core"]
  node_dbconn["DB connect<br/>php shared module<br/>[conexion.php]"]
  node_database[("Database<br/>relational store")]
end

node_appjs -->|"drives UI"| node_index
node_index -->|"loads"| node_appjs
node_appjs -->|"uses"| node_bootstrap
node_styles -.->|"overrides"| node_bootstrap
node_styles -.->|"uses"| node_fonts
node_appjs -->|"fetches HTML"| node_lib_lista
node_appjs -->|"fetches form"| node_lib_registro
node_appjs -->|"submits"| node_lib_create
node_appjs -->|"prefills"| node_lib_get
node_appjs -->|"submits"| node_lib_update
node_appjs -->|"submits"| node_lib_delete
node_appjs -->|"fetches HTML"| node_usr_lista
node_appjs -->|"fetches form"| node_usr_registro
node_appjs -->|"submits"| node_usr_create
node_lib_lista -->|"queries"| node_dbconn
node_lib_registro -->|"queries"| node_dbconn
node_lib_create -->|"writes"| node_dbconn
node_lib_get -->|"reads"| node_dbconn
node_lib_update -->|"writes"| node_dbconn
node_lib_delete -->|"writes"| node_dbconn
node_usr_lista -->|"queries"| node_dbconn
node_usr_registro -->|"queries"| node_dbconn
node_usr_create -->|"writes"| node_dbconn
node_dbconn -->|"connects to"| node_database

click node_index "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/index.html"
click node_appjs "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/app.js"
click node_styles "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/estilos.css"
click node_lib_lista "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/lista.php"
click node_lib_registro "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/registro.php"
click node_lib_create "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/create.php"
click node_lib_get "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/get.php"
click node_lib_update "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/update.php"
click node_lib_delete "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/delete.php"
click node_usr_lista "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/usuarios/lista.php"
click node_usr_registro "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/usuarios/registro.php"
click node_usr_create "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/usuarios/create.php"
click node_dbconn "https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/conexion.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_index,node_appjs,node_styles,node_bootstrap,node_fonts toneBlue
class node_lib_lista,node_lib_registro,node_lib_create,node_lib_get,node_lib_update,node_lib_delete toneAmber
class node_usr_lista,node_usr_registro,node_usr_create toneMint
class node_dbconn,node_database toneRose
```

## Components

### Client UI

Browser shell, controller, and presentation layer

- [Shell page](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/index.html): html entry · Single-page shell with navigation, content, and modal containers · `index.html`
- [App logic](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/app.js): js controller · Orchestrates navigation, fragment loading, form flows, and CRUD requests · `app.js`
- [Theme CSS](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/estilos.css): style · Custom visual layer over Bootstrap · `estilos.css`
- **Bootstrap**: ui framework · External UI framework for layout and modals
- **Google Fonts**: font service · External typography dependency referenced by the app

### Libros

Book CRUD views and endpoints

- [Libro list](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/lista.php): html fragment · Server-rendered table view for books · `libros/lista.php`
- [Libro form](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/registro.php): html fragment · Reusable create/edit form template for books · `libros/registro.php`
- [Libro create](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/create.php): json endpoint · Creates a book record and returns status/data · `libros/create.php`
- [Libro fetch](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/get.php): json endpoint · Returns one book record for editing · `libros/get.php`
- [Libro update](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/update.php): json endpoint · Updates an existing book record · `libros/update.php`
- [Libro delete](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/libros/delete.php): json endpoint · Deletes a book record · `libros/delete.php`

### Usuarios

User CRUD views and endpoints

- [Usuario list](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/usuarios/lista.php): html fragment · Server-rendered table view for users · `usuarios/lista.php`
- [Usuario form](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/usuarios/registro.php): html fragment · Reusable create/edit form template for users · `usuarios/registro.php`
- [Usuario create](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/usuarios/create.php): json endpoint · Creates a user record · `usuarios/create.php`

### Server Core

Shared PHP infrastructure and persistence boundary

- [DB connect](https://github.com/carloskapaza/laboratorio-5-6-biblioteca-en-grupo/blob/main/conexion.php): php shared module · Shared connection module used by server scripts · `conexion.php`
- **Database**: relational store · Persistent data store behind the PHP endpoints

## Connections

- App logic → Shell page: drives UI · Updates the shell content and modal areas
- Shell page → App logic: loads · Page shell bootstraps the client controller
- App logic → Bootstrap: uses · Relies on Bootstrap for modal and layout behavior
- Theme CSS → Bootstrap: overrides · Custom CSS layers on top of Bootstrap defaults
- Theme CSS → Google Fonts: uses · Presentation layer depends on external fonts
- App logic → Libro list: fetches HTML · Loads the books table into the main content area
- App logic → Libro form: fetches form · Loads the reusable book form into the modal container
- App logic → Libro create: submits · Sends create requests for books
- App logic → Libro fetch: prefills · Requests one book record before edit
- App logic → Libro update: submits · Sends update requests for books
- App logic → Libro delete: submits · Sends delete requests for books
- App logic → Usuario list: fetches HTML · Loads the users table into the main content area
- App logic → Usuario form: fetches form · Loads the reusable user form into the modal container
- App logic → Usuario create: submits · Sends create requests for users
- Libro list → DB connect: queries · Uses the shared DB connection for data access
- Libro form → DB connect: queries · Uses the shared DB connection when needed for form data
- Libro create → DB connect: writes · Persists new book records through the shared connection
- Libro fetch → DB connect: reads · Fetches a single book record through the shared connection
- Libro update → DB connect: writes · Updates book records through the shared connection
- Libro delete → DB connect: writes · Deletes book records through the shared connection
- Usuario list → DB connect: queries · Uses the shared DB connection for user listings
- Usuario form → DB connect: queries · Uses the shared DB connection when needed for form data
- Usuario create → DB connect: writes · Persists new user records through the shared connection
- DB connect → Database: connects to · Centralized PHP bridge to the relational database
