# afranklinromero/sidepo architecture

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

- Interactive diagram: https://gitdiagram.com/afranklinromero/sidepo
- Repository: https://github.com/afranklinromero/sidepo

## Overview

1. **Overall shape**
   - This is a single Laravel monolith, not a multi-service system. The core architecture is the standard Laravel request lifecycle: HTTP request → middleware → controller → Eloquent model/database → Blade response or file output.

2. **Primary domain**
   - The domain appears to be a Spanish-language complaint/case management system. The main business entities are **Caso**, **Registro**, **Seguimiento**, **Archivo**, **Archivodenuncia**, **Departamento**, **Municipio**, and **User/Role**.

3. **Request entrypoints**
   - Web traffic is handled through `routes/web.php` and the Laravel HTTP kernel. The app also includes `routes/api.php`, but the repository structure suggests the main product is server-rendered web UI rather than a JSON API.

4. **Controller layer**
   - Most application behavior is concentrated in feature controllers under `app/Http/Controllers`, especially CRUD-style controllers for each domain entity.
   - There are also specialized controllers for **auth**, **admin access**, **QR code generation**, **reports**, and **case follow-up**. This indicates the controllers are the main orchestration boundary, with little evidence of a separate service layer.

5. **Presentation layer**
   - Views are primarily **Blade templates** under `resources/views`, grouped by domain (`caso`, `registro`, `seguimiento`, `archivo`, `municipio`, etc.).
   - Shared UI is in `layouts/app.blade.php`, with additional pages for login/register/password reset, menus, dashboards, and case-specific views such as `conpdf`, `sinpdf`, and `ver`.

6. **Data model and persistence**
   - Persistence is handled through Eloquent models in `app/Models` and migrations in `database/migrations`.
   - The migration set shows the key schema objects: cases, geography tables, follow-up records, denunciation archives, roles/permissions, and user auth tables. This suggests a relational database with normalized reference data for departments and municipalities.

7. **Authorization model**
   - Authentication uses Laravel’s built-in auth stack, visible in the `Auth` controllers and middleware.
   - Authorization is role-based: the presence of `permission.php`, `create_permission_tables`, `create_roles`, `Role`, and `ModelHasRole` indicates a permissions package/pattern similar to Spatie-style RBAC. There is also a custom `AdminAuth` middleware for admin-only access.

8. **Document and file handling**
   - The app manages documents/files through `Archivo`, `Archivodenuncia`, and the `storage/app/public` area.
   - `config/dompdf.php` and PDF-related case views strongly suggest server-side PDF generation for case records or printable reports.
   - `public/img` and `resources/views/caso/*pdf*` indicate the UI supports generating/exporting case documents rather than only viewing records online.

9. **Geography/reference data**
   - `Departamento` and `Municipio` are separate domain objects, likely used as lookup/reference data linked to complaints, registries, or users.
   - This creates a hierarchical geographic boundary in the data model and likely drives form selection and filtering in the UI.

10. **Reporting and operational views**
   - `ReporteController` plus `resources/views/reporte/index.blade.php` suggest a reporting dashboard or listing layer over the core case data.
   - `HomeController`, `AdminController`, `menu.blade.php`, and `administrator.blade.php` indicate a role-specific landing/dashboard experience for operators and admins.

11. **Frontend assets**
   - Frontend build tooling is present via Vite, with CSS/Sass and a small amount of JavaScript/Vue (`resources/js`, `resources/sass`, `resources/js/components`).
   - The frontend is mostly server-rendered Blade, with modest asset bundling rather than a SPA architecture.

12. **Infrastructure and runtime boundaries**
   - File storage is local and Laravel-managed (`storage/`, `public/`), not an external object store.
   - The application relies on standard Laravel subsystems: sessions, cache, logging, mail, queue, broadcasting, and Sanctum are configured, but the repo structure does not indicate heavy use of async jobs or realtime features.

