# nativephp/kitchen-sink-mobile architecture

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

- Interactive diagram: https://gitdiagram.com/nativephp/kitchen-sink-mobile
- Repository: https://github.com/nativephp/kitchen-sink-mobile

## Overview

##### Project type and purpose
- This is a full-stack, embedded-mobile demonstration: a “Mobile Kitchen Sink” app built on top of Laravel, Livewire, and NativePHP.
- It showcases dozens of native device features (camera, geolocation, storage, notifications, etc.) via Livewire components inside a PHP-powered mobile runtime.

##### File-structure analysis
- Top-level directories:
- app/       → Laravel core (MVC controllers, models, services, events)
- bootstrap/ → framework bootstrap & provider registration
- config/    → Laravel & NativePHP configuration
- database/  → migrations for users, cache, jobs
- public/    → entry point (index.php) & static assets
- resources/ → Blade views, Livewire view templates, CSS/JS assets
- routes/    → HTTP, console, channels definition
- storage/   → app files, cache, sessions, logs
- native/    → NativePHP engine artifacts
- tests/     → unit & feature tests
- build files: vite.config.js, tailwind.config.js, package.json
- Presence of Livewire (app/Livewire, resources/views/livewire) indicates component-driven UI with real-time XHR/WebSocket updates.
- The .env, artisan, composer.json indicate a Laravel backend. The “native” folder and php artisan native:* commands signal NativePHP’s embedded-server on device.

##### README insights
- Purpose: demo for NativePHP for Mobile license & Flux UI Pro.
- Installation steps: clone, composer+npm install, build assets, run php artisan native:install & native:run → launches on device.

##### Main components
a. Mobile Device & OS
- Shows the handset running Android/iOS.
- NativePHP runtime embedded in the app.
b. PHP Application Server
- Laravel entry point (public/index.php → bootstrap → service providers).
- HTTP kernel & Livewire kernel.
c. Livewire Component Layer
- PHP components (app/Livewire) ↔ JS runtime in WebView
- Blade templates & Flux UI Pro shaders.
d. Asset Pipeline
- Vite dev server / build → app.css, app.js, echo.js
- Tailwind CSS
e. Data Storage
- Local database (SQLite or configured DB in config/database.php)
- File storage (storage/app/private & public)
- Cache & sessions (storage/framework)
- Queues (jobs table)
f. Native Device Services
- Camera, Microphone, Geolocation, Push Notifications, Haptics, Secure Storage, etc.
- Exposed via Livewire components that fire events to the PHP backend.
g. External Services
- WorkOS (config/workos.php, AuthKit), maybe broadcast driver (Pusher/Echo).
- Any third-party APIs (e.g., cloud mail, queue, cache services if configured).

##### Relationships & data flows
- UI Interaction (touch)
→ Livewire JS component
→ AJAX/WebSocket request to Livewire kernel
→ Controller / Livewire class (app/Livewire)
→ Optional Service classes (app/Services) or Models (app/Models)
→ Database / Storage / External API
→ Response back to Livewire JS
→ DOM diff applied in WebView
- Events: Laravel events (app/Events) broadcast via Echo → Livewire listeners → front-end update.
- Console commands (app/Console) for setup, migrations, native:install, native:run.

##### Architectural patterns & principles
- MVC at the core (Controllers, Models, Views)
- Component-based UI via Livewire (separation of stateful UI logic)
- Event-driven updates (Laravel Events + Echo)
- Service layer for business logic (app/Services/KitchenSinkService)
- Clear separation: Frontend assets vs. backend runtime vs. device bridges

