# siubie/kaido-kit architecture

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

- Interactive diagram: https://gitdiagram.com/siubie/kaido-kit
- Repository: https://github.com/siubie/kaido-kit

## Overview

##### Project type and purpose
- This is a full-stack Laravel 11.0 application with a FilamentPHP 3.2-based admin panel starter kit (“Kaido Kit”) intended to accelerate CRUD, API, auth, media, settings, and RBAC setup.
- The README confirms it’s a feature-rich admin interface that bundles Filament plugins (Shield, Socialite, Breezy, Impersonate, Media Library, Settings, API Service) plus export/import, two-factor auth, social login, and auto-generated API docs.

##### File structure
- Top-level:
- app/Filament → Filament Resources (Books, Users, Roles, Contacts), Pages, Exports/Imports, API handlers
- app/Http → HTTP Controllers (web & API), Form Requests, API Resources
- app/Models & app/Policies → Eloquent models and authorization policies
- app/Services & app/Settings → custom service classes (ApiService) and dynamic settings
- config/, database/, routes/, public/, resources/ → typical Laravel layout
- Tests → PHPUnit/Pest Feature and Unit tests
- docker-compose.yml, sail support, stubs, webpack (Vite) and Tailwind configs

##### README for additional insights
- States core plugins and patterns: RBAC via Shield, Social login, 2FA, user impersonation, API with Sanctum, media via Spatie, settings via Spatie.
- Quick-start and Docker/Sail instructions suggest standard LAMP/Sail deployment.

