# altinawiwaseem/teaser_app architecture

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

- Interactive diagram: https://gitdiagram.com/altinawiwaseem/teaser_app
- Repository: https://github.com/altinawiwaseem/teaser_app

## Overview

##### Project type and purpose
- This is a full-stack web application built with the TALL stack:
- Tailwind CSS (UI styling)
- Alpine.js (lightweight frontend behavior)
- Laravel (PHP backend + MVC + Blade + Livewire)
- Livewire v3 (server-driven reactive components)
- Purpose: allow authenticated users to create/read “teasers” (title, description, image) with live image-upload preview.

##### Top-level components
a. Client (Browser)
- HTML/CSS/JS delivered by Vite
- Alpine.js for local interactivity
- Livewire JS to open WebSocket/AJAX connections for component updates
b. Web Server
- Apache or Nginx + PHP-FPM
c. Laravel Application
- HTTP kernel → routing (routes/web.php, routes/auth.php) → controllers & Livewire components
- MVC Layers: Controllers (app/Http/Controllers), Views (resources/views + Blade + Livewire templates), Models (app/Models)
- Livewire components (app/Livewire) for teaser forms, listings, edits
- Form requests & validation (app/Http/Requests)
- Service providers (app/Providers)
d. Database
- MySQL (configured via config/database.php, .env)
- Migrations (database/migrations) define users & teasers tables
- Eloquent models (User, Teaser)
e. Storage
- Local disk: storage/app/public → symlinked to public/storage
- Serves uploaded teaser images
f. Build Tools
- Vite (vite.config.js) compiles JS (Alpine.js) & CSS (Tailwind)
- PostCSS, Tailwind config
g. External Services (optional)
- Mail (config/mail)
- Queue (config/queue) if background jobs are used
- Third-party APIs (config/services)

##### Relationships & data-flow
1. Browser → HTTP GET / → public/index.php → Laravel Router → WelcomeController or Livewire component → Blade view → HTML/CSS/JS
2. Browser interacts with Livewire component (e.g., TeaserForm) via AJAX/WebSockets → Livewire lifecycle methods → Controller/Component class → Model → DB
3. File uploads handled by Livewire + Alpine.js preview → stored to storage/app/public → accessible via public/storage
4. Authentication flows: Registration/Login (controllers in app/Http/Controllers/Auth) → session cookies → protected routes (Profile, Teasers)
5. Vite dev server (npm run dev) serves hot-reload assets; in production assets are pre-built and served from public/build.

##### Architectural patterns & design principles
- MVC + componentized UI (Livewire)
- Single PHP backend with AJAX-driven reactive components (no full SPA)
- Separation of concerns: validation in FormRequests, business logic in Controllers/Livewire, data in Models, presentation in Views
- Asset bundling & code-splitting via Vite
- File storage abstraction via Laravel’s Filesystem

