Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/corpentunida-org/corpen/llms.txt

Use this file to discover all available pages before exploring further.

Corpen follows a classic MVC architecture on top of Laravel 11, extended with Livewire 3 for reactive components and Blade for server-rendered views. Every feature domain is organized as a self-contained module: its own route group with a URL prefix, a dedicated Controllers/ subdirectory, a mirrored Models/ subdirectory, and a matching resources/views/ subtree. There is no micro-service boundary or API gateway — all modules share one database, one authentication session, and one Spatie permission store, which is the key design choice that allows cross-module data lookups (e.g., an Interaction can reference the same MaeTerceros record that an insurance policy uses).

High-Level Architecture

Browser / PWA client


   Apache (port 80 in container, 83 on host)


   Laravel 11 HTTP Kernel
   ├── Global middleware: TrustHosts, TrustProxies, StartSession
   ├── Web group: EncryptCookies, AddQueuedCookiesToResponse, SubstituteBindings
   ├── Route middleware aliases:
   │   ├── auth          → Illuminate\Auth\Middleware\Authenticate
   │   ├── can           → Illuminate\Auth\Middleware\Authorize
   │   └── candirect     → App\Http\Middleware\CanDirect  ← custom


   Route groups (web.php — 1 266 lines)
   Each module: Route::prefix(…)->middleware(['auth'])->group(…)


   Controllers (app/Http/Controllers/<Module>/)

       ├── Eloquent Models (app/Models/<Module>/)
       ├── Exports/Imports (app/Exports/, app/Imports/)
       ├── Livewire components (resources/views/livewire/ if present)
       └── Blade views (resources/views/<module>/)
Vite compiles resources/css/app.css and resources/js/app.js into versioned bundles under public/build/. Tailwind CSS (with @tailwindcss/forms and @tailwindcss/typography) is configured to scan all Blade files and Jetstream vendor views. The font stack defaults to Figtree via a theme.extend.fontFamily.sans override.

Module Reference

The table below maps every module to its URL prefix, primary controller namespace, and representative key routes derived from routes/web.php.
The candirect middleware alias (registered in bootstrap/app.php) maps to App\Http\Middleware\CanDirect. Unlike the standard can: guard which checks role-inherited permissions, CanDirect calls $user->getDirectPermissions() and matches only explicitly assigned direct permissions for the authenticated user. If none of the passed permission names appear in the user’s direct permissions, the middleware aborts with a 404 — Página no encontrada response. This makes sensitive module entry points (e.g., candirect:seguros.poliza.index, candirect:correspondencia.usuario.admin) invisible rather than forbidden, preventing enumeration of restricted features.

Core & Member Management

ModuleURL PrefixController NamespaceKey Named Routes
Dashboard/IndexControllerdashboard
Associates/asociadosAsociado\MaeAsociadoControllerasociados.dashboard, asociados.maestro.*, asociados.ecm.index, asociados.sincronizar.*
Demographics/demograficosDemografia\DemografiaControllerdemograficos.dashboard, demograficos.maestro.*, demograficos.sincronizar.*
Master Data/maestrasMaestras\Mae*Controllermaestras.terceros.*, maestras.tipos.*, maestras.congregacion.*, maestras.departamentos.listar, maestras.municipios.listar
Admin/users, /roles, /permisosAdmin\UserController, Admin\RoleController, Admin\PermissionsControlleradmin.users.*, admin.roles.*, admin.permisos.*, admin.auditoria.*

Finance

