How area17/twill works
Overall Architecture
• Recognize that Twill is a Laravel package. This means the core application is built on Laravel’s MVC framework and extends its functionality.
• There is a clear separation between the backend (Laravel controllers, models, services, commands, repositories, middleware, facades, and service providers in the “src” directory) and the frontend (Vue.js components, JavaScript components, SCSS styling, and Blade templates in the “views” and “frontend” directories).
Lay Out the Main Components
a. Laravel Application Core and Package Integration:
• Laravel kernel, the HTTP middleware layer (src/Http/Middleware), and the route definitions (routes, e.g., admin.php and auth.php).
• “src” directory as the heart of Twill. Emphasize controllers (admin and frontend controllers under src/Http/Controllers), models (under src/Models), repositories (src/Repositories), jobs, and service providers (TwillServiceProvider.php, etc.) that integrate the package into Laravel.
b. Admin Console & CMS Functionality:
• Admin controllers (in src/Http/Controllers/Admin) that handle actions such as file management, block management, and user operations.
• Custom UI components, blocks, fields, and repeaters found in both the “views” folder (Blade templates) and the “frontend/js/components” folder (Vue components).
• Services, for example, Blocks service, Media Library services (Glide, Imgix, TwicPics, etc.) and Settings (in src/Services/Settings).
• Middleware (authentication, localization, permissions, etc.) that secures admin routes.
c. Frontend Public Pages (if applicable):
d. Command-Line Tools & CLI Interfaces:
• “src/Commands” directory for Artisan commands (e.g., BlockMake, MakeCapsule, Install, Update, etc.) that drive Twill’s CLI interface and help generate or update code.
e. Modular/Extensible Functionality:
f. Data Persistence and Migrations:
• That models interact with this layer via repositories.
g. Frontend Assets & Presentation Layer:
• A “Frontend” component where the Vue.js-based admin UI is assembled (frontend/js and frontend/scss directories).
• Blade templates and partials in the “views” directory that render the CMS UI.
h. External Services and Integrations:
• Integration with external image services (Glide, Imgix, TwicPics), cloud storage or upload mechanisms, and possibly OAuth handled in the configs and services.
i. Documentation, Testing, and Dev Tools:
• A block for the “docs” (both docs and docs-api) that serves as the knowledge base.
• Testing components (tests directory, with unit, integration, and browser tests) that ensure quality.
Relationships and Interactions
• Middleware layers intercepting requests.
• Integrations with external cloud services or storage (showing in the service layer).
Architectural Patterns and Design Principles
• MVC pattern at work due to Laravel’s inherent structure.
• Modular design with separate capsules and repeatable blocks – an extensibility design to allow dynamic modification of content types.
• Separation of concerns through clear layers: Controllers (HTTP layer), Models (data layer), Repositories/Services (business logic), and a customized CLI layer.
• Mention dependency injections, facades (src/Facades) to simplify usage of complex subsystems.
Relevant Technologies and Frameworks
• Laravel (PHP framework) serves as the backbone.
• Vue.js is used for the rich, interactive admin UI (frontend/js/components).
• Blade templating for server-side rendering.
• Command-line interfaces to support various developer tasks.
• CSS/SCSS for visual styling and several JavaScript libraries (e.g., Quill for rich text editing).