### Modular Architecture Guidelines #### Overview This application uses a custom modular architecture to organize features into distinct, self-contained units called "Modules". Each module encapsulates a specific piece of functionality, including its own models, migrations, seeders, controllers, and more. The system is designed to automatically discover and register components from enabled modules. The core of this system is the `App\Modules\ModuleRepository`, which is responsible for finding, loading, and managing all the modules in the application. A set of helper functions is provided for easy interaction with the module repository. #### Core Concepts - **Module**: A directory within `app/Modules` that represents a distinct feature. - **`ModuleRepository`**: A singleton service (`App\Modules\ModuleRepository`) that manages all modules. Accessed via the `modular()` helper. - **`ModuleContract`**: An interface (`App\Modules\ModuleContract`) that every module's main class must implement. It defines the basic contract for a module, such as whether it's enabled. - **Helpers**: Global functions defined in `app/Helpers/helpers.php` to simplify interaction with the modular system. #### Module Structure Every module is a directory located in `app/Modules/`. For a module named `Example`, the structure would be `app/Modules/Example/`. ##### Required Structure - `app/Modules/Example/ExampleModule.php`: This is the main class for the module. It **must** implement `App\Modules\ModuleContract`. ```php name; } ``` - **Get a Specific Module Instance**: ```php $invoiceModule = module('Invoice'); // Returns instance of InvoiceModule if ($invoiceModule->isEnabled()) { // ... } ``` - **Get the Modules Path**: ```php $path = modules_path('Invoice/Database'); // app/Modules/Invoice/Database ```