# alejo09g/proyecto_bolipuerto architecture

> Architecture diagram of the GitHub repository alejo09g/proyecto_bolipuerto, 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/alejo09g/proyecto_bolipuerto
- Repository: https://github.com/alejo09g/proyecto_bolipuerto

## Overview

1. **Repository shape**
   - This is a monorepo, but the only production system is **`SIRAP/`**: a Laravel 11 application for port access control.
   - The other top-level documents and the “Port Access Control System” mockup area are reference material, not part of the runtime system.

2. **Runtime and stack**
   - The app is a **server-rendered Laravel application** using **Blade** views, **MySQL** persistence, and frontend assets built with **Vite** plus **Alpine.js/TailwindCSS** style utilities.
   - The application is deployed as a traditional PHP web app behind the `public/` front controller.

3. **Request entry and routing**
   - Web traffic enters through `public/index.php` and is routed via **`routes/web.php`**.
   - Requests are mediated by custom middleware such as:
     - `SesionUnica` for enforcing one active session
     - `TurnoActivo` for shift-based access
     - `PreventBackHistory` for security on authenticated pages
     - `DevPanelAuth` for protected developer/admin tooling
     - `HandleInertiaRequests` exists, but the visible UI is predominantly Blade-based

4. **Role-based application boundaries**
   - The UI and controllers are clearly split into three main operational areas:
     - **Operador**: day-to-day gate operations
     - **Admin**: administration, reporting, configuration
     - **Superadmin**: higher-privilege control, infrastructure, user management, audit, and dev-panel access
   - Separate Blade view folders reflect these boundaries: `resources/views/operador`, `admin`, and `superadmin`.

5. **Controllers as orchestration layer**
   - Key controllers are:
     - `AuthController` for login/session flow
     - `RegistroController` for access-entry and exit records
     - `TurnoController` for shift handling
     - `IncidenteController` for incident reporting
     - `PreferenciaController` for user/system preferences
     - `AdminController`, `SuperadminController`, and `DevPanelController` for role-specific dashboards and tools
   - Controllers appear to coordinate validation, authorization, and persistence rather than embedding domain logic.

6. **Core domain model**
   - The main persistent entities are:
     - `Usuario`, `Persona`, `Vehiculo`
     - `Institucion`, `PuntoControl`, `TipoVehiculo`
     - `RegistroAcceso`, `PreAutorizacion`, `ListaNegra`
     - `Incidente`, `Notificacion`, `Auditoria`, `Ajuste`
   - The database migrations show the system evolved around port-access operations: vehicle entry/exit, people/driver identity, checkpoints, blacklist handling, preauthorization, and traceability.

7. **Primary operational data flow**
   - A typical access flow is:
     - operator authenticates
     - selects a control point and shift context
     - captures or looks up a person/vehicle
     - creates or updates an access record in `registro_accesos`
     - possibly checks blacklist or preauthorization status
     - records notes, exit user, and historical fields
   - This is the system’s central transaction path and the most important flow for an architecture diagram.

8. **Security, identity, and access control**
   - Authentication is backed by Laravel auth plus a permissions layer indicated by `config/permission.php` and `create_permission_tables`.
   - There are user-level fields for `modo_oscuro`, `turno`, `session_token`, and `persona_id`, implying profile settings, shift assignment, and strict session binding.
   - The architecture emphasizes operational safety: single-session enforcement, back-history prevention, and shift-aware gating.

9. **Auditability and traceability**
   - The app is designed for accountability:
     - `Auditoria` model and `auditorias` table
     - `Auditable` trait for reusable change tracking
     - `TelescopeServiceProvider` and telescope entries for runtime observability
   - This means state changes are likely logged both at the business level and at the framework/diagnostic level.

10. **Reporting and document output**
    - The `resources/views/pdf/` folder contains dedicated PDF templates for:
      - access history
      - incidents
      - blacklist
      - users
      - pre-authorizations
      - turn summaries
      - operational reports
    - This suggests a reporting pipeline where database records are rendered into printable/exportable documents from server-side templates.