##### Final checklist
- [ ] Clear component boundaries and labels
- [ ] Callouts for build tools (Vite) vs. runtime (Laravel)
- [ ] Notes on environment differences (development vs. production)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client (Browser)" 
        direction TB
        HTML["HTML/CSS/JS"]:::client
        Alpine["Alpine.js"]:::client
        LivewireJS["Livewire JS"]:::client
    end

    %% Dev Tools
    subgraph "Dev Tools" 
        direction TB
        Vite["Vite Dev Server (5173)"]:::dev
        TailwindCFG["tailwind.config.js"]:::dev
        PostCSSCFG["postcss.config.js"]:::dev
    end

    %% Infrastructure
    subgraph "Infrastructure" 
        direction TB
        WebServer["Web Server + PHP-FPM"]:::infra
        IndexPHP["public/index.php"]:::infra
        HTAccess["public/.htaccess"]:::infra
    end

    %% Application Layer
    subgraph "Laravel App" 
        direction TB
        subgraph "HTTP Kernel & Routing"
            Kernel["HTTP Kernel"]:::app
            Router["Router"]:::app
            WebRoutes["routes/web.php"]:::app
            AuthRoutes["routes/auth.php"]:::app
            ConsoleRoutes["routes/console.php"]:::app
        end
        subgraph "Controllers"
            TeaserCtrl["TeaserController.php"]:::app
            ProfileCtrl["ProfileController.php"]:::app
            AuthCtrls["app/Http/Controllers/Auth/*"]:::app
        end
        subgraph "Livewire Components"
            TeaserForm["TeaserForm.php"]:::app
            TeaserList["TeaserList.php"]:::app
            TeaserEdit["TeaserEdit.php"]:::app
        end
        subgraph "Form Requests"
            ProfileReq["ProfileUpdateRequest.php"]:::app
            LoginReq["LoginRequest.php"]:::app
        end
        subgraph "Models & ORM"
            TeaserModel["Teaser.php"]:::app
            UserModel["User.php"]:::app
        end
        subgraph "Views & Templates"
            LWFormView["teaser-form.blade.php"]:::app
            LWListView["teaser-list.blade.php"]:::app
            LWEditView["teaser-edit.blade.php"]:::app
            ShowView["teasers/show.blade.php"]:::app
            AuthViews["resources/views/auth/*.blade.php"]:::app
            Layouts["resources/views/layouts/*.blade.php"]:::app
        end
        subgraph "Providers & Bootstrapping"
            AppProv["AppServiceProvider.php"]:::app
            BootApp["bootstrap/app.php"]:::app
            BootProv["bootstrap/providers.php"]:::app
        end
        subgraph "Configuration"
            DBConfig["config/database.php"]:::app
            FSConfig["config/filesystems.php"]:::app
            MailConfig["config/mail.php"]:::app
            QueueConfig["config/queue.php"]:::app
            ServicesConfig["config/services.php"]:::app
            LivewireConfig["config/livewire.php"]:::app
        end
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        MySQL["MySQL Database"]:::data
        Migrations["database/migrations/*"]:::data
        Seeder["database/seeders/DatabaseSeeder.php"]:::data
        StoragePub["storage/app/public/"]:::data
        StoragePriv["storage/app/private/"]:::data
    end

    %% Build Assets
    subgraph "Assets"
        direction TB
        CSS["resources/css/app.css"]:::assets
        JSApp["resources/js/app.js"]:::assets
        JSBoot["resources/js/bootstrap.js"]:::assets
    end

    %% Flows
    CSS -->|built by Vite| Vite
    JSApp -->|built by Vite| Vite
    JSBoot -->|built by Vite| Vite
    Vite -.->|hot reload assets| HTML
    HTML -->|HTTP GET /| IndexPHP
    HTAccess -->|rewrite| IndexPHP
    IndexPHP -->|dispatch| Kernel
    Kernel --> Router
    Router -->|routes/web| WebRoutes
    Router -->|routes/auth| AuthRoutes
    Router -->|routes/console| ConsoleRoutes
    Router --> TeaserCtrl
    Router --> ProfileCtrl
    Router --> AuthCtrls
    TeaserCtrl --> TeaserModel
    ProfileCtrl --> UserModel
    AuthCtrls --> UserModel
    TeaserModel <--> MySQL
    UserModel <--> MySQL
    Migrations --> MySQL
    Seeder --> MySQL
    TeaserForm --> TeaserModel
    TeaserList --> TeaserModel
    TeaserEdit --> TeaserModel
    TeaserForm --> StoragePub
    StoragePub -->|serve images| HTML
    LivewireJS --> TeaserForm
    LivewireJS --> TeaserList
    LivewireJS --> TeaserEdit
    Alpine --> HTML
    HTML --> LivewireJS
    Kernel -->|boot| AppProv
    BootApp --> Kernel
    BootProv --> Kernel
    Kernel --> DBConfig
    Kernel --> FSConfig
    Kernel --> MailConfig
    Kernel --> QueueConfig
    Kernel --> ServicesConfig
    Kernel --> LivewireConfig

    %% Click Events
    click CSS "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/css/app.css"
    click TailwindCFG "https://github.com/altinawiwaseem/teaser_app/blob/main/tailwind.config.js"
    click PostCSSCFG "https://github.com/altinawiwaseem/teaser_app/blob/main/postcss.config.js"
    click JSApp "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/js/app.js"
    click JSBoot "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/js/bootstrap.js"
    click Vite "https://github.com/altinawiwaseem/teaser_app/blob/main/vite.config.js"
    click IndexPHP "https://github.com/altinawiwaseem/teaser_app/blob/main/public/index.php"
    click HTAccess "https://github.com/altinawiwaseem/teaser_app/blob/main/public/.htaccess"
    click WebRoutes "https://github.com/altinawiwaseem/teaser_app/blob/main/routes/web.php"
    click AuthRoutes "https://github.com/altinawiwaseem/teaser_app/blob/main/routes/auth.php"
    click ConsoleRoutes "https://github.com/altinawiwaseem/teaser_app/blob/main/routes/console.php"
    click TeaserCtrl "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Http/Controllers/TeaserController.php"
    click ProfileCtrl "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Http/Controllers/ProfileController.php"
    click AuthCtrls "https://github.com/altinawiwaseem/teaser_app/tree/main/app/Http/Controllers/Auth/"
    click TeaserForm "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Livewire/TeaserForm.php"
    click TeaserList "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Livewire/TeaserList.php"
    click TeaserEdit "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Livewire/TeaserEdit.php"
    click LWFormView "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/views/livewire/teaser-form.blade.php"
    click LWListView "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/views/livewire/teaser-list.blade.php"
    click LWEditView "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/views/livewire/teaser-edit.blade.php"
    click ShowView "https://github.com/altinawiwaseem/teaser_app/blob/main/resources/views/teasers/show.blade.php"
    click AuthViews "https://github.com/altinawiwaseem/teaser_app/tree/main/resources/views/auth/"
    click Layouts "https://github.com/altinawiwaseem/teaser_app/tree/main/resources/views/layouts/"
    click TeaserModel "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Models/Teaser.php"
    click UserModel "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Models/User.php"
    click ProfileReq "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Http/Requests/ProfileUpdateRequest.php"
    click LoginReq "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Http/Requests/Auth/LoginRequest.php"
    click AppProv "https://github.com/altinawiwaseem/teaser_app/blob/main/app/Providers/AppServiceProvider.php"
    click BootApp "https://github.com/altinawiwaseem/teaser_app/blob/main/bootstrap/app.php"
    click BootProv "https://github.com/altinawiwaseem/teaser_app/blob/main/bootstrap/providers.php"
    click DBConfig "https://github.com/altinawiwaseem/teaser_app/blob/main/config/database.php"
    click FSConfig "https://github.com/altinawiwaseem/teaser_app/blob/main/config/filesystems.php"
    click MailConfig "https://github.com/altinawiwaseem/teaser_app/blob/main/config/mail.php"
    click QueueConfig "https://github.com/altinawiwaseem/teaser_app/blob/main/config/queue.php"
    click ServicesConfig "https://github.com/altinawiwaseem/teaser_app/blob/main/config/services.php"
    click LivewireConfig "https://github.com/altinawiwaseem/teaser_app/blob/main/config/livewire.php"
    click Migrations "https://github.com/altinawiwaseem/teaser_app/tree/main/database/migrations/"
    click Seeder "https://github.com/altinawiwaseem/teaser_app/blob/main/database/seeders/DatabaseSeeder.php"
    click StoragePub "https://github.com/altinawiwaseem/teaser_app/tree/main/storage/app/public/"
    click StoragePriv "https://github.com/altinawiwaseem/teaser_app/tree/main/storage/app/private/"

    %% Style Definitions
    classDef client fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef dev fill:#FFF4D6,stroke:#F5A623,color:#F5A623,stroke-dasharray: 5 5
    classDef infra fill:#E6FFFA,stroke:#2CB1A9,color:#2CB1A9
    classDef app fill:#FFF7E6,stroke:#D69E2E,color:#D69E2E
    classDef data fill:#FFEFE6,stroke:#E85D04,color:#E85D04
    classDef assets fill:#F0F0F0,stroke:#A0A0A0,color:#606060,stroke-dasharray: 2 2
```