##### Essential elements summary
- Components: OS/Device, NativePHP, Laravel Kernel, Livewire Layer, Blade + Flux UI, Asset Bundler, DB & Storage, External APIs
- Data flows: user input → Livewire → backend → persistence → front-end update
- Patterns: MVC, Component-based, Event-driven
- Technologies: PHP 8+, Laravel, Livewire, NativePHP, Vite, Tailwind, Flux UI, WorkOS API

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Device Layer
    subgraph "Device Layer"
        Device("Mobile Device & OS"):::device
        Native("NativePHP Runtime"):::runtime
    end
    Device --> Native

    %% Application Layer
    subgraph "Application Layer"
        subgraph "Entry & Bootstrap"
            Index("public/index.php"):::entry
            BootstrapApp("bootstrap/app.php"):::bootstrap
            BootstrapProv("bootstrap/providers.php"):::bootstrap
        end

        subgraph "Laravel HTTP & Livewire Kernel"
            Controllers("app/Http/Controllers"):::backend
            Middleware("app/Http/Middleware"):::backend
            RoutesWeb("routes/web.php"):::backend
            RoutesConsole("routes/console.php"):::backend
        end

        subgraph "Service & Events"
            Service("app/Services/KitchenSinkService.php"):::service
            Events("app/Events/"):::events
        end

        subgraph "Livewire Component Layer"
            LWApp("app/Livewire/"):::livewire
            LWViews("resources/views/livewire/"):::livewire
            Camera("Camera Component"):::component
            Geolocation("Geolocation Component"):::component
            Microphone("Microphone Component"):::component
            PushNotif("PushNotification Component"):::component
            Haptics("Haptics Component"):::component
            SecureStorage("SecureStorage Component"):::component
        end

        subgraph "Blade & Flux UI"
            BladeLayout("resources/views/components/layouts/app.blade.php"):::blade
            FluxViews("resources/views/flux/"):::blade
        end

        subgraph "Asset Pipeline"
            Vite("vite.config.js"):::asset
            Tailwind("tailwind.config.js"):::asset
            CSS("resources/css/app.css"):::asset
            JSApp("resources/js/app.js"):::asset
            EchoJS("resources/js/echo.js"):::asset
        end
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB("SQLite DB"):::db
        Models("app/Models/User.php"):::model
        DBConfig("config/database.php"):::config
        MigrUsers("database/migrations/0001_01_01_000000_create_users_table.php"):::migration
        MigrCache("database/migrations/0001_01_01_000001_create_cache_table.php"):::migration
        MigrJobs("database/migrations/0001_01_01_000002_create_jobs_table.php"):::migration
        Storage("storage/app/"):::storage
        Cache("storage/framework/cache/"):::storage
        Sessions("storage/framework/sessions/"):::storage
    end

    %% External Services
    subgraph "External Services"
        WorkOS("config/workos.php"):::external
        Broadcasting("config/broadcasting.php"):::external
        WorkOSReq("app/Http/Requests/WorkOS.php"):::external
    end

    %% Data Flows
    Native -->|"start server"| Index
    Index -->|"bootstrap"| BootstrapApp
    BootstrapApp --> BootstrapProv
    BootstrapProv --> Controllers
    Controllers --> Middleware
    Middleware --> RoutesWeb
    RoutesWeb --> Controllers
    RoutesConsole --> Service

    Native -->|"serve assets"| Vite
    Native --> CSS
    Native --> JSApp
    Native --> EchoJS

    JSApp -->|"Livewire XHR/WebSocket"| LWApp
    LWApp --> Controllers
    Controllers --> Service
    Service --> Models
    Service --> DB
    Controllers --> Storage
    DB --> Controllers
    Controllers --> LWApp
    LWApp --> JSApp
    JSApp -->|"DOM diff"| Device

    %% Native Device Services Integrations
    LWApp --> Camera
    LWApp --> Geolocation
    LWApp --> Microphone
    LWApp --> PushNotif
    LWApp --> Haptics
    LWApp --> SecureStorage

    %% Blade & Flux UI Integration
    LWViews --> BladeLayout
    BladeLayout --> FluxViews

    %% External
    Controllers --> WorkOSReq
    Controllers --> WorkOS
    Controllers --> Broadcasting

    %% Click Events
    click Native "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/native/"
    click Index "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/public/index.php"
    click BootstrapApp "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/bootstrap/app.php"
    click BootstrapProv "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/bootstrap/providers.php"
    click Controllers "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/app/Http/Controllers"
    click Middleware "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/app/Http/Middleware"
    click RoutesWeb "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/routes/web.php"
    click RoutesConsole "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/routes/console.php"
    click LWApp "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/app/Livewire/"
    click LWViews "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/resources/views/livewire/"
    click BladeLayout "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/resources/views/components/layouts/app.blade.php"
    click FluxViews "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/resources/views/flux/"
    click Vite "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/vite.config.js"
    click Tailwind "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/tailwind.config.js"
    click CSS "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/resources/css/app.css"
    click JSApp "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/resources/js/app.js"
    click EchoJS "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/resources/js/echo.js"
    click Models "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/app/Models/User.php"
    click DBConfig "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/config/database.php"
    click MigrUsers "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/database/migrations/0001_01_01_000000_create_users_table.php"
    click MigrCache "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/database/migrations/0001_01_01_000001_create_cache_table.php"
    click MigrJobs "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/database/migrations/0001_01_01_000002_create_jobs_table.php"
    click Storage "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/storage/app/"
    click Cache "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/storage/framework/cache/"
    click Sessions "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/storage/framework/sessions/"
    click Service "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/app/Services/KitchenSinkService.php"
    click Events "https://github.com/nativephp/kitchen-sink-mobile/tree/2.x/app/Events/"
    click WorkOS "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/config/workos.php"
    click Broadcasting "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/config/broadcasting.php"
    click WorkOSReq "https://github.com/nativephp/kitchen-sink-mobile/blob/2.x/app/Http/Requests/WorkOS.php"

    %% Styles
    classDef device fill:#B3E5FC,stroke:#0277BD,color:#000
    classDef runtime fill:#81D4FA,stroke:#0288D1,color:#000
    classDef entry fill:#FFCC80,stroke:#EF6C00,color:#000
    classDef bootstrap fill:#FFE0B2,stroke:#F57C00,color:#000
    classDef backend fill:#FFAB91,stroke:#D84315,color:#000
    classDef service fill:#CE93D8,stroke:#6A1B9A,color:#000
    classDef events fill:#E1BEE7,stroke:#8E24AA,color:#000
    classDef livewire fill:#A5D6A7,stroke:#2E7D32,color:#000
    classDef component fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef blade fill:#FFF59D,stroke:#F9A825,color:#000
    classDef asset fill:#B2EBF2,stroke:#00796B,color:#000
    classDef db fill:#B0BEC5,stroke:#455A64,color:#000
    classDef model fill:#90A4AE,stroke:#546E7A,color:#000
    classDef config fill:#ECEFF1,stroke:#607D8B,color:#000
    classDef migration fill:#CFD8DC,stroke:#546E7A,color:#000
    classDef storage fill:#B0BEC5,stroke:#37474F,color:#000
    classDef external fill:#D1C4E9,stroke:#4527A0,color:#000
```