11. **Background/maintenance tasks**
    - Console commands show two important scheduled/ops concerns:
      - `CheckVehiculosLargaEstancia` for long-stay vehicle detection
      - `DatabaseBackup` for operational backups
    - These are supporting processes, not user-facing workflows, but they are important for the architecture because they extend the system beyond request/response handling.

12. **Storage and infrastructure touchpoints**
    - The app uses standard Laravel storage areas for logs, cached views, sessions, and file uploads/public assets.
    - Mail, queue, cache, session, and logging configs are present, so the deployment is built around normal Laravel infrastructure services, with **MySQL** as the primary system of record.

13. **Frontend structure**
    - Presentation is organized into reusable layouts and partials:
      - shared app shell
      - header, sidebar, footer
      - role-specific layouts
      - modal fragments for forms and detail views
    - The UI is therefore composed from Blade templates rather than a separate SPA frontend.

14. **Testing and seed data**
    - The repo includes PHPUnit feature/unit tests and at least one feature test for synchronization-related behavior.
    - Seeders exist for bootstrap data such as blacklist entries, indicating the system can be initialized with realistic operational defaults.

15. **Diagram guidance**
    - If you draw the architecture, the main boxes should be:
      - Browser/UI
      - Laravel routes/middleware
      - Role-specific controllers
      - Domain models
      - MySQL database
      - PDF/report generation
      - Console jobs/maintenance
      - Telescope/logging/backup as support services
    - The most important boundary is between **operator/admin/superadmin presentation flows** and the **shared access-control data model** centered on persons, vehicles, checkpoints, and access records.

Main entry points: [`SIRAP/routes/web.php`](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/routes/web.php) (Web routes), [`SIRAP/app/Models`](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Models) (Core models), [`SIRAP/app/Http/Controllers/RegistroController.php`](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/RegistroController.php) (Accesses), [`SIRAP/app/Http/Controllers/AdminController.php`](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/AdminController.php) (Admin ctrl)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI & Entry"]
  node_public_index["Front controller<br/>php entrypoint<br/>[index.php]"]
  node_routes_web["Web routes<br/>routing<br/>[web.php]"]
  node_views_layouts["Blade shell<br/>presentation"]
  node_views_operador["Operador UI<br/>role views"]
  node_views_admin["Admin UI<br/>role views"]
  node_views_superadmin["Superadmin UI<br/>role views"]
end

subgraph group_app["Laravel App"]
  node_auth_controller["Auth<br/>controller<br/>[AuthController.php]"]
  node_registro_controller["Accesses<br/>controller"]
  node_turno_controller["Shifts<br/>controller"]
  node_admin_controller["Admin ctrl<br/>controller"]
  node_superadmin_controller["Superadmin ctrl<br/>controller"]
  node_devpanel_controller["Dev panel<br/>controller"]
  node_middleware_stack{{"Middleware"}}
end

subgraph group_domain["Domain & Data"]
  node_models_core[("Core models<br/>Eloquent models")]
  node_auditable_trait["Auditable<br/>trait<br/>[Auditable.php]"]
  node_migrations[("Schema<br/>migrations")]
  node_seeders["Seed data<br/>seeders"]
  node_database_config[("MySQL config<br/>database config<br/>[database.php]")]
end

subgraph group_ops["Ops & Output"]
  node_pdf_views["PDF reports<br/>report templates"]
  node_console_commands["Console jobs<br/>artisan commands"]
  node_telescope_provider["Telescope<br/>observability"]
  node_storage[("Storage")]
end

