Overview
GIMA (Gestión Inteligente para el Mantenimiento de Activos) is built on a modern, scalable architecture using Laravel as the core framework. The system provides comprehensive asset maintenance management with role-based access control, real-time tracking, and automated workflows.Technology Stack
Backend Framework
Laravel 11.xModern PHP framework providing:
- Eloquent ORM for database interactions
- API routing and middleware
- Queue management
- Event broadcasting
Authentication
Laravel SanctumToken-based authentication for:
- API token generation
- SPA authentication
- Mobile app support
- Secure session management
Authorization
Spatie Laravel PermissionRole and permission management:
- Role-based access control (RBAC)
- Permission inheritance
- Guard support
- Dynamic permission assignment
Database
MySQL / PostgreSQLRelational database for:
- Asset tracking
- Maintenance records
- User management
- Audit trails
Core Components
1. Authentication Layer
The authentication system uses Laravel Sanctum to provide stateless API authentication:All API requests require a valid Bearer token obtained through the
/autenticacion/iniciar-sesion endpoint.2. Authorization Layer
GIMA implements a hierarchical role-based permission system using Spatie Laravel Permission:Role Hierarchy
Role Hierarchy
- Admin - Full system access with all permissions
- Supervisor - Asset and maintenance management
- Técnico - Task execution and reporting
- Reporter - Fault reporting and view-only access
RolesSeeder.php3. Data Layer
The system uses Eloquent ORM with strongly-typed relationships and enums:Models
- User: Users with roles and permissions
- Activo: Assets being maintained
- Mantenimiento: Maintenance records
- Reporte: Fault reports
- Repuesto: Spare parts inventory
- Ubicacion: Physical locations
Enums
- EstadoActivo: Asset states
- TipoMantenimiento: Maintenance types
- EstadoMantenimiento: Maintenance status
- EstadoReporte: Report status
- NivelPrioridad: Priority levels
4. Business Logic Layer
The application follows Laravel’s MVC architecture:Database Schema Overview
Core Relationships
API Architecture
Request Flow
- Authentication: Client sends Bearer token in Authorization header
- Route Matching: Laravel router matches request to endpoint
- Middleware:
auth:sanctumvalidates token,rolechecks permissions - Controller: Processes request and calls service layer
- Service Layer: Executes business logic
- Model Layer: Interacts with database via Eloquent
- Response: JSON response returned to client
API Structure
Security Features
Token Authentication
- Stateless API tokens via Sanctum
- Token expiration policies
- Token revocation support
- Secure token storage
Authorization
- Role-based access control
- Permission-level granularity
- Route protection middleware
- User approval workflow
Data Protection
- Password hashing (bcrypt)
- Mass assignment protection
- SQL injection prevention
- XSS protection
Audit Trail
- User activity logging
- Model change tracking
- Audit table for compliance
- Timestamp tracking
Performance Considerations
Eager Loading
Caching
Indexing
Database indexes on:- Foreign keys (
activo_id,usuario_id, etc.) - Status fields (
estado,prioridad) - Search fields (
codigo,email)
Deployment Architecture
Production Stack
Production Stack
- Web Server: Nginx or Apache with PHP-FPM
- Application: Laravel running on PHP 8.2+
- Database: MySQL 8.0+ or PostgreSQL 14+
- Cache: Redis for session and cache storage
- Queue: Redis or database for background jobs
- Storage: Local filesystem or S3 for file uploads
Environment Configuration
Next Steps
Roles & Permissions
Learn about the role hierarchy and permission system
Asset Management
Understand asset lifecycle and tracking
Maintenance Types
Explore preventive, corrective, and predictive maintenance
API Reference
View complete API endpoint documentation