##### Elements
- Clear labels for each component (e.g., “Filament Resource: BookResource → CRUD pages and API handlers”)
- HTTP request flow (Browser → WebServer → Laravel Router → Controller/Filament Page → Model → DB)
- Data flows between Filament Resources and Import/Export services
- Calls from Controllers to Services (ApiService) and from Services to external APIs
- Purple clouds = external services (Google OAuth, Resend, Scramble)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        Browser["Browser Admin UI"]:::frontend
        ViteAssets["Vite/Tailwind Assets\n(resources/css, resources/js)"]:::frontend
        Browser -->|requests /admin, API| WebServer
    end

    %% Web Server
    WebServer["Web Server\n(Nginx/Apache/Sail)"]:::logic --> Router

    %% Laravel Router
    Router["public/index.php → Laravel Router"]:::logic 
    Router --> WebRoutes
    Router --> ApiRoutes
    Router --> FilamentCore
    Router --> Scramble

    %% HTTP Layer
    subgraph "HTTP Layer"
        WebRoutes["routes/web.php"]:::logic 
        ApiRoutes["routes/api.php"]:::logic 
    end

    WebRoutes --> Controllers
    ApiRoutes --> Controllers

    %% Filament Admin Panel
    subgraph "Filament Admin Panel"
        FilamentCore["Filament Core\n(app/Filament)"]:::frontend
        subgraph "Resources"
            BookRes["BookResource"]:::frontend
            UserRes["UserResource"]:::frontend
            RoleRes["RoleResource"]:::frontend
            BookRes --> BookPages
            UserRes --> UserPages
            RoleRes --> RolePages
            BookRes --> BookApiHandlers
        end
        subgraph "Pages"
            BookPages["Pages (app/Filament/Resources/BookResource/Pages)"]:::frontend
            UserPages["Pages (app/Filament/Resources/UserResource/Pages)"]:::frontend
            RolePages["Pages (app/Filament/Resources/RoleResource/Pages)"]:::frontend
        end
        subgraph "API Handlers"
            BookApiHandlers["Book API Handlers\n(app/Filament/Resources/BookResource/Api/Handlers)"]:::frontend
        end
        subgraph "Import/Export"
            Imports["Imports\n(app/Filament/Imports)"]:::frontend
            Exports["Exports\n(app/Filament/Exports)"]:::frontend
        end
        subgraph "Custom Pages"
            CustomPages["Pages\n(app/Filament/Pages)"]:::frontend
        end
        FilamentCore --> Resources
        FilamentCore --> Imports
        FilamentCore --> Exports
        FilamentCore --> CustomPages
    end

    %% Application Logic
    subgraph "Application Logic"
        Controllers["Controllers\n(app/Http/Controllers)"]:::logic
        FormRequests["Form Requests\n(app/Http/Requests)"]:::logic
        ApiResources["API Resources\n(app/Http/Resources)"]:::logic
        Policies["Policies & Guards\n(app/Policies)"]:::logic
        Models["Eloquent Models\n(app/Models)"]:::logic
        Services["ApiService\n(app/Services/ApiService.php)"]:::logic
        Settings["Settings\n(app/Settings/KaidoSetting.php)"]:::logic
        Controllers -->|validates via| FormRequests
        Controllers -->|transforms via| ApiResources
        Controllers -->|authorizes via| Policies
        Controllers -->|reads/writes| Models
        Controllers -->|calls| Services
        Controllers -->|renders Filament Pages| FilamentCore
        Models -->|persist| DB
        Services -->|external calls| GoogleOAuth
        Services -->|email via| Resend
    end

    %% Storage & Caching
    subgraph "Persistence"
        DB["Database\n(MySQL/PostgreSQL)"]:::storage
        Cache["Cache/Queue\n(Redis, DB)"]:::storage
        Storage["Media Storage\n(Local/S3)"]:::storage
        Models --> DB
        Imports -->|store files| Storage
        Exports -->|store files| Storage
        Controllers -->|queues jobs| Cache
    end

    %% External Services
    subgraph "External Services"
        GoogleOAuth["Google OAuth\n(Socialite)"]:::external
        Resend["Resend Email Service"]:::external
        Scramble["Scramble API Docs"]:::external
        Router -->|serves docs| Scramble
    end

    %% Click Events
    click FilamentCore "https://github.com/siubie/kaido-kit/tree/main/app/Filament"
    click BookRes "https://github.com/siubie/kaido-kit/blob/main/app/Filament/Resources/BookResource.php"
    click BookRes "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/BookResource"
    click UserRes "https://github.com/siubie/kaido-kit/blob/main/app/Filament/Resources/UserResource.php"
    click UserRes "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/UserResource"
    click RoleRes "https://github.com/siubie/kaido-kit/blob/main/app/Filament/Resources/RoleResource.php"
    click RoleRes "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/RoleResource"
    click BookPages "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/BookResource/Pages"
    click UserPages "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/UserResource/Pages"
    click RolePages "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/RoleResource/Pages"
    click BookApiHandlers "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Resources/BookResource/Api/Handlers"
    click Imports "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Imports"
    click Exports "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Exports"
    click CustomPages "https://github.com/siubie/kaido-kit/tree/main/app/Filament/Pages"
    click WebRoutes "https://github.com/siubie/kaido-kit/blob/main/routes/web.php"
    click ApiRoutes "https://github.com/siubie/kaido-kit/blob/main/routes/api.php"
    click Controllers "https://github.com/siubie/kaido-kit/tree/main/app/Http/Controllers"
    click FormRequests "https://github.com/siubie/kaido-kit/tree/main/app/Http/Requests"
    click ApiResources "https://github.com/siubie/kaido-kit/tree/main/app/Http/Resources"
    click Models "https://github.com/siubie/kaido-kit/tree/main/app/Models"
    click Policies "https://github.com/siubie/kaido-kit/tree/main/app/Policies"
    click Services "https://github.com/siubie/kaido-kit/blob/main/app/Services/ApiService.php"
    click Settings "https://github.com/siubie/kaido-kit/blob/main/app/Settings/KaidoSetting.php"

    %% Styles
    classDef frontend fill:#c3defc,stroke:#0366d6,stroke-width:1px
    classDef logic fill:#d2f8d2,stroke:#22863a,stroke-width:1px
    classDef storage fill:#ffe5b4,stroke:#db8b00,stroke-width:1px
    classDef external fill:#f0d9ff,stroke:#6f42c1,stroke-width:1px
```
