# cmabris/framework architecture

> Architecture diagram of the GitHub repository cmabris/framework, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cmabris/framework
- Repository: https://github.com/cmabris/framework

## Overview

##### Project type and purpose
- This code base is a Laravel-based e-commerce framework package (“AvoRed Framework”) that provides core ecommerce functionality (catalog, cart, orders, CMS, user/role management) to Laravel applications.
- It exposes both a server-rendered admin UI (Blade + Vue components + assets) and a GraphQL API layer, and plugs into Laravel via service providers.

##### File structure
- Top-level:
- assets/ and resources/ for frontend UI (Vue components under resources/components, Blade under resources/views, CSS/LESS/SASS under resources/)
- src/ for core PHP application code, subdivided by domain (Catalog, Cms, Order, System, User, Database, GraphQL, Support, Modules, etc.)
- config/, database/ for configuration and migrations/factories
- routes/web.php defines HTTP routes
- composer.json, service providers register the package with Laravel
- Key patterns:
- MVC: Controllers (src/**/Controllers), Requests (validation), ViewComposers
- Repository pattern: Contracts + Repository implementations under src/Database
- Service providers wire up facades, middleware, GraphQL, modules
- GraphQL subsystem with Mutations, Queries, Types
- Modular architecture: Modules/Console commands and ModuleManager

##### Extract insights from the README
- Highlights that this is a composer-installable Laravel package.
- Admin UI is published via vendor:publish, migrations installed, artisan commands for setup (avored:install, avored:admin:make).

