How phicorp/davinci works
Main Components
• Client / Browser – Represent external requests hitting your application.
• Public Entry Point – The “public” directory (with index.php, .htaccess, and robots.txt) defines the web root where user requests initially land.
• Router and Bootstrapping – Files like router.php, config.php, and the “nova” directory (with its “serve” command) are used to start the application and route incoming requests.
• Application Core (App) – This is subdivided into:
– Controllers: (App/Controllers) where incoming HTTP requests are handled.
– Models: (App/Models) representing the ORM layer and database entities.
– Middlewares: (App/Middlewares) for handling pre/post processing of HTTP requests (e.g., CORS, CSRF).
– Console: (App/Console) containing command line tools/commands.
– Helpers: (App/Helpers) and Providers: (App/Providers) which set up dependency injection, IoC, and other service configurations.
– DB: (App/DB) which could hold database connection logic or configuration.
• Routes – The “Routes” directory (with web.php, api.php, console.php) defines how HTTP, API, and console commands are mapped to their respective controllers or actions.
• Views – The “View” directory contains Blade templates (e.g., welcome.blade.php) used to render the UI.
• Assets – Static assets like CSS, JS, and fonts in the “Assets” folder (though not central to backend logic, they’re part of the external resources served when necessary).
• Storage – Holds logs, session data, cache, etc., indicating persistence and state management for the framework.
• Third-party & Dependency Management – Composer (composer.json) indicates package management, while external libraries might be loaded via autoloading.
Relationships and Interactions
• That the router loads Routes (from Routes/web.php or api.php) that map to specific Controller methods (from App/Controllers).
• Middleware processing (from App/Middlewares) that intercepts the request before reaching controllers.
• Once the Controller processes the request, it may interact with Models (via the ORM), and subsequently passing any data to the View rendering engine (from View).
• The Providers (in App/Providers) orchestrate dependency injection and service registration, allowing components like the ORM and session management (stored in Storage) to interact seamlessly.
• The console commands (App/Console) provide administrative or maintenance functions that might interact with the same layers (routing for console, models, DB, etc.).
• Static assets under “Assets” are served separately by the web server (usually referenced in the view templates).
Architectural Patterns and Principles
• MVC-like Structure: Controllers, Models, and Views are clearly separated.
• Middleware Pipeline: In App/Middlewares, showing how requests are filtered/processed.
• Service Providers & Dependency Injection: Ensuring loose coupling and extendability.
• Routing Layer: Centralized in the Routes directory to define different request types (web, api, console).
• Clear Separation of Concerns: Different directories isolate specific responsibilities (for instance, Storage for logs and sessions, App/DB for database abstractions).
Technology and Frameworks
• PHP as the primary language.
• Composer for dependency management.
• Blade-like templating engine (as seen in the View folder).
• Built-in routing, ORM, and console command support similar to popular frameworks like Laravel.