How rapidez/core works
Project Type and Its Purpose
• This is a PHP-based e-commerce integration/core platform—Rapidez Core—that appears to integrate with Magento (as seen from the authentication guards and token names) and uses Laravel’s conventions.
• It is structured as an MVC application with a mix of backend components (controllers, models, middleware, commands) and frontend components (Blade views, Vue components, CSS/JS assets).
File Structure to Define Major Components
a. Configuration and Setup:
• The “config/rapidez” directory holds configurations like frontend options, routing, JWT, indexer settings, health checks, and models. This is the backbone for system behavior.
• Global configuration files (.editorconfig, .php-cs-fixer, package.json, etc.) set up code quality, formatting, and asset compilation.
b. Frontend & Asset Layer:
• The “resources” directory contains CSS, JavaScript (including Vue components), and Blade templates (views). This represents the presentation layer.
• Components are well-factored, with separate minor directories for cart, checkout, listing, product, and customer views, indicating an emphasis on modular frontend design.
c. Application Logic and Business Layer:
• The “src” folder is where most of the backend code resides:
• Controllers (e.g., CategoryController, CheckoutController, ProductController) reside in “src/Http/Controllers,” handling routing and request processing.
• Business logic is organized into Actions, Commands, Events, Jobs, and Listeners.
• Models in “src/Models” implement the domain layer for products, orders, customers, and other e-commerce components.
• Custom middleware and authentication guards (MagentoCartTokenGuard, MagentoCustomerTokenGuard) handle security and session management.
• The Service Provider (RapidezServiceProvider) and Facade (Rapidez) encapsulate bootstrap tasks and offer a clean API.
d. Routing and Integration Points:
• The “routes” directory (with “api.php” and “web.php”) shows how HTTP endpoints and API routes are defined and bound to the controllers.
• Integration with external systems is evident through Magento integrations, Elasticsearch commands (IndexCategoriesCommand, ElasticsearchIndexer), and healthcheck components.
e. Testing and Quality Control:
• The “tests” directory has unit, feature, and browser (Dusk) tests that validate the application logic and frontend interactions.
• GitHub workflows, PHPStan, and Prettier configurations ensure continuous integration and code style enforcement.
a. A top-level separation:
• Frontend/Presentation Layer: Represented by “resources/views” (Blade templates) and “resources/js/components” (Vue components, JS) together with asset compile tools (vite.config.js, tailwind.config.js).
• Application/API Layer:
– The routing files (routes/web.php, routes/api.php) serve as the entry point for HTTP requests.
– Controllers take request inputs after passing through middleware (from src/Http/Middleware).
• Business Logic Layer:
– The Service Provider and Facade that bootstrap the application.
• Data/Domain Layer:
– The “src/Models” directory represents the domain model for e-commerce elements such as Product, Category, Quote, etc. Also emphasize the model scopes and traits.
– Represent the database and external data stores (Elasticsearch, Magento) as part of this layer.
b. External Integrations:
• Magneto’s integration through authentication components.
• Elasticsearch integrations via command components and associated health check listeners.
c. Control and Communication Flow:
– From the Frontend (user/browser) to the Routing layer.
– From the Routing layer through Middleware into Controllers.
– From Controllers to various Business Logic components (Actions, Commands) and then to Models.
– Represent asynchronous processes like Jobs and Event handling.
Architectural Patterns and Technologies
• MVC pattern and the layered architecture (presentation, business logic, and data).
• How Laravel Dusk tests interact with the frontend and backend.
• Integration points for search (GraphQL queries in resources/views and JS components) and health checks (controllers and listeners).
• Use of Laravel service providers and custom authentication guards for Magento.