##### Main components
a. Frontend Admin UI
- Browser → loads admin interface
- Assets delivered (CSS/JS under assets/ and compiled via Laravel Mix in resources/)
- Vue components interact via AJAX/GraphQL or submit to HTTP endpoints
b. HTTP Application Layer (Laravel)
- routes/web.php → Laravel Router
- Middleware (src/Support/Middleware/AdminAuth, RedirectIfAdminAuth)
- Controllers (src/*/Controllers) handle HTTP form submissions and return Blade views
- Requests (validation)
- ViewComposers assemble layout data
c. GraphQL API Layer
- Single GraphQL endpoint handled by GraphqlProvider
- Mutations and Queries: authentication, CRUD for catalog, system layout queries, etc.
- Type system defines DTOs
d. Domain Services and Managers
- Cart Manager, Breadcrumb Builder, Permission Manager, Module Manager
- Factories, Builders, Facades in src/Support
e. Data Access
- Repository layer (src/Database/Repository) implements Contracts (src/Database/Contracts)
- Eloquent Models (src/Database/Models)
- Database: migrations and seeders
f. External Integrations
- Laravel core services, third-party packages loaded by composer
- Artisan console commands for installation and module management

##### Relationships and interactions
- Browser ↔ HTTP Layer: requests for pages, forms, assets
- HTTP Layer → Domain Services → Repository → Database
- Browser ↔ GraphQL Layer: AJAX queries/mutations
- Service Providers bootstrapping components into Laravel container
- Modules Manager dynamically registers modules/providers

##### Architectural patterns and principles
- MVC for admin UI
- Repository + Contract to decouple models from persistence
- Service Provider pattern to register and configure subsystems (GraphQL, Menu, Cart)
- Facade pattern for global static-style access to services (Cart, Menu, Breadcrumb, Module, Permission)
- Modular plugin architecture under src/Modules

##### Technologies and frameworks
- Laravel 5.8 (Router, ServiceContainer, Eloquent, Middleware, Blade)
- Vue.js components for dynamic form pages
- Laravel Mix for asset compilation (LESS/SASS)
- GraphQL (webonyx/graphql-php or similar)
- PHPUnit for tests
- Composer for package management

##### Final advice
- Be precise: represent each subsystem (GraphQL vs MVC) and every major package (Cart, Breadcrumb, Modules).
- Service providers as the glue that binds everything into Laravel’s DI container.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Admin UI
    subgraph "Frontend Admin UI" 
        direction TB
        Browser["Browser"]:::frontend
        Assets["Assets (CSS/JS)"]:::frontend
        VueComponents["Vue Components"]:::frontend
        BladeTemplates["Blade View Templates"]:::frontend
    end

    %% HTTP Application Layer
    subgraph "HTTP Application Layer"
        direction TB
        Router["Laravel Router\n(routes/web.php)"]:::app
        MiddlewareAuth["AdminAuth Middleware"]:::app
        MiddlewareRedirect["RedirectIfAdminAuth Middleware"]:::app
        Controllers["HTTP Controllers"]:::app
        Requests["Form Validation Requests"]:::app
        ViewComposers["Layout ViewComposers"]:::app
    end

    %% GraphQL API Layer
    subgraph "GraphQL API Layer"
        direction TB
        GraphqlProvider["GraphQL Service Provider"]:::app
        GraphQLEndpoint["/graphql Endpoint"]:::app
        GQLQueries["GraphQL Queries & Mutations"]:::app
        GQLTypes["GraphQL Types"]:::app
    end

    %% Domain Services & Managers
    subgraph "Domain Services & Managers"
        direction TB
        CartManager["Cart Manager"]:::service
        BreadcrumbBuilder["Breadcrumb Builder"]:::service
        PermissionManager["Permission Manager"]:::service
        ModuleManager["Module Manager"]:::service
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        Contracts["Database Contracts"]:::data
        Repositories["Repository Implementations"]:::data
        Models["Eloquent Models"]:::data
        Migrations["Migrations & Factories"]:::data
    end

    %% Infrastructure
    subgraph "Infrastructure & Bootstrapping"
        direction TB
        AvoRedProvider["AvoRed Core Service Provider"]:::infra
        Providers["Service Providers"]:::infra
        Facades["Service Facades"]:::infra
        ConfigFile["Configuration File"]:::infra
        ConsoleCommands["Artisan Console Commands"]:::infra
    end

    Database["Database"]:::data

    %% Connections - Frontend to HTTP/GraphQL
    Browser -->|HTTP GET/POST| Router
    Browser -->|AJAX GraphQL| GraphQLEndpoint
    Assets --> Browser
    VueComponents -->|AJAX/HTTP| Router
    BladeTemplates -->|Rendered Views| Browser

    %% HTTP Layer flow
    Router -->|invoke| MiddlewareAuth
    Router -->|invoke| MiddlewareRedirect
    MiddlewareAuth --> Controllers
    MiddlewareRedirect --> Controllers
    Controllers -->|validate| Requests
    Controllers -->|use| ViewComposers
    Controllers -->|call| CartManager
    Controllers -->|call| ModuleManager

    %% GraphQL flow
    GraphQLEndpoint -->|boot| GraphqlProvider
    GraphQLEndpoint -->|resolve| GQLQueries
    GQLQueries -->|use| GQLTypes
    GQLQueries -->|call| ModuleManager
    GQLQueries -->|call| CartManager

    %% Domain Services to Data Access
    CartManager -->|repository| Repositories
    BreadcrumbBuilder -->|repository| Repositories
    PermissionManager -->|repository| Repositories
    ModuleManager -->|repository| Repositories

    %% Data Access to DB
    Repositories -->|SQL read/write| Models
    Models -->|migrations| Database
    Migrations --> Database
    Contracts --> Repositories

    %% Infrastructure bindings
    AvoRedProvider --> Providers
    Providers -->|bind| Facades
    Providers -->|bind| Contracts
    Providers -->|boot| GraphqlProvider
    Providers -->|boot| ModuleManager
    Facades --> CartManager
    Facades --> BreadcrumbBuilder
    Facades --> PermissionManager
    Facades --> ModuleManager
    ConsoleCommands --> ModuleManager
    ConfigFile --> AvoRedProvider

    %% Click Events
    click Assets "https://github.com/cmabris/framework/tree/master/assets/avored-admin/"
    click VueComponents "https://github.com/cmabris/framework/tree/master/resources/components/"
    click BladeTemplates "https://github.com/cmabris/framework/tree/master/resources/views/"
    click Router "https://github.com/cmabris/framework/blob/master/routes/web.php"
    click Controllers "https://github.com/cmabris/framework/tree/master/src/Catalog/Controllers/"
    click Controllers "https://github.com/cmabris/framework/tree/master/src/Cms/Controllers/"
    click Controllers "https://github.com/cmabris/framework/tree/master/src/Order/Controllers/"
    click Controllers "https://github.com/cmabris/framework/tree/master/src/System/Controllers/"
    click Controllers "https://github.com/cmabris/framework/tree/master/src/User/Controllers/"
    click Requests "https://github.com/cmabris/framework/tree/master/src/Catalog/Requests/"
    click Requests "https://github.com/cmabris/framework/tree/master/src/Cms/Requests/"
    click Requests "https://github.com/cmabris/framework/tree/master/src/Order/Requests/"
    click Requests "https://github.com/cmabris/framework/tree/master/src/System/Requests/"
    click Requests "https://github.com/cmabris/framework/tree/master/src/User/Requests/"
    click ViewComposers "https://github.com/cmabris/framework/blob/master/src/System/ViewComposers/LayoutComposer.php"
    click MiddlewareAuth "https://github.com/cmabris/framework/blob/master/src/Support/Middleware/AdminAuth.php"
    click MiddlewareRedirect "https://github.com/cmabris/framework/blob/master/src/Support/Middleware/RedirectIfAdminAuth.php"
    click GraphqlProvider "https://github.com/cmabris/framework/blob/master/src/Support/Providers/GraphqlProvider.php"
    click GQLQueries "https://github.com/cmabris/framework/tree/master/src/GraphQL/Query/"
    click GQLQueries "https://github.com/cmabris/framework/tree/master/src/GraphQL/Mutation/"
    click GQLTypes "https://github.com/cmabris/framework/tree/master/src/GraphQL/Type/"
    click CartManager "https://github.com/cmabris/framework/blob/master/src/Cart/Manager.php"
    click BreadcrumbBuilder "https://github.com/cmabris/framework/blob/master/src/Breadcrumb/Builder.php"
    click PermissionManager "https://github.com/cmabris/framework/blob/master/src/Permission/Manager.php"
    click ModuleManager "https://github.com/cmabris/framework/blob/master/src/Modules/Manager.php"
    click ModuleManager "https://github.com/cmabris/framework/blob/master/src/Modules/Module.php"
    click Facades "https://github.com/cmabris/framework/blob/master/src/Support/Facades/Breadcrumb.php"
    click Facades "https://github.com/cmabris/framework/blob/master/src/Support/Facades/Cart.php"
    click Facades "https://github.com/cmabris/framework/blob/master/src/Support/Facades/Menu.php"
    click Facades "https://github.com/cmabris/framework/blob/master/src/Support/Facades/Module.php"
    click Facades "https://github.com/cmabris/framework/blob/master/src/Support/Facades/Permission.php"
    click Providers "https://github.com/cmabris/framework/blob/master/src/Support/Providers/BreadcrumbProvider.php"
    click Providers "https://github.com/cmabris/framework/blob/master/src/Support/Providers/CartProvider.php"
    click Providers "https://github.com/cmabris/framework/blob/master/src/Support/Providers/MenuProvider.php"
    click Providers "https://github.com/cmabris/framework/blob/master/src/Support/Providers/ModuleProvider.php"
    click Providers "https://github.com/cmabris/framework/blob/master/src/Support/Providers/PermissionProvider.php"
    click Providers "https://github.com/cmabris/framework/blob/master/src/Support/Providers/ModelProvider.php"
    click Contracts "https://github.com/cmabris/framework/tree/master/src/Database/Contracts/"
    click Repositories "https://github.com/cmabris/framework/tree/master/src/Database/Repository/"
    click Models "https://github.com/cmabris/framework/tree/master/src/Database/Models/"
    click Migrations "https://github.com/cmabris/framework/tree/master/database/migrations/"
    click Migrations "https://github.com/cmabris/framework/tree/master/database/factories/"
    click ConsoleCommands "https://github.com/cmabris/framework/blob/master/src/Modules/Console/ModuleInstallCommand.php"
    click ConsoleCommands "https://github.com/cmabris/framework/blob/master/src/Modules/Console/ModuleMakeCommand.php"
    click ConsoleCommands "https://github.com/cmabris/framework/blob/master/src/Modules/Console/ControllerMakeCommand.php"
    click ConsoleCommands "https://github.com/cmabris/framework/blob/master/src/Support/Console/InstallCommand.php"
    click ConsoleCommands "https://github.com/cmabris/framework/blob/master/src/Support/Console/AdminMakeCommand.php"
    click AvoRedProvider "https://github.com/cmabris/framework/blob/master/src/AvoRedProvider.php"
    click ConfigFile "https://github.com/cmabris/framework/blob/master/config/avored.php"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef app fill:#DFFFE0,stroke:#28A745,color:#28A745
    classDef service fill:#FFF5D0,stroke:#FFB700,color:#FFB700
    classDef data fill:#FFE0D0,stroke:#D73A49,color:#D73A49
    classDef infra fill:#F0F0F0,stroke:#6A737D,color:#6A737D
```
