How neorazorx/facturascripts works
Main Components
• Presentation Layer:
– Represented by the assets (located in directories such as Core/Assets and Dinamic/Lib/Widget, etc.), the twig templates (Core/View and its subdirectories), and the login and layout pages.
– Include the client-side technologies (CSS, JavaScript, fonts, images) and the HTML templates rendered by the system.
• Business/Controller Layer:
– The Core/Controller and Dinamic/Lib/ExtendedController directories hold the controllers, API endpoints, and request-handling logic.
– This layer manages incoming requests (including Ajax requests seen in Core/Base/AjaxForms) and decides on the processing needed.
• Domain/Model Layer:
– All the domain objects reside in Core/Model and Dinamic/Model directories. They represent entities like Client, FacturaCliente, PedidoProveedor, and many others.
– Also include the contracts/interfaces in Core/Contract and Core/Base/Contract.
• Data Access Layer:
– Found in Core/Base/DataBase and its subdirectories, these provide abstractions for database engines (MySQLEngine, PostgresqlEngine, etc.) and query management.
– Migration tools and database update scripts (e.g., Migrations.php) are also part of this aspect.
• Infrastructure & Utilities:
– Background jobs (Core/Worker) for processing asynchronous tasks like ContaWorker, PurchaseDocumentWorker, etc.
– Utility libraries: email modules (Core/Lib/Email), PDF exports (Core/Lib/Export), logging (MiniLog, MiniLogStorage), and translation support.
– Plugin integration: Both Core and Dinamic include dynamic plugin and extension support to enhance functionality.
• Testing and Quality Assurance:
– The Test directory shows unit tests, integration tests, and related assets ensuring functionality across controllers, models, and utilities.
Relationships and Interactions
• User requests (HTTP requests from clients or API calls) hit the Presentation Layer, which then forwards the request to the appropriate controller in the Business Layer (via Core/Controller, API endpoints, and login controllers).
• Controllers interact with domain Models to perform business logic. For example, a Sales or Purchases request is handled by corresponding controllers that call models residing under Core/Model to retrieve or save data.
• The Data Access Layer (via databases, queries, and migrations) underpins the Models – it abstracts differences between SQL engines and manages low-level data operations.
• Infrastructure components, including background Workers and utilities (like email notifications, PDF generation, and logging), are invoked as part of the business processes.
• Plugins and external modules (visible in the “Dinamic” folder) extend the core functionality. Consider these as extension points that plug into business logic or presentation components as needed.
Architectural Patterns and Design Principles
• Layered (n-tier) architecture separating presentation, business logic, domain, and data access.
• Use of MVC-like patterns where Controllers manage inputs, Models manage data, and Views (twig templates) present the data.
• Modularity and extensibility via plugin structure — dynamic modules allow for expanding system functionality without modifying core files.
• Abstraction of database access to support multiple database engines (as seen in the DatabaseEngine implementations).
Relevant Technologies
• PHP (modern PHP, utilizing composer for dependency management)
• Twig templating engine (as indicated by the templates under Core/View)
• Bootstrap 4 (as mentioned in the README, indicating UI framework usage)
• JavaScript libraries for user interface enhancements (assets in Core/Assets/JS)
• Various utilities for PDF exports, email, translations, and background processing.