How mroblesdev/pos-cdp-lite works
1. Application type and runtime boundary
This is a CodeIgniter 4 PHP application for a point-of-sale system. The runtime entrypoint is public/index.php, with Apache rewrite rules in public/.htaccess and app-specific rewrite support in app/.htaccess. The app persists business data in MySQL and stores runtime artifacts in writable/ (logs, cache, sessions, uploads).
2. Framework vs. application code
The repo is split into the CodeIgniter framework (system/) and the business application (app/). The architectural diagram should treat app/ as the custom POS layer on top of CI4, while system/ is the reusable framework runtime providing routing, request/response handling, sessions, validation, database access, and views.
3. Request handling pipeline
Incoming HTTP requests flow through CI4 boot/configuration (app/Config/*, especially Routes.php, Filters.php, Services.php, Database.php) and then into controller actions. The app uses an AuthFilter to guard protected pages, so authenticated access is a key boundary between public login traffic and the internal POS modules.
4. Authentication and session state
app/Controllers/Login.php is the primary public entry point for users. Successful login likely creates session state through CI4’s session subsystem, and subsequent requests are allowed through app/Filters/AuthFilter.php. The application’s stateful behavior depends on session management plus user records in UsuariosModel.
5. Core POS modules
The main business subsystems are organized by controller:
- Inicio for the dashboard/home screen
- Productos for catalog management
- Ventas for sales workflow, sale history, cancellations, and ticketing
- Caja for cash register / checkout state
- Configuracion for system settings
- Reportes for sales and product reports
These controllers are backed by matching views under app/Views/ and models under app/Models/.
6. Data model and persistence
Persistence is centered on a small transactional schema managed by migrations and seeders. The key domain entities are: usuarios, productos, configuracion, temporal_caja, ventas, detalle_venta, and vista_ventas. Migrations in app/Database/Migrations/ define schema evolution, while seeders in app/Database/Seeds/ provide bootstrap data such as default users and configuration. A full SQL snapshot is also included at app/Database/pos-cdp-lite.sql.
7. Sales flow and transactional boundary
The sales subsystem appears to use a multi-step flow: a cash register state is stored in TemporalCajaModel, sales headers in VentasModel, and line items in DetalleVentasModel. This implies a transactional boundary where product selection, checkout, and ticket generation are tightly coupled to database writes. Historical sales and cancellations are handled from the Ventas controller and related views.
8. Reporting and document generation
Reports and printable artifacts are a distinct subsystem. app/Controllers/Reportes.php serves report views, and app/ThirdParty/Fpdf/ provides PDF generation for tickets and reports via custom templates like PlantillaVentas.php and PlantillaProductos.php. NumerosALetras.php supports converting amounts to text, which is typically used in printable documents.
9. Presentation layer
The UI is built with server-rendered views under app/Views/, organized by module and shared layout. Shared shell components live in app/Views/plantilla/ (layout.php, menu.php), while module views live under productos/, ventas/, reportes/, and configuracion/. Front-end assets in public/assets/, public/css/, and public/js/ include DataTables and jQuery UI, indicating table-heavy admin screens and interactive forms.
10. Cross-cutting framework services
CI4 configuration files under app/Config/ define the app’s security, session, database, validation, and routing behavior. Language files in app/Language/ support localized validation messages in English and Spanish. The presence of standard CI4 filters, security, and validation layers means these concerns are handled centrally rather than inside each controller.
11. Operational and deployment boundaries
The app is designed to be deployed either through Apache or via php spark serve during development. env/.env controls environment-specific settings such as baseURL and MySQL credentials. Runtime write paths are isolated in writable/, which is important for logs, session persistence, cache, and uploaded files.
12. Testing and maintenance surface
The repository includes CI4 test scaffolding under tests/, covering unit, database, and session examples. That suggests the architecture is already partitioned enough to support framework-level and domain-level testing, even though the main app is relatively compact.
Main entry points: Routes.php Routes · AuthFilter.php Auth guard · Ventas.php Sales · Login.php Login
Components 34
Runtime
HTTP entrypoints and writable deployment state
- Front controller · Main HTTP entrypoint for the application
public/index.php - Web rewrite · Apache rewrite rules for public routing
public/.htaccess - App rewrite · Application-level rewrite support
app/.htaccess - Writable state · Logs, cache, sessions, and uploads
POS App
Custom CodeIgniter 4 application layer for the point-of-sale domain
- Routes · URL-to-controller mapping
app/Config/Routes.php - Filters · Request filters including auth boundary
app/Config/Filters.php - Services · Framework service wiring for app behavior
app/Config/Services.php - Database config · MySQL connection and persistence settings
app/Config/Database.php - Login · Public authentication entrypoint
app/Controllers/Login.php - Auth guard · Protects authenticated POS pages
app/Filters/AuthFilter.php - Home · Dashboard and landing screen
app/Controllers/Inicio.php - Products · Product catalog management
app/Controllers/Productos.php - Sales · Checkout, history, cancellations, and tickets
app/Controllers/Ventas.php - Cash desk · Register state and checkout workflow
app/Controllers/Caja.php - Settings · System configuration management
app/Controllers/Configuracion.php - Reports · Sales and product reporting
app/Controllers/Reportes.php
Data
Database schema, seed data, and persistence models
- Users model · User persistence and login lookup
app/Models/UsuariosModel.php - Products model · Product catalog persistence
app/Models/ProductosModel.php - Sales model · Sales header persistence
app/Models/VentasModel.php - Line items · Sale detail persistence
app/Models/DetalleVentasModel.php - Caja state · Temporary cash register state
app/Models/TemporalCajaModel.php - Config model · Application settings persistence
app/Models/ConfiguracionModel.php - Usuarios schema · Database migration for users
app/Database/Migrations/2024-01-30-144522_Usuarios.php - Ventas schema · Database migration for sales and details
app/Database/Migrations/2024-02-06-204639_Ventas.php - Seed data · Initial users, configuration, and sample data
app/Database/Seeds/CargaSeeder.php - SQL snapshot · Full MySQL snapshot of the POS schema
app/Database/pos-cdp-lite.sql
Presentation
Server-rendered views, shared layout, and public assets
- Views · Server-rendered UI templates
- Layout · Common page chrome and menu
app/Views/plantilla/layout.php - Menu · Shared navigation component
app/Views/plantilla/menu.php - Login view · Rendered login form
app/Views/login.php - Assets · CSS, JavaScript, DataTables, and jQuery UI
public/css/styles.css - PDF engine · Ticket and report PDF generation
app/ThirdParty/Fpdf/Fpdf.php - Numbers to words · Converts amounts for printable documents
app/ThirdParty/NumerosALetras.php
Other components
- CI4 runtime · Reusable CodeIgniter 4 framework layer
system/CodeIgniter.php
Connections 48
- Web rewrite → Front controller: rewrites to
- App rewrite → Front controller: supports routing
- Front controller → CI4 runtime: boots
- Front controller → Routes: loads
- Routes → Login: public route
- Routes → Home: protected route
- Routes → Products: protected route
- Routes → Sales: protected route
- Routes → Cash desk: protected route
- Routes → Settings: protected route
- Routes → Reports: protected route
- Filters → Auth guard: registers
- Auth guard → Login: allows public access
- Auth guard → Home: protects
- Auth guard → Products: protects
- Auth guard → Sales: protects
- Auth guard → Cash desk: protects
- Auth guard → Settings: protects
- Auth guard → Reports: protects
- Login → Users model: verifies user
- Login → Services: uses
- Login → Writable state: writes session/logs
- Login → Login view: renders
- Home → Views: renders
- Products → Products model: reads/writes
- Products → Views: renders
- Sales → Sales model: persists header
- Sales → Line items: persists items
- Sales → Caja state: uses register state
- Sales → PDF engine: generates tickets
- Sales → Numbers to words: formats amounts
- Sales → Views: renders
- Cash desk → Caja state: updates state
- Cash desk → Views: renders
- Settings → Config model: updates settings
- Settings → Views: renders
- Reports → Sales model: queries sales
- Reports → Products model: queries products
- Reports → PDF engine: exports pdf
- Reports → Views: renders
- Views → Layout: uses shell
- Views → Menu: uses nav
- Views → Assets: loads
- CI4 runtime → Database config: provides db layer
- CI4 runtime → Services: provides services
- CI4 runtime → Filters: provides filter runtime
- CI4 runtime → Writable state: uses runtime storage
- Usuarios schema → Users model: defines schema for