# sucrero/asistencia architecture

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

- Interactive diagram: https://gitdiagram.com/sucrero/asistencia
- Repository: https://github.com/sucrero/asistencia

## Overview

1. **What this repository is**
   - A monolithic PHP application for **school attendance control** (“asistencia”) identified by **national ID/cédula**.
   - It is built as a classic server-rendered CRUD system rather than a SPA or API service.

2. **Primary entry and page flow**
   - `index.php` and `vistas/index.php` act as the main application entry points.
   - The `vistas/` directory contains the user-facing screens for the main modules: attendance, personnel, schedules, holidays, permissions, users, and reports.
   - `menu/menu.php` and shared layout fragments like `vistas/pie.html` provide common navigation and page chrome.

3. **Core functional subsystems**
   - **Asistencia**: attendance registration and consultation.
   - **Personal**: staff/person records.
   - **Horario / Horper**: schedules and schedule-to-person assignment.
   - **Festivo**: holidays/non-working days.
   - **Permiso / PermisoPer**: permissions/leave requests and their assignment to people.
   - **Usuario**: user accounts and access management.
   - `Operaciones.php` likely acts as a controller/dispatcher for form actions and CRUD operations across these modules.

4. **Domain model layer**
   - The `clases/` folder contains the application’s business/domain objects.
   - Each class maps closely to a business concept: `Asistencia`, `Personal`, `Horario`, `Festivo`, `Permiso`, `Usuario`, plus helper entities like `Horper` and `PermisoPer`.
   - `clases/JSON.php` suggests the app also emits structured responses for some AJAX-driven interactions.

5. **Database access boundary**
   - `conexion/` is the persistence layer, with `Postgres.php`, `DataAccess.php`, `DBMetodos.php`, and `conexion.php`.
   - The README confirms **PostgreSQL** as the database backend.
   - `bdd/bdd.sql` is the schema/data seed file, which is the authoritative source for tables and likely stored structure used by the domain classes.

6. **Data flow from UI to database**
   - User actions start in a `vistas/*.php` screen, often driven by JavaScript form handling.
   - Requests are processed by PHP classes or `Operaciones.php`, which call the database layer in `conexion/`.
   - Results are rendered back into the same view or returned as JSON for asynchronous updates.

7. **Reporting and document generation**
   - The `vistas/reporte_*.php` files indicate separate report screens for each business area.
   - PDF generation is a major subsystem: the repository includes **FPDF** plus custom extensions in `clases/PDF_MC_Table.php`, `clases/PDF_Code128.php`, and `clases/cellpdf.php`.
   - This suggests reports can be exported/printed as structured PDFs, possibly with tables and barcodes.

8. **Client-side interaction layer**
   - The `js/` folder contains module-specific scripts like `jsAsistencia.js`, `jsPersonal.js`, `jsHorario.js`, `jsPermiso.js`, `jsFestivo.js`, and `jsUsuario.js`.
   - These scripts likely handle validation, AJAX calls, dynamic table updates, and UI behavior.
   - jQuery and Bootstrap 2.x are the main front-end dependencies.

9. **Presentation and styling**
   - CSS assets in `css/` and Bootstrap assets define the UI layout and responsive behavior.
   - The app is designed for a traditional form-based interface, with modal/dialog interactions supported by Bootstrap scripts.

10. **External/runtime assumptions**
   - The README states the system was built on **Linux/Debian**, using **PHP 5.x**, **PostgreSQL 9.4**, and tested in Chrome/Firefox.
   - That places the application squarely in the LAMP-like era, with no evidence of modern framework abstractions.

11. **What to highlight in an architecture diagram**
   - A central **web UI layer** (`vistas/`, `menu/`, JS/CSS).
   - A **PHP domain/controller layer** (`clases/`, `Operaciones.php`).
   - A **database access layer** (`conexion/`).
   - A **PostgreSQL data store** (`bdd/bdd.sql` as schema source).
   - A **report/export layer** built on FPDF.
   - Cross-cutting static dependencies: Bootstrap, jQuery, and custom AJAX scripts.

12. **Overall structure**
   - This is a **single-codebase, tightly coupled CRUD application** with separate screens per module, shared PHP classes for business logic, and direct database access.
   - The main architectural boundaries are not microservices or APIs, but rather **UI screens, domain classes, persistence helpers, and PDF/report generation**.

