How mafo2017/dms_enterprise works
1. Overall shape
- This is a PHP 8.2+ monolith built around a strict MVC-style architecture.
- The codebase is split into a browser-facing application and a separate REST API, both sharing the same core, models, and database.
2. Request entry points
- public/index.php is the main web entry point for the frontend.
- api/index.php is the API entry point.
- The public/ directory is the web root, while storage/ and logs/ are kept outside normal public access and protected with .htaccess.
3. Framework core
- The core/ folder acts as a lightweight internal framework:
- Router.php dispatches requests.
- Controller.php and View.php support rendering and response handling.
- Model.php and Database.php provide persistence access.
- Auth.php and Security.php centralize authentication and security checks.
- This suggests a custom framework rather than Laravel/Symfony.
4. Frontend presentation layer
- Browser UI controllers live under Controllers/frontend/.
- HTML rendering is handled by templates in public/views/, organized by feature:
- auth/
- dashboard/
- documents/
- series/
- users/
- audit/
- shared layouts/ and partials/
- The frontend likely follows a classic server-rendered flow: controller → model → view.
5. API layer
- API controllers live under Controllers/api/v1/, indicating explicit versioning.
- The API has feature-specific endpoints for authentication, documents, users, audit, and series.
- Responses are presumably JSON-based and used for integration with external systems.
6. Domain subsystems
- The main business areas are:
- Document management (Document, DocumentVersion, DocumentMetadata, DocumentAccessLog)
- User and role management (User, Role)
- Authentication and recovery (RefreshToken, PasswordReset)
- Audit and security (AuditLog, SecurityLog)
- Retention/compliance (RetentionSchedule, RetentionAlert)
- Notifications and settings (Notification, SystemSetting)
- Series appears to model document classification or filing structure.
7. Persistence and data model
- The app uses MySQL 8+ through the custom database layer in core/Database.php.
- Each domain object has a corresponding model in models/, which likely encapsulates queries and business rules.
- Database setup artifacts include base.sql, datos.sql, and import helpers like import_db.php and execute_db.bat.
8. Security architecture
- The README indicates layered security: sessions + JWT, 2FA TOTP, password reset, refresh tokens, and security logging.
- core/Security.php and core/Auth.php likely enforce input validation, authorization, and session/token handling.
- The presence of logs/php_errors.log and SecurityLog suggests runtime security events are tracked separately from application audit events.
9. Audit and compliance
- Audit is a first-class subsystem, not an afterthought:
- AuditApiController.php / AuditController.php
- AuditLog and DocumentAccessLog
- Retention management (RetentionSchedule, RetentionAlert) aligns with ISO 15489 document lifecycle requirements.
- The repository also includes compliance checklists for ISO 15489, ISO 27001, and OWASP, which are supporting artifacts for governance and verification.
10. Document lifecycle boundaries
- The document domain is more than CRUD: it includes versions, metadata, access history, and retention rules.
- That implies a flow where documents are created/updated through controllers, persisted via models, and audited at each meaningful action.
- The architecture is designed to preserve traceability and compliance, not just store files.
11. Operational and deployment boundaries
- .env / .ENV.EXAMPLE and config/config.php / config/database.php separate environment configuration from code.
- storage/ and logs/ are writable runtime areas, likely for files, generated artifacts, and error/audit logs.
- public/.htaccess and logs/.htaccess indicate Apache-oriented hardening, though the app can also be hosted behind Nginx with equivalent routing.
12. Supporting material in the repo
- The repository includes substantial documentation: installation, user manual, architecture notes, testing plan, and security characteristics.
- Files like CHECKLIST_*.txt, manual_instalacion.txt, and manual_usuario.txt suggest the project is intended for audited enterprise deployment rather than a minimal prototype.
13. Mental model for a diagram
- The cleanest diagram would show:
- Clients entering through web frontend or REST API
- Both routed through front controllers / router
- Shared core services for auth, security, database, and view rendering
- Feature controllers calling domain models
- Models persisting to MySQL
- Supporting stores for logs, storage, and compliance/audit records
Main entry points: frontend Frontend ctrls · v1 API v1 ctrls · Document.php Document · Router.php Router
Components 27
Entry points
Browser and API front controllers
Application
Frontend, API controllers, and views
- Frontend ctrls · Browser-facing controllers for auth, dashboard, documents, series, users, and audit
Controllers/frontend - API v1 ctrls · Versioned REST controllers for auth, documents, series, users, and audit
Controllers/api/v1 - Views · Server-rendered pages and layouts
public/views
Core framework
Shared routing, controller, auth, security, and persistence primitives
- Router · Central request dispatcher
core/Router.php - Base ctl · Shared controller behavior
core/Controller.php - View · Template rendering and response output
core/View.php - Auth · Authentication and session/token handling
core/Auth.php - Security · Input validation and authorization checks
core/Security.php - Model · Shared model persistence layer
core/Model.php - Database · Database connection and queries
core/Database.php
Domain model
Business entities and compliance-related records
- User · Users and profile data
models/User.php - Role · Authorization roles
models/Role.php - Document · Core document aggregate
models/Document.php - Versions · Document revision history
models/DocumentVersion.php - Metadata · Document classification and descriptive data
models/DocumentMetadata.php - Access log · Document access history
models/DocumentAccessLog.php - Audit log · Application activity audit trail
models/AuditLog.php - Security log · Security-relevant event records
models/SecurityLog.php - Retention · Retention schedules and alerts
models/RetentionSchedule.php - Tokens · Refresh token storage
models/RefreshToken.php
Runtime and config
Environment, storage, logs, and database setup
Connections 31
- Web entry → Router: dispatches · Web requests are routed into the shared dispatcher
- API entry → Router: dispatches · API requests are routed into the shared dispatcher
- Router → Frontend ctrls: routes to · Browser routes are handled by frontend controllers
- Router → API v1 ctrls: routes to · API routes are handled by versioned API controllers
- Frontend ctrls → Base ctl: extends · Frontend controllers share common controller behavior
- API v1 ctrls → Base ctl: extends · API controllers share common controller behavior
- Frontend ctrls → Views: renders · Frontend controllers render server-side views
- Frontend ctrls → Auth: uses · Authentication and session checks
- Frontend ctrls → Security: uses · Authorization and validation checks
- API v1 ctrls → Auth: uses · Token/session based API authentication
- API v1 ctrls → Security: uses · API request validation and protection
- Base ctl → View: uses · Controllers rely on view rendering helpers
- Base ctl → Model: uses · Controllers coordinate with models through the shared base
- Model → Database: persists via · Models execute database access through the shared database layer
- Document → Versions: has · Documents maintain version history
- Document → Metadata: has · Documents carry metadata and classification
- Document → Access log: tracked by · Document access is separately audited
- Frontend ctrls → Document: manages · Document lifecycle screens
- API v1 ctrls → Document: exposes · Document REST endpoints
- Frontend ctrls → User: manages · User administration and profile flows
- API v1 ctrls → User: exposes · User REST endpoints
- Frontend ctrls → Audit log: reviews · Audit screens inspect activity history
- API v1 ctrls → Audit log: exposes · Audit REST endpoints
- Auth → Tokens: stores · Refresh token lifecycle support
- Auth → User: verifies · Authentication resolves user identities
- Security → Security log: records · Security events are written to dedicated logs
- Config → Database: configures · Database settings feed the persistence layer
- Env → Config: overrides · Environment values supplement static config
- Schema → Database: initializes · Schema and seed artifacts prepare the database
- Storage → Document: stores files · Writable storage holds document assets and generated content
- Logs → Security log: stores · Runtime logs complement security audit records