ModuleURL PrefixController NamespaceKey Named Routes
Accounting/contabilidadContabilidad\ConCuentaBancariaController, ConExtractoTransaccionController, ExcelSyncControllercontabilidad.cuentas-bancarias.*, contabilidad.extractos.*, contabilidad.extractos.conciliacion, contabilidad.sincronizar.*, contabilidad.mantenimiento
Portfolio (Cartera)/carteraCartera\CarComprobantePagoController, ReadExelControllercartera.comprobantes.*, cartera.morosos.index, cartera.morosos.pdfMora
Collections (Recaudo)/recaudoRecaudo\RecImputacionContableControllerrecaudo.imputaciones.*, recaudo.buscar-distrito
Credits/creditosCreditos\CreditoControllercreditos.credito.*
Five-Percent Fund/cinco, /retirosCinco\TercerosController, MoviContCincoController, RetirosListadoController, CondicionesRetirosControllercinco.tercero.*, cinco.movcontables.*, cinco.reportepdf, cinco.retiros.*, cinco.condicionRetiros.*, cinco.liquidacionretiro

Operations

ModuleURL PrefixController NamespaceKey Named Routes
Exequial/exequialesExequial\ComaeExCliController, MaeC_ExSerController, ComaeTerController, ComaeExRelParControllerexequial.asociados.*, exequial.prestarServicio.*, exequial.beneficiarios.*, exequial.terceros.*, asociados.generarpdf, prestarServicio.generate.excel
Insurance/segurosSeguros\SegPolizaController, SegPlanController, SegBeneficiarioController, SegCoberturaController, SegConvenioController, SegReclamacionesController, SegNovedadesController, SegBeneficiosController, SegCondicionesControllerseguros.poliza.*, seguros.planes.*, seguros.cobertura.*, seguros.beneficiario.*, seguros.convenio.*, seguros.reclamacion.*, seguros.novedades.*, seguros.beneficios.*, seguros.reclamaciones.dashboard
Reservations/reservasReservas\ResReservaController, ResInmuebleController, ResDashboardControllerreserva.dashboard, reserva.reserva.*, reserva.crudinmuebles.*, reserva.inmueble.confirmacion, reserva.inmueble.historico, reserva.reservas.pago
Inventory/inventarioInventario\ActivoController, CompraController, MovimientoController, MantenimientoController, MarcaController, BodegaController, EstadoController, MetodoPagoController, ClasificacionController, TableroInventarioControllerinventario.tablero, inventario.activos.*, inventario.compras.*, inventario.movimientos.*, inventario.mantenimientos.*, inventario.marcas.*, inventario.bodegas.*, inventario.clasificacion.*

Document & Correspondence

ModuleURL PrefixController NamespaceKey Named Routes
Document Archive/archivoArchivo\GdoCargoController, GdoAreaController, GdoEmpleadoController, GdoTipoDocumentoController, GdoCategoriaDocumentoController, GdoFuncionControllerarchivo.cargo.*, archivo.area.*, archivo.empleado.*, archivo.gdotipodocumento.*, archivo.categorias.*, archivo.funcion.*
Correspondence/correspondenciaCorrespondencia\CorrespondenciaController, FlujoDeTrabajoController, ProcesoController, TrdController, PlantillaController, ComunicacionSalidaController, CorrespondenciaProcesoController, CorrEstadoController, MedioRecepcionControllercorrespondencia.tablero, correspondencia.correspondencias.*, correspondencia.flujos.*, correspondencia.procesos.*, correspondencia.trds.*, correspondencia.plantillas.*, correspondencia.comunicaciones-salida.*, correspondencia.medios-recepcion.*
Workflow Engine (Flujo)/flujoFlujo\WorkflowController, TaskController, TaskHistoryController, TaskCommentController, TableroController, AuditoriaProyectosControllerflujo.tablero, flujo.workflows.*, flujo.tasks.*, flujo.histories.*, flujo.comments.*, flujo.auditoria.index, flujo.auditoria.pdf

CRM & Engagement