Main entry points: [`Operaciones.php`](https://github.com/sucrero/asistencia/blob/master/Operaciones.php) (Operaciones), [`vistas/index.php`](https://github.com/sucrero/asistencia/blob/master/vistas/index.php) (App Entry), [`conexion/conexion.php`](https://github.com/sucrero/asistencia/blob/master/conexion/conexion.php) (DB Access), [`js/jsAsistencia.js`](https://github.com/sucrero/asistencia/blob/master/js/jsAsistencia.js) (UI Scripts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Web UI"]
  node_index["Home<br/>entrypoint<br/>[index.php]"]
  node_vistas_index["App Entry<br/>entrypoint<br/>[index.php]"]
  node_menu["Menu<br/>layout<br/>[menu.php]"]
  node_vistas_inicio["Start Page<br/>screen<br/>[inicio.php]"]
  node_vistas_asistencia["Asistencia<br/>screen<br/>[asistencia.php]"]
  node_vistas_personal["Personal<br/>screen<br/>[personal.php]"]
  node_vistas_horario["Horario<br/>screen<br/>[horario.php]"]
  node_vistas_permiso["Permiso<br/>screen<br/>[permiso.php]"]
  node_vistas_festivo["Festivo<br/>screen<br/>[festivo.php]"]
  node_vistas_usuario["Usuario<br/>screen<br/>[usuario.php]"]
  node_js_bundle["UI Scripts<br/>client scripts<br/>[jsAsistencia.js]"]
end

subgraph group_core["Application Core"]
  node_operaciones["Operaciones<br/>controller<br/>[Operaciones.php]"]
  node_asistencia_cls["Asistencia<br/>domain model<br/>[Asistencia.php]"]
  node_personal_cls["Personal<br/>domain model<br/>[Personal.php]"]
  node_horario_cls["Horario<br/>domain model<br/>[Horario.php]"]
  node_permiso_cls["Permiso<br/>domain model<br/>[Permiso.php]"]
  node_usuario_cls["Usuario<br/>domain model<br/>[Usuario.php]"]
  node_json_cls["JSON<br/>response helper<br/>[JSON.php]"]
end

subgraph group_data["Persistence"]
  node_conexion_base[("DB Access<br/>persistence gateway<br/>[conexion.php]")]
  node_db_metodos["DB Methods<br/>persistence helper<br/>[DBMetodos.php]"]
  node_postgres["Postgres<br/>driver adapter<br/>[Postgres.php]"]
  node_bdd_sql["Schema<br/>[bdd.sql]"]
end

subgraph group_reports["Reports & PDF"]
  node_reporte_general["General Report<br/>report screen<br/>[repgeneral.php]"]
  node_reporte_asis["Asis Report<br/>report screen<br/>[repgralasis.php]"]
  node_reporte_personal["Pers Report<br/>report screen<br/>[reporte_pers.php]"]
  node_reporte_permiso["Permiso Report<br/>report screen"]
  node_pdf_ext["PDF Extras<br/>pdf extensions<br/>[PDF_MC_Table.php]"]
end

subgraph group_vendor["Vendored Libraries"]
  node_pdf_fpdf["FPDF<br/>pdf library<br/>[fpdf.php]"]
end

node_index -->|"boots"| node_vistas_index
node_vistas_index -->|"includes"| node_menu
node_vistas_index -->|"routes to"| node_vistas_inicio
node_vistas_index -->|"routes to"| node_vistas_asistencia
node_vistas_index -->|"routes to"| node_vistas_personal
node_vistas_index -->|"routes to"| node_vistas_horario
node_vistas_index -->|"routes to"| node_vistas_permiso
node_vistas_index -->|"routes to"| node_vistas_festivo
node_vistas_index -->|"routes to"| node_vistas_usuario
node_vistas_asistencia -->|"uses"| node_js_bundle
node_vistas_personal -->|"uses"| node_js_bundle
node_vistas_horario -->|"uses"| node_js_bundle
node_vistas_permiso -->|"uses"| node_js_bundle
node_operaciones -->|"coordinates"| node_asistencia_cls
node_operaciones -->|"coordinates"| node_personal_cls
node_operaciones -->|"coordinates"| node_horario_cls
node_operaciones -->|"coordinates"| node_permiso_cls
node_operaciones -->|"coordinates"| node_usuario_cls
node_asistencia_cls -->|"reads/writes"| node_conexion_base
node_personal_cls -->|"reads/writes"| node_conexion_base
node_horario_cls -->|"reads/writes"| node_conexion_base
node_permiso_cls -->|"reads/writes"| node_conexion_base
node_usuario_cls -->|"reads/writes"| node_conexion_base
node_conexion_base -->|"uses"| node_db_metodos
node_conexion_base -->|"adapts"| node_postgres
node_db_metodos -->|"targets"| node_bdd_sql
node_reporte_general -->|"renders with"| node_pdf_fpdf
node_reporte_personal -->|"renders with"| node_pdf_fpdf
node_reporte_permiso -->|"renders with"| node_pdf_fpdf
node_pdf_ext -->|"extends"| node_pdf_fpdf
node_vistas_asistencia -->|"submits to"| node_operaciones
node_vistas_personal -->|"submits to"| node_operaciones
node_vistas_horario -->|"submits to"| node_operaciones
node_vistas_permiso -->|"submits to"| node_operaciones
node_vistas_usuario -->|"submits to"| node_operaciones
node_operaciones -->|"returns"| node_json_cls

click node_index "https://github.com/sucrero/asistencia/blob/master/index.php"
click node_vistas_index "https://github.com/sucrero/asistencia/blob/master/vistas/index.php"
click node_menu "https://github.com/sucrero/asistencia/blob/master/menu/menu.php"
click node_vistas_inicio "https://github.com/sucrero/asistencia/blob/master/vistas/inicio.php"
click node_vistas_asistencia "https://github.com/sucrero/asistencia/blob/master/vistas/asistencia.php"
click node_vistas_personal "https://github.com/sucrero/asistencia/blob/master/vistas/personal.php"
click node_vistas_horario "https://github.com/sucrero/asistencia/blob/master/vistas/horario.php"
click node_vistas_permiso "https://github.com/sucrero/asistencia/blob/master/vistas/permiso.php"
click node_vistas_festivo "https://github.com/sucrero/asistencia/blob/master/vistas/festivo.php"
click node_vistas_usuario "https://github.com/sucrero/asistencia/blob/master/vistas/usuario.php"
click node_js_bundle "https://github.com/sucrero/asistencia/blob/master/js/jsAsistencia.js"
click node_operaciones "https://github.com/sucrero/asistencia/blob/master/Operaciones.php"
click node_asistencia_cls "https://github.com/sucrero/asistencia/blob/master/clases/Asistencia.php"
click node_personal_cls "https://github.com/sucrero/asistencia/blob/master/clases/Personal.php"
click node_horario_cls "https://github.com/sucrero/asistencia/blob/master/clases/Horario.php"
click node_permiso_cls "https://github.com/sucrero/asistencia/blob/master/clases/Permiso.php"
click node_usuario_cls "https://github.com/sucrero/asistencia/blob/master/clases/Usuario.php"
click node_json_cls "https://github.com/sucrero/asistencia/blob/master/clases/JSON.php"
click node_conexion_base "https://github.com/sucrero/asistencia/blob/master/conexion/conexion.php"
click node_db_metodos "https://github.com/sucrero/asistencia/blob/master/conexion/DBMetodos.php"
click node_postgres "https://github.com/sucrero/asistencia/blob/master/conexion/Postgres.php"
click node_bdd_sql "https://github.com/sucrero/asistencia/blob/master/bdd/bdd.sql"
click node_reporte_general "https://github.com/sucrero/asistencia/blob/master/vistas/repgeneral.php"
click node_reporte_asis "https://github.com/sucrero/asistencia/blob/master/vistas/repgralasis.php"
click node_reporte_personal "https://github.com/sucrero/asistencia/blob/master/vistas/reporte_pers.php"
click node_reporte_permiso "https://github.com/sucrero/asistencia/blob/master/vistas/reporte_permiso.php"
click node_pdf_fpdf "https://github.com/sucrero/asistencia/blob/master/fpdf/fpdf.php"
click node_pdf_ext "https://github.com/sucrero/asistencia/blob/master/clases/PDF_MC_Table.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_vistas_index,node_menu,node_vistas_inicio,node_vistas_asistencia,node_vistas_personal,node_vistas_horario,node_vistas_permiso,node_vistas_festivo,node_vistas_usuario,node_js_bundle toneBlue
class node_operaciones,node_asistencia_cls,node_personal_cls,node_horario_cls,node_permiso_cls,node_usuario_cls,node_json_cls toneAmber
class node_conexion_base,node_db_metodos,node_postgres,node_bdd_sql toneMint
class node_reporte_general,node_reporte_asis,node_reporte_personal,node_reporte_permiso,node_pdf_ext toneRose
class node_pdf_fpdf toneIndigo
```

## Components

### Web UI

Server-rendered screens, shared chrome, and client-side interaction assets.

- [Home](https://github.com/sucrero/asistencia/blob/master/index.php): entrypoint · Main application entry point. · `index.php`
- [App Entry](https://github.com/sucrero/asistencia/blob/master/vistas/index.php): entrypoint · Primary page bootstrap and navigation entry. · `vistas/index.php`
- [Menu](https://github.com/sucrero/asistencia/blob/master/menu/menu.php): layout · Shared navigation chrome. · `menu/menu.php`
- [Start Page](https://github.com/sucrero/asistencia/blob/master/vistas/inicio.php): screen · Landing/dashboard screen. · `vistas/inicio.php`
- [Asistencia](https://github.com/sucrero/asistencia/blob/master/vistas/asistencia.php): screen · Attendance management view. · `vistas/asistencia.php`
- [Personal](https://github.com/sucrero/asistencia/blob/master/vistas/personal.php): screen · Staff/person management view. · `vistas/personal.php`
- [Horario](https://github.com/sucrero/asistencia/blob/master/vistas/horario.php): screen · Schedule management view. · `vistas/horario.php`
- [Permiso](https://github.com/sucrero/asistencia/blob/master/vistas/permiso.php): screen · Leave/permission management view. · `vistas/permiso.php`
- [Festivo](https://github.com/sucrero/asistencia/blob/master/vistas/festivo.php): screen · Holiday calendar view. · `vistas/festivo.php`
- [Usuario](https://github.com/sucrero/asistencia/blob/master/vistas/usuario.php): screen · User account management view. · `vistas/usuario.php`
- [UI Scripts](https://github.com/sucrero/asistencia/blob/master/js/jsAsistencia.js): client scripts · Module-specific AJAX, validation, and UI behavior. · `js/jsAsistencia.js`

### Application Core

Central PHP controller and domain model for attendance and related entities.

- [Operaciones](https://github.com/sucrero/asistencia/blob/master/Operaciones.php): controller · Central action dispatcher for CRUD operations. · `Operaciones.php`
- [Asistencia](https://github.com/sucrero/asistencia/blob/master/clases/Asistencia.php): domain model · Attendance domain object. · `clases/Asistencia.php`
- [Personal](https://github.com/sucrero/asistencia/blob/master/clases/Personal.php): domain model · Staff/person domain object. · `clases/Personal.php`
- [Horario](https://github.com/sucrero/asistencia/blob/master/clases/Horario.php): domain model · Schedule domain object. · `clases/Horario.php`
- [Permiso](https://github.com/sucrero/asistencia/blob/master/clases/Permiso.php): domain model · Permission/leave domain object. · `clases/Permiso.php`
- [Usuario](https://github.com/sucrero/asistencia/blob/master/clases/Usuario.php): domain model · User/account domain object. · `clases/Usuario.php`
- [JSON](https://github.com/sucrero/asistencia/blob/master/clases/JSON.php): response helper · Structured response helper for asynchronous interactions. · `clases/JSON.php`

### Persistence

Database connection and access helpers.

- [DB Access](https://github.com/sucrero/asistencia/blob/master/conexion/conexion.php): persistence gateway · Database connection and access layer. · `conexion/conexion.php`
- [DB Methods](https://github.com/sucrero/asistencia/blob/master/conexion/DBMetodos.php): persistence helper · Reusable database operations. · `conexion/DBMetodos.php`
- [Postgres](https://github.com/sucrero/asistencia/blob/master/conexion/Postgres.php): driver adapter · PostgreSQL-specific access wrapper. · `conexion/Postgres.php`
- [Schema](https://github.com/sucrero/asistencia/blob/master/bdd/bdd.sql): database schema · SQL schema and seed source. · `bdd/bdd.sql`

### Reports & PDF

PDF generation and report screens.

- [General Report](https://github.com/sucrero/asistencia/blob/master/vistas/repgeneral.php): report screen · Consolidated reporting view. · `vistas/repgeneral.php`
- [Asis Report](https://github.com/sucrero/asistencia/blob/master/vistas/repgralasis.php): report screen · Attendance report screen. · `vistas/repgralasis.php`
- [Pers Report](https://github.com/sucrero/asistencia/blob/master/vistas/reporte_pers.php): report screen · Personnel report screen. · `vistas/reporte_pers.php`
- [Permiso Report](https://github.com/sucrero/asistencia/blob/master/vistas/reporte_permiso.php): report screen · Permission report screen. · `vistas/reporte_permiso.php`
- [PDF Extras](https://github.com/sucrero/asistencia/blob/master/clases/PDF_MC_Table.php): pdf extensions · Custom PDF table and barcode helpers. · `clases/PDF_MC_Table.php`

### Vendored Libraries

Bundled third-party frontend and PDF dependencies.

- [FPDF](https://github.com/sucrero/asistencia/blob/master/fpdf/fpdf.php): pdf library · Bundled PDF generation engine. · `fpdf/fpdf.php`

## Connections

- Home → App Entry: boots · Initial request enters the main app flow.
- App Entry → Menu: includes · Shared navigation is loaded into pages.
- App Entry → Start Page: routes to · Loads the start screen after bootstrap.
- App Entry → Asistencia: routes to · Main navigation opens attendance screens.
- App Entry → Personal: routes to · Main navigation opens personnel screens.
- App Entry → Horario: routes to · Main navigation opens schedule screens.
- App Entry → Permiso: routes to · Main navigation opens permission screens.
- App Entry → Festivo: routes to · Main navigation opens holiday screens.
- App Entry → Usuario: routes to · Main navigation opens user screens.
- Asistencia → UI Scripts: uses · Client-side behavior and AJAX hooks.
- Personal → UI Scripts: uses · Client-side behavior and AJAX hooks.
- Horario → UI Scripts: uses · Client-side behavior and AJAX hooks.
- Permiso → UI Scripts: uses · Client-side behavior and AJAX hooks.
- Operaciones → Asistencia: coordinates · Dispatches attendance operations.
- Operaciones → Personal: coordinates · Dispatches personnel operations.
- Operaciones → Horario: coordinates · Dispatches schedule operations.
- Operaciones → Permiso: coordinates · Dispatches permission operations.
- Operaciones → Usuario: coordinates · Dispatches account operations.
- Asistencia → DB Access: reads/writes · Persists attendance records.
- Personal → DB Access: reads/writes · Persists staff records.
- Horario → DB Access: reads/writes · Persists schedules and assignments.
- Permiso → DB Access: reads/writes · Persists permission requests.
- Usuario → DB Access: reads/writes · Persists user accounts.
- DB Access → DB Methods: uses · Common database helpers.
- DB Access → Postgres: adapts · PostgreSQL-specific connection behavior.
- DB Methods → Schema: targets · Operates on the seeded schema.
- General Report → FPDF: renders with · Report output is built as PDF.
- Pers Report → FPDF: renders with · Report output is built as PDF.
- Permiso Report → FPDF: renders with · Report output is built as PDF.
- PDF Extras → FPDF: extends · Custom table and barcode rendering.
- Asistencia → Operaciones: submits to · Forms post actions into the dispatcher.
- Personal → Operaciones: submits to · Forms post actions into the dispatcher.
- Horario → Operaciones: submits to · Forms post actions into the dispatcher.
- Permiso → Operaciones: submits to · Forms post actions into the dispatcher.
- Usuario → Operaciones: submits to · Forms post actions into the dispatcher.
- Operaciones → JSON: returns · Some interactions return structured JSON.
