How danielayala-06/proyecto-de-innovacion works
1. Overall shape
- This is a CodeIgniter 4 / PHP 8.2 monolith with a layered backend and a browser-based frontend.
- The main business domains are cotizaciones, contratos, clientes, paquetes, pagos, promociones, personas/usuarios, and supporting academic entities like colegios, estudiantes y apoderados.
2. Request entry and HTTP boundary
- All web traffic enters through public/index.php.
- The app exposes both HTML pages and REST-style API endpoints.
- Apache rewrite rules are handled by the .htaccess files in public/ and app/.
3. Routing and cross-cutting controls
- app/Config/Routes.php defines the HTTP surface.
- app/Filters/AuthFilter.php is the key access-control boundary, likely protecting authenticated areas and API routes.
- Other CI4 configs in app/Config/ control environment bootstrapping, sessions, security, CORS, validation, logging, and database connectivity.
4. Backend layering
- The repository follows a clear pipeline:
- Controllers receive requests and orchestrate responses.
- Services hold domain logic.
- Models access the database.
- Transformers shape API responses into JSON-friendly output.
- This separation is explicit in the folders app/Controllers, app/Services, app/Models, and app/Transformers.
5. Domain controllers
- There are standard UI controllers such as ClienteController, ContratoController, CotizacionController, PaqueteController, CalendarioController, and AuthController.
- API controllers live under app/Controllers/Api and mirror core business areas: ClientesApi, ContratosApi, CotizacionesApi, PagosApi, PaquetesApi, PromocionesApi, ReniecApi.
- The presence of ReniecApi suggests integration with an external identity/document lookup service.
6. Business services
- Domain logic is concentrated in feature-specific services:
- ClienteService
- ContratoService
- CotizacionService
- PagoService
- PaqueteService
- PromocionService
- These services form the main boundary between HTTP controllers and persistence, especially for operations that combine multiple tables or business rules.
7. Persistence model and schema
- Data is persisted in MySQL through CodeIgniter models such as ClientesModel, ContratosModel, CotizacionesModel, PagosModel, PaquetesModel, UsuariosModel, etc.
- The schema is managed with many migrations covering:
- identity and authorization: Personas, Usuarios, Roles, Permisos, RolesPermisos
- commercial operations: Clientes, Cotizaciones, CotizacionesDetalles, Contratos, Pagos
- products and offers: Productos, Paquetes, PaquetesProductos, ReglasPaquetes, PromocionesEscolares
- supporting entities: Colegios, Estudiantes, Apoderados, SesionesFotograficas, FormasPago
- Seeders provide initial/reference data for these tables.
8. Response formatting
- API output is normalized through Transformers for each major domain: ClienteTransformer, ContratoTransformer, CotizacionTransformer, PagoTransformer, PaqueteTransformer, PromocionTransformer.
- This means the API boundary is intentionally decoupled from raw model structure and can enforce consistent response shapes.
9. Frontend structure
- The browser UI is server-rendered with CodeIgniter Views for pages like login, clientes, contratos, cotizaciones, paquetes, calendario, and PDF output.
- The frontend also has a modular JavaScript layer under public/js/modules, organized by domain:
- cotizaciones
- contratos
- paquetes
- Each module is split into state, UI, events, form/manager files, indicating a client-side interaction layer that talks to the backend APIs.
10. Client-server interaction
- JavaScript API wrappers in public/js/api/ call the backend endpoints for each domain.
- Shared utilities in public/js/utils/ handle HTTP, alerts, and formatting.
- This creates a clean flow: UI module → API wrapper → controller/API → service → model → database, with transformers shaping the response on the way back.
11. Authentication and session handling
- Authentication is centered around AuthController, filtered routes, session config, and the Usuarios/Roles/Permisos schema.
- The architecture suggests role-based access control rather than a flat login-only system.
12. Reporting and document generation
- There is a dedicated PDF view at app/Views/pdf/contrato.php, plus contract styling in public/css/contrato_styles.css.
- This indicates at least one document-generation path for contract output, separate from normal page rendering.
13. Operational and developer tooling
- Composer manages PHP dependencies.
- Spark is used for migrations, seeding, and local serving.
- The tests/ tree includes CI4 support fixtures plus database, session, and unit tests, showing the project is structured for framework-level testing.
14. Architecture summary for diagramming
- The main diagram should show three major zones:
- Browser/UI: server-rendered views plus modular JS calling APIs.
- Application layer: controllers, auth filter, services, transformers.
- Data layer: models, migrations, seeders, MySQL.
- External dependencies are limited but important: MySQL for persistence and RENIEC for identity-related lookup/integration.
Main entry points: ClientesApi.php API controllers · ClientesModel.php Models · Routes.php Routes · ClienteController.php UI controllers
Components 22
Browser/UI
Server-rendered views and client-side modules
- Views · Login, clientes, contratos, cotizaciones, paquetes, calendario, PDF
app/Views/contratos/index.php - JS modules · Domain UI state, events, forms, and managers
public/js/modules/contratos/contrato.manager.js - JS API · Browser wrappers for backend endpoints
public/js/api/contrato.api.js - HTTP utils · Shared request, alert, and formatting helpers
public/js/utils/http.js
Application
HTTP boundary, routing, controllers, filters, services, and transformers
- Auth filter · Protects authenticated routes and APIs
app/Filters/AuthFilter.php - Auth · Login and session entry
app/Controllers/AuthController.php - UI controllers · Clientes, contratos, cotizaciones, paquetes, calendario
app/Controllers/ClienteController.php - API controllers · Clientes, contratos, cotizaciones, pagos, paquetes, promociones, Reniec
app/Controllers/Api/ClientesApi.php - Cliente service · Cliente business rules
app/Services/Clientes/ClienteService.php - Contrato service · Contract orchestration
app/Services/Contratos/ContratoService.php - Cotización service · Quotation workflow
app/Services/Cotizaciones/CotizacionService.php - Pago service · Payment logic
app/Services/Pagos/PagoService.php - Paquete service · Package and bundle rules
app/Services/Paquetes/PaqueteService.php - Promoción service · School promotion rules
app/Services/Promociones/PromocionService.php - Transformers · Normalizes API payloads
app/Transformers/ClienteTransformer.php
Data
Persistence, migrations, and seed data
- Models · CI4 models for core domains
app/Models/ClientesModel.php - Migrations · Database schema evolution
app/Database/Migrations/2026-05-07-035257_Personas.php - Seeders · Initial and fixture data
app/Database/Seeds/DatabaseSeeder.php
Connections 29
- index.php → Routes: bootstraps · Front controller hands off to route resolution
- Routes → Auth filter: guards · Applies access control to protected surfaces
- Routes → Auth: maps · Routes login and session endpoints
- Routes → UI controllers: maps · Routes browser-facing pages
- Routes → API controllers: maps · Routes REST-style endpoints
- Auth → Views: renders · Login page and session-related views
- UI controllers → Views: renders · Server-side page rendering
- UI controllers → JS modules: serves · Pages load modular client scripts
- JS modules → JS API: calls · UI modules invoke domain API wrappers
- JS API → API controllers: requests · Browser requests reach backend APIs
- API controllers → Cliente service: orchestrates · Clientes API delegates business logic
- API controllers → Contrato service: orchestrates · Contratos API delegates business logic
- API controllers → Cotización service: orchestrates · Cotizaciones API delegates business logic
- API controllers → Pago service: orchestrates · Pagos API delegates business logic
- API controllers → Paquete service: orchestrates · Paquetes API delegates business logic
- API controllers → Promoción service: orchestrates · Promociones API delegates business logic
- Cliente service → Models: reads/writes · Services coordinate persistence through models
- Contrato service → Models: reads/writes · Services coordinate persistence through models
- Cotización service → Models: reads/writes · Services coordinate persistence through models
- Pago service → Models: reads/writes · Services coordinate persistence through models
- Paquete service → Models: reads/writes · Services coordinate persistence through models
- Promoción service → Models: reads/writes · Services coordinate persistence through models
- API controllers → Transformers: formats · API responses are normalized before returning
- Transformers → Views: separates · Keeps API shapes distinct from page templates
- Models → MySQL: persists to · CI4 models store domain data in MySQL
- Migrations → MySQL: defines schema · Schema evolution targets the same database
- Seeders → MySQL: loads data · Reference and initial data populate tables
- API controllers → RENIEC: integrates · RENIEC lookup is exposed as an API boundary
- UI controllers → Auth filter: protected by · Authenticated pages are filtered at entry