ModuleURL PrefixController NamespaceKey Named Routes
CRM Interactions/interactionsInteracciones\InteractionController, IntChannelController, IntTypeController, IntOutcomeController, IntNextActionController, IntSeguimientoController, IntWorkspaceController, IntConversationController, IntMessageController, IntChatControllerinteractions.index, interactions.report, interactions.chat.index, interactions.channels.*, interactions.types.*, interactions.outcomes.*, interactions.next_actions.*, interactions.workspaces.*, interactions.conversations.*, interactions.messages.*
Visits/visitasVistas\VisitaCorpenControllervisitas.tablero, visitas.corpen.*, visitas.cliente.buscar
Support Tickets/soportesSoportes\ScpSoporteController, ScpEstadoController, ScpPrioridadController, ScpTipoController, ScpCategoriaController, ScpUsuarioController, ScpNotificacionController, ScpEstadisticaController, ScpTableroParametroControllersoportes.tablero, soportes.estadisticas, soportes.soportes.*, soportes.pendientes, soportes.mis-soportes, soportes.sinAsignar, soportes.categorias.*, soportes.estados.*, soportes.prioridades.*, soportes.tipos.*
Indicators & Quizzes/indicatorsIndicators\QuizController, IndicadoresControllerindicators.quiz.inicio, indicators.quiz.preguntas, indicators.quizes.*, indicators.indicadores.*, indicators.indicadores.descargar

Folder Structure

app/
├── Actions/
│   ├── Fortify/          # Jetstream/Fortify authentication actions
│   └── Jetstream/        # Profile photo, team actions
├── Console/
│   ├── Kernel.php
│   └── Commands/
│       └── Reservas/     # Scheduled commands for reservation auto-cancellation
├── Enums/
│   ├── AcuerdoEstadoEnum.php
│   └── NotificacionEstadoEnum.php
├── Exports/
│   ├── Asociado/
│   ├── Demografia/
│   ├── ReporteSiniestrosExport.php
│   └── TransaccionesExport.php
├── Http/
│   ├── Controllers/      # One subdirectory per module (see table above)
│   ├── Middleware/
│   │   └── CanDirect.php # Custom direct-permission guard
│   └── Requests/
├── Imports/
│   ├── Asociado/
│   ├── Cartera/
│   ├── Contabilidad/
│   ├── Demografia/
│   ├── ExcelExport.php
│   ├── ExcelImport.php
│   └── PolizasImport.php
├── Mail/
│   ├── FlujoNotificacion.php
│   ├── ReservaInmueble.php
│   └── SoporteEscaladoMail.php
├── Models/               # Mirroring controller namespaces:
│   ├── Archivo/          # GdoArea, GdoCargo, GdoEmpleado, GdoFuncion, GdoTipoDocumento…
│   ├── Asociado/         # MaeAsociado
│   ├── Cartera/          # CarComprobantePago, Acuerdo
│   ├── Cinco/            # MoviContCinco, Retiros, Terceros, CuentasContables…
│   ├── Contabilidad/     # ConCuentaBancaria, ConExtractoTransaccion
│   ├── Correspondencia/  # Correspondencia, FlujoDeTrabajo, Proceso, Plantilla, Trd, ComunicacionSalida…
│   ├── Creditos/         # Credito, LineaCredito, Garantia, Etapa, Escritura…
│   ├── Demografia/
│   ├── Exequiales/
│   ├── Flujo/            # Workflow, Task, TaskHistory, TaskComment
│   ├── Indicators/
│   ├── Interacciones/    # Interaction, IntChannel, IntType, IntOutcome, IntNextAction…
│   ├── Inventario/       # InvActivo, InvCompra, InvMovimiento, InvMantenimiento…
│   ├── Maestras/         # MaeTerceros, MaeTipos, MaeCongregacion, MaeMunicipios
│   ├── Recaudo/
│   ├── Reserva/          # Res_reserva, Res_inmueble, Res_status, Res_condicion…
│   ├── Seguros/          # SegPoliza, SegPlan, SegBeneficiario, SegCobertura, SegConvenio, SegReclamaciones…
│   ├── Soportes/         # ScpSoporte, ScpCategoria, ScpEstado, ScpPrioridad, ScpTipo…
│   ├── Tesoreria/        # Pago
│   ├── Vistas/           # VisitaCorpen
│   ├── User.php          # Uses HasRoles, HasApiTokens, Notifiable
│   ├── Role.php
│   ├── Permisos.php
│   ├── Action.php
│   └── auditoria.php
├── Policies/
│   └── UserPolicy.php
├── Providers/
│   ├── AppServiceProvider.php
│   ├── AuthServiceProvider.php
│   ├── FortifyServiceProvider.php
│   └── JetstreamServiceProvider.php
└── Services/
    └── GoogleDriveService.php