node_public_index -->|"dispatches"| node_routes_web
node_routes_web -->|"applies"| node_middleware_stack
node_routes_web -->|"auth flow"| node_auth_controller
node_routes_web -->|"access flow"| node_registro_controller
node_routes_web -->|"shift flow"| node_turno_controller
node_routes_web -->|"admin area"| node_admin_controller
node_routes_web -->|"superadmin area"| node_superadmin_controller
node_routes_web -->|"dev tools"| node_devpanel_controller
node_auth_controller -->|"reads/writes"| node_models_core
node_registro_controller -->|"persists"| node_models_core
node_turno_controller -->|"reads/writes"| node_models_core
node_admin_controller -->|"manages"| node_models_core
node_superadmin_controller -->|"manages"| node_models_core
node_devpanel_controller -->|"uses"| node_telescope_provider
node_models_core -->|"defined by"| node_migrations
node_auditable_trait -->|"tracks"| node_models_core
node_migrations -->|"targets"| node_database_config
node_seeders -->|"populates"| node_migrations
node_registro_controller -->|"exports"| node_pdf_views
node_admin_controller -->|"exports"| node_pdf_views
node_superadmin_controller -->|"exports"| node_pdf_views
node_console_commands -->|"operates on"| node_database_config
node_console_commands -->|"writes"| node_storage
node_telescope_provider -->|"records"| node_storage
node_middleware_stack -->|"uses"| node_storage
node_views_operador -->|"composes"| node_views_layouts
node_views_admin -->|"composes"| node_views_layouts
node_views_superadmin -->|"composes"| node_views_layouts