13. **What to draw in an architecture diagram**
   - A browser/client boundary feeding a Laravel web app.
   - Inside the app: auth/admin middleware, CRUD controllers, RBAC authorization, Eloquent models, Blade views, and document/PDF/file generation.
   - Downstream: relational database for domain and auth tables, local filesystem for uploads/public assets, and optional PDF output generation.

Main entry points: [`routes/web.php`](https://github.com/afranklinromero/sidepo/blob/main/routes/web.php) (Web routes), [`app/Models`](https://github.com/afranklinromero/sidepo/tree/main/app/Models) (Domain models), [`app/Http/Controllers/ArchivoController.php`](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ArchivoController.php) (Archivos), [`resources/views/caso`](https://github.com/afranklinromero/sidepo/tree/main/resources/views/caso) (Case views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry & HTTP"]
  node_routes_web["Web routes<br/>route map<br/>[web.php]"]
  node_routes_api["API routes<br/>route map<br/>[api.php]"]
  node_kernel{{"HTTP kernel<br/>http stack<br/>[Kernel.php]"}}
  node_admin_auth{{"Admin auth<br/>middleware<br/>[AdminAuth.php]"}}
end

subgraph group_app["Application"]
  node_auth_controllers["Auth flow<br/>controllers"]
  node_home_admin["Home admin<br/>controller<br/>[HomeController.php]"]
  node_case_crud["Casos<br/>controller<br/>[CasoController.php]"]
  node_registry_crud["Registros<br/>controller"]
  node_followup_crud["Seguimiento<br/>controller"]
  node_docs_crud["Archivos<br/>controller"]
  node_denuncia_docs["Archivodenuncia<br/>controller"]
  node_geo_crud["Geography<br/>controllers"]
  node_rbac_admin["Roles & users<br/>controllers<br/>[UserController.php]"]
  node_reports_qr["Reports & QR<br/>controllers"]
  node_models[("Domain models<br/>eloquent models")]
end

subgraph group_ui["Presentation"]
  node_views_case["Case views<br/>blade views"]
  node_views_admin["Shared UI<br/>blade views<br/>[app.blade.php]"]
  node_assets["Frontend assets<br/>vite assets<br/>[app.js]"]
end

subgraph group_data["Data & Storage"]
  node_migrations["Schema migrations<br/>database schema"]
  node_db[("Relational DB<br/>database<br/>[database.php]")]
  node_storage["Local storage<br/>filesystem"]
end

node_routes_web -->|"dispatch"| node_kernel
node_routes_api -.->|"dispatch"| node_kernel
node_kernel -->|"protects"| node_admin_auth
node_routes_web -->|"auth pages"| node_auth_controllers
node_routes_web -->|"dashboard"| node_home_admin
node_routes_web -->|"CRUD"| node_case_crud
node_routes_web -->|"CRUD"| node_registry_crud
node_routes_web -->|"CRUD"| node_followup_crud
node_routes_web -->|"CRUD"| node_docs_crud
node_routes_web -->|"CRUD"| node_denuncia_docs
node_routes_web -->|"CRUD"| node_geo_crud
node_routes_web -->|"admin"| node_rbac_admin
node_routes_web -->|"ops"| node_reports_qr
node_home_admin -->|"reads"| node_models
node_case_crud -->|"uses"| node_models
node_registry_crud -->|"uses"| node_models
node_followup_crud -->|"uses"| node_models
node_docs_crud -->|"uses"| node_models
node_denuncia_docs -->|"uses"| node_models
node_geo_crud -->|"uses"| node_models
node_rbac_admin -->|"uses"| node_models
node_reports_qr -->|"reads"| node_models
node_models -->|"defined by"| node_migrations
node_models -->|"persists"| node_db
node_docs_crud -->|"files"| node_storage
node_denuncia_docs -->|"files"| node_storage
node_views_case -->|"renders"| node_docs_crud
node_views_admin -->|"renders"| node_home_admin
node_case_crud -->|"returns"| node_views_case
node_registry_crud -->|"returns"| node_views_case
node_followup_crud -->|"returns"| node_views_case
node_assets -.->|"supports"| node_views_admin

click node_routes_web "https://github.com/afranklinromero/sidepo/blob/main/routes/web.php"
click node_routes_api "https://github.com/afranklinromero/sidepo/blob/main/routes/api.php"
click node_kernel "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Kernel.php"
click node_admin_auth "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Middleware/AdminAuth.php"
click node_auth_controllers "https://github.com/afranklinromero/sidepo/tree/main/app/Http/Controllers/Auth"
click node_home_admin "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/HomeController.php"
click node_case_crud "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/CasoController.php"
click node_registry_crud "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/RegistroController.php"
click node_followup_crud "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/SeguimientoController.php"
click node_docs_crud "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ArchivoController.php"
click node_denuncia_docs "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ArchivodenunciaController.php"
click node_geo_crud "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/DepartamentoController.php"
click node_rbac_admin "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/UserController.php"
click node_reports_qr "https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ReporterController.php"
click node_models "https://github.com/afranklinromero/sidepo/tree/main/app/Models"
click node_views_case "https://github.com/afranklinromero/sidepo/tree/main/resources/views/caso"
click node_views_admin "https://github.com/afranklinromero/sidepo/blob/main/resources/views/layouts/app.blade.php"
click node_assets "https://github.com/afranklinromero/sidepo/blob/main/resources/js/app.js"
click node_migrations "https://github.com/afranklinromero/sidepo/tree/main/database/migrations"
click node_db "https://github.com/afranklinromero/sidepo/blob/main/config/database.php"
click node_storage "https://github.com/afranklinromero/sidepo/tree/main/storage/app/public"

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_routes_web,node_routes_api,node_kernel,node_admin_auth toneBlue
class node_auth_controllers,node_home_admin,node_case_crud,node_registry_crud,node_followup_crud,node_docs_crud,node_denuncia_docs,node_geo_crud,node_rbac_admin,node_reports_qr,node_models toneAmber
class node_views_case,node_views_admin,node_assets toneMint
class node_migrations,node_db,node_storage toneRose
```

## Components

### Entry & HTTP

Request entrypoints and HTTP middleware

- [Web routes](https://github.com/afranklinromero/sidepo/blob/main/routes/web.php): route map · Main browser entrypoints and route dispatch · `routes/web.php`
- [API routes](https://github.com/afranklinromero/sidepo/blob/main/routes/api.php): route map · Secondary API surface · `routes/api.php`
- [HTTP kernel](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Kernel.php): http stack · Middleware pipeline for web requests · `app/Http/Kernel.php`
- [Admin auth](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Middleware/AdminAuth.php): middleware · Admin-only access guard · `app/Http/Middleware/AdminAuth.php`

### Application

Controllers, models, and authorization

- [Auth flow](https://github.com/afranklinromero/sidepo/tree/main/app/Http/Controllers/Auth): controllers · Login, register, password reset, verification · `app/Http/Controllers/Auth`
- [Home admin](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/HomeController.php): controller · Landing pages and operator/admin dashboard · `app/Http/Controllers/HomeController.php`
- [Casos](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/CasoController.php): controller · Core case lifecycle and case views · `app/Http/Controllers/CasoController.php`
- [Registros](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/RegistroController.php): controller · Complaint/record CRUD · `app/Http/Controllers/RegistroController.php`
- [Seguimiento](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/SeguimientoController.php): controller · Case follow-up and tracing · `app/Http/Controllers/SeguimientoController.php`
- [Archivos](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ArchivoController.php): controller · File and document management · `app/Http/Controllers/ArchivoController.php`
- [Archivodenuncia](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ArchivodenunciaController.php): controller · Complaint archive documents · `app/Http/Controllers/ArchivodenunciaController.php`
- [Geography](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/DepartamentoController.php): controllers · Departamento and municipio management · `app/Http/Controllers/DepartamentoController.php`
- [Roles & users](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/UserController.php): controllers · Users, roles, and role assignment admin · `app/Http/Controllers/UserController.php`
- [Reports & QR](https://github.com/afranklinromero/sidepo/blob/main/app/Http/Controllers/ReporterController.php): controllers · Reporting and QR code generation · `app/Http/Controllers/ReporterController.php`
- [Domain models](https://github.com/afranklinromero/sidepo/tree/main/app/Models): eloquent models · Caso, Registro, Seguimiento, Archivo, geography, users, and RBAC models · `app/Models`

### Presentation

Blade views and frontend assets

- [Case views](https://github.com/afranklinromero/sidepo/tree/main/resources/views/caso): blade views · Case, registry, follow-up, archive, and PDF pages · `resources/views/caso`
- [Shared UI](https://github.com/afranklinromero/sidepo/blob/main/resources/views/layouts/app.blade.php): blade views · Layout, menu, dashboards, auth pages, and report screens · `resources/views/layouts/app.blade.php`
- [Frontend assets](https://github.com/afranklinromero/sidepo/blob/main/resources/js/app.js): vite assets · Bundled CSS, Sass, JS, and Vue components · `resources/js/app.js`

### Data & Storage

Database schema and file storage

- [Schema migrations](https://github.com/afranklinromero/sidepo/tree/main/database/migrations): database schema · Users, cases, geography, RBAC, seguimiento, and archivodenuncia tables · `database/migrations`
- [Relational DB](https://github.com/afranklinromero/sidepo/blob/main/config/database.php): database · Primary persistence for domain, auth, and RBAC data · `config/database.php`
- [Local storage](https://github.com/afranklinromero/sidepo/tree/main/storage/app/public): filesystem · Uploads, public files, logs, and generated documents · `storage/app/public`

## Connections

- Web routes → HTTP kernel: dispatch · Web requests enter the middleware pipeline
- API routes → HTTP kernel: dispatch · API requests also pass through HTTP middleware
- HTTP kernel → Admin auth: protects · Admin routes use custom access control
- Web routes → Auth flow: auth pages · Login and registration routes map to auth controllers
- Web routes → Home admin: dashboard · Landing and operator pages are routed here
- Web routes → Casos: CRUD · Case management routes
- Web routes → Registros: CRUD · Record management routes
- Web routes → Seguimiento: CRUD · Follow-up routes
- Web routes → Archivos: CRUD · File management routes
- Web routes → Archivodenuncia: CRUD · Complaint archive document routes
- Web routes → Geography: CRUD · Geography management routes
- Web routes → Roles & users: admin · User and role administration routes
- Web routes → Reports & QR: ops · Reports and QR utilities
- Home admin → Domain models: reads · Dashboard aggregates domain data
- Casos → Domain models: uses · Case controller persists and loads Eloquent models
- Registros → Domain models: uses · Registry controller persists and loads Eloquent models
- Seguimiento → Domain models: uses · Follow-up controller persists and loads Eloquent models
- Archivos → Domain models: uses · File controller persists and loads Eloquent models
- Archivodenuncia → Domain models: uses · Complaint document controller persists and loads Eloquent models
- Geography → Domain models: uses · Geography controllers persist and load reference models
- Roles & users → Domain models: uses · Role and user admin relies on RBAC models
- Reports & QR → Domain models: reads · Reports and QR generation use case data
- Domain models → Schema migrations: defined by · Schema migrations define the persistent tables
- Domain models → Relational DB: persists · Eloquent models store data in the relational database
- Archivos → Local storage: files · Uploads and generated documents go to local storage
- Archivodenuncia → Local storage: files · Complaint archives are stored locally
- Case views → Archivos: renders · Case and document screens are served by CRUD controllers
- Shared UI → Home admin: renders · Shared dashboards and auth screens are rendered by controllers
- Casos → Case views: returns · Case controller returns Blade pages and PDF variants
- Registros → Case views: returns · Registry pages live with the domain views
- Seguimiento → Case views: returns · Follow-up pages live with the domain views
- Frontend assets → Shared UI: supports · Bundled frontend assets enhance Blade pages