Role-Based Access Control

Corpen uses Spatie Laravel Permission 6.9 for its permission model. The User model mixes in the HasRoles trait:
// app/Models/User.php
use Spatie\Permission\Traits\HasRoles;

class User extends Authenticatable
{
    use HasApiTokens;
    use Notifiable;
    use HasRoles;
    // ...
}
The seeder creates five base roles:
// database/seeders/RoleSeeder.php
Role::create(['name' => 'admin']);
Role::create(['name' => 'exequial']);
Role::create(['name' => 'creditos']);
Role::create(['name' => 'seguros']);
Role::create(['name' => 'read']);
Route-level enforcement uses two complementary guards:
  • can: middleware — standard Spatie gate check; passes when the user holds the permission directly or via a role.
  • candirect: middleware — custom CanDirect class; passes only when the named permission appears in getDirectPermissions(). Used for high-sensitivity entry points like candirect:admin.users.index, candirect:seguros.poliza.index, and candirect:correspondencia.usuario.admin.
The CanDirect middleware aborts with 404 (not 403) when access is denied. This is a deliberate security design: unauthorized users see a “page not found” response rather than a “forbidden” response, preventing role and permission enumeration through the HTTP status code. The logic lives in app/Http/Middleware/CanDirect.php and is registered as the candirect alias in bootstrap/app.php.
The actions table joins users to roles for the IndexController redirect logic. The model_has_permissions and model_has_roles tables (Spatie standard schema, created by migration 2024_11_05_135024_create_permission_tables.php) drive all middleware checks at runtime.

Storage & Cloud Integrations

Corpen supports three storage backends, configured via the FILESYSTEM_DISK environment variable and the standard Laravel config/filesystems.php disks:
DriverPackageUsed By
localLaravel built-inDevelopment, view caches
s3league/flysystem-aws-s3-v3 3.0Document Archive (archivo), Inventory (inventario), Cartera — employee photos, function manuals, purchase invoices, movement acts
Google Cloud Storagegoogle/cloud-storage 1.48GoogleDriveService in app/Services/
SFTPleague/flysystem-sftp-v3 3.0Optional alternative storage target
The AWS S3 disk is configured with AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION, AWS_BUCKET, and optionally AWS_ENDPOINT for custom S3-compatible endpoints. The GdoEmpleadoController::verFoto() method generates signed S3 URLs to serve private employee profile photos without exposing bucket credentials.

Export, Import, and PDF Generation

CapabilityPackageExample Usage
Excel exportmaatwebsite/excel 3.1ReporteSiniestrosExport, TransaccionesExport, associate and demographic exports, policy benefit reports
Excel importmaatwebsite/excel + phpoffice/phpspreadsheetPolizasImport, cartera morosos upload, asociado/demographic mass sync
PDF generationbarryvdh/laravel-dompdf 2.2Exequial service PDFs, insurance claim reports, credit documents, inventory asset sheets, correspondence history PDFs, workflow audit PDFs
Chartsarielmejiadev/larapex-charts 2.1Support ticket statistics dashboard, inventory tablero, interaction reports

Progressive Web App

The PWA manifest is managed by silviolleite/laravelpwa 2.0. Corpen registers a service worker and manifest at the application level. An offline fallback is served at:
Route::get('/offline', function () {
    return view('vendor.laravelpwa.offline');
});
This route is intentionally outside the auth middleware group so that installed PWA clients can render an offline page without an active session, which is important for field agents with intermittent connectivity.

Build docs developers (and LLMs) love