click node_public_index "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/public/index.php"
click node_routes_web "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/routes/web.php"
click node_views_layouts "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/layouts"
click node_views_operador "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/operador"
click node_views_admin "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/admin"
click node_views_superadmin "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/superadmin"
click node_auth_controller "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/AuthController.php"
click node_registro_controller "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/RegistroController.php"
click node_turno_controller "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/TurnoController.php"
click node_admin_controller "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/AdminController.php"
click node_superadmin_controller "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/SuperadminController.php"
click node_devpanel_controller "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/DevPanelController.php"
click node_middleware_stack "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Http/Middleware"
click node_models_core "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Models"
click node_auditable_trait "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Traits/Auditable.php"
click node_migrations "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/database/migrations"
click node_seeders "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/database/seeders"
click node_pdf_views "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/pdf"
click node_console_commands "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Console/Commands"
click node_telescope_provider "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Providers/TelescopeServiceProvider.php"
click node_storage "https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/storage"
click node_database_config "https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/config/database.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_public_index,node_routes_web,node_views_layouts,node_views_operador,node_views_admin,node_views_superadmin toneBlue
class node_auth_controller,node_registro_controller,node_turno_controller,node_admin_controller,node_superadmin_controller,node_devpanel_controller,node_middleware_stack toneAmber
class node_models_core,node_auditable_trait,node_migrations,node_seeders,node_database_config toneMint
class node_pdf_views,node_console_commands,node_telescope_provider,node_storage toneRose
```

## Components

### UI & Entry

Browser entry, Blade presentation, and request routing

- [Front controller](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/public/index.php): php entrypoint · Web entry point for all browser requests · `SIRAP/public/index.php`
- [Web routes](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/routes/web.php): routing · Main HTTP route definitions and request dispatch · `SIRAP/routes/web.php`
- [Blade shell](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/layouts): presentation · Shared layouts, header/sidebar/footer, and app shells · `SIRAP/resources/views/layouts`
- [Operador UI](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/operador): role views · Day-to-day gate operation screens · `SIRAP/resources/views/operador`
- [Admin UI](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/admin): role views · Administration, reporting, and operational management screens · `SIRAP/resources/views/admin`
- [Superadmin UI](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/superadmin): role views · Higher-privilege control, infrastructure, and user management screens · `SIRAP/resources/views/superadmin`

### Laravel App

Controllers, middleware, providers, and command orchestration

- [Auth](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/AuthController.php): controller · Login and session flow · `SIRAP/app/Http/Controllers/AuthController.php`
- [Accesses](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/RegistroController.php): controller · Entry, exit, and access record orchestration · `SIRAP/app/Http/Controllers/RegistroController.php`
- [Shifts](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/TurnoController.php): controller · Shift selection and active-turn handling · `SIRAP/app/Http/Controllers/TurnoController.php`
- [Admin ctrl](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/AdminController.php): controller · Admin dashboard and management actions · `SIRAP/app/Http/Controllers/AdminController.php`
- [Superadmin ctrl](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/SuperadminController.php): controller · Superadmin dashboard and privileged tooling · `SIRAP/app/Http/Controllers/SuperadminController.php`
- [Dev panel](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Http/Controllers/DevPanelController.php): controller · Protected developer/admin tooling · `SIRAP/app/Http/Controllers/DevPanelController.php`
- [Middleware](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Http/Middleware): http middleware · Session, shift, back-history, and dev-panel gates · `SIRAP/app/Http/Middleware`

### Domain & Data

Core entities and persistence layer

- [Core models](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Models): Eloquent models · Person, vehicle, institution, checkpoint, and access entities · `SIRAP/app/Models`
- [Auditable](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Traits/Auditable.php): trait · Reusable change-tracking behavior · `SIRAP/app/Traits/Auditable.php`
- [Schema](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/database/migrations): migrations · Database evolution for access control, roles, audit, and reporting · `SIRAP/database/migrations`
- [Seed data](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/database/seeders): seeders · Bootstrap data such as blacklist entries · `SIRAP/database/seeders`
- [MySQL config](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/config/database.php): database config · Primary persistence and Laravel database setup · `SIRAP/config/database.php`

### Ops & Output

Reporting, observability, backups, and maintenance

- [PDF reports](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/resources/views/pdf): report templates · Printable/exportable operational documents · `SIRAP/resources/views/pdf`
- [Console jobs](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/app/Console/Commands): artisan commands · Scheduled maintenance such as long-stay checks and backups · `SIRAP/app/Console/Commands`
- [Telescope](https://github.com/alejo09g/proyecto_bolipuerto/blob/main/SIRAP/app/Providers/TelescopeServiceProvider.php): observability · Runtime diagnostics and entry capture · `SIRAP/app/Providers/TelescopeServiceProvider.php`
- [Storage](https://github.com/alejo09g/proyecto_bolipuerto/tree/main/SIRAP/storage): runtime storage · Sessions, cache, logs, uploads, and generated artifacts · `SIRAP/storage`

## Connections

- Front controller → Web routes: dispatches · Front controller hands requests to route definitions
- Web routes → Middleware: applies · Web routes are protected by session, shift, and security middleware
- Web routes → Auth: auth flow · Login and session endpoints
- Web routes → Accesses: access flow · Entry and exit operations
- Web routes → Shifts: shift flow · Shift selection and validation
- Web routes → Admin ctrl: admin area · Admin dashboard and management screens
- Web routes → Superadmin ctrl: superadmin area · Privileged administration routes
- Web routes → Dev panel: dev tools · Protected developer tooling routes
- Auth → Core models: reads/writes · User session and profile data
- Accesses → Core models: persists · Creates and updates access, person, vehicle, blacklist, and notification records
- Shifts → Core models: reads/writes · Shift state and user assignment
- Admin ctrl → Core models: manages · Operational admin data
- Superadmin ctrl → Core models: manages · Privileged user, audit, and infrastructure-related data
- Dev panel → Telescope: uses · Developer panel is aligned with observability tooling
- Core models → Schema: defined by · Tables and relationships are shaped by migrations
- Auditable → Core models: tracks · Reusable audit behavior for change history
- Schema → MySQL config: targets · Schema is stored in the Laravel/MySQL database
- Seed data → Schema: populates · Seed data assumes the evolved schema
- Accesses → PDF reports: exports · Access history and report output
- Admin ctrl → PDF reports: exports · Admin reporting and printable summaries
- Superadmin ctrl → PDF reports: exports · High-privilege reports and audit views
- Console jobs → MySQL config: operates on · Maintenance jobs run against the database
- Console jobs → Storage: writes · Backups and maintenance artifacts
- Telescope → Storage: records · Diagnostics and runtime capture rely on app storage
- Middleware → Storage: uses · Sessions and request security state are stored in Laravel storage/services
- Operador UI → Blade shell: composes · Role-specific screens use shared layouts
- Admin UI → Blade shell: composes · Admin screens use shared layouts
- Superadmin UI → Blade shell: composes · Superadmin screens use shared layouts
