# laravel/jetstream architecture

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

- Interactive diagram: https://gitdiagram.com/laravel/jetstream
- Repository: https://github.com/laravel/jetstream

## Overview

##### Main Components Identification

The system should be represented with these key components:

a) Frontend Layer
- Dual Stack Support:
- Livewire Stack (Server-side rendering)
- Inertia Stack (Client-side rendering with Vue.js)
- UI Components (/resources/views or /resources/js)
- Authentication Views
- Team Management Interface

b) Core Application Layer
- Authentication System
- Team Management System
- API Token Management
- Profile Management
- Two-Factor Authentication

c) Service Layer
- Actions (src/Actions/)
- Events System (src/Events/)
- Mail Services (src/Mail/)
- Contracts (src/Contracts/)

d) Data Layer
- Database Migrations
- Models (Team, User, TeamInvitation)
- Factories for Testing

##### Component Relationships

**[Frontend Layer] ←→ [HTTP Controllers]**
- ↑               ↑

- ↓               ↓
**[Authentication] ←→ [Core Services] ←→ [Data Layer]**
- ↑               ↑

- ↓               ↓
- [API Layer] ←→ [Team Management]

##### Specific Implementation Details

Crucial elements:
- Authentication flows (login, registration, password reset)
- Team management workflows (creation, invitation, roles)
- API token management
- Profile management features
- Two-factor authentication flow

##### Integration Points

Key integration areas:
- Livewire/Inertia integration with backend
- Laravel Sanctum API authentication
- Event system connections
- Mail service integration

**┌─ Frontend Layer ─────────────┐**
- Livewire/Inertia Stacks   │
- Vue.js Components         │
- Blade Templates          │
- ┬──────────────┘
- ↓
**┌─ Application Core ──────────┐**
- Authentication           │
- Team Management         │
- Profile Management      │
- API Token Management    │
- ┬──────────────┘
- ↓
**┌─ Service Layer ────────────┐**
- Actions                 │
- Events                 │
- Mail                  │
- Contracts            │
- ┬──────────────┘
- ↓
**┌─ Data Layer ──────────────┐**
- Models                 │
- Migrations            │
- Factories            │
- ┘

Remember to:
- Detailed component interactions
- Document all authentication and authorization flows
- Clear boundaries between frontend stacks
- Extensibility points for custom implementations
- Error handling and security measures

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        FE_LW[Livewire Stack]:::frontend
        FE_IN[Inertia Stack]:::frontend
        UI_COMP[UI Components]:::frontend
        AUTH_V[Authentication Views]:::frontend
        TEAM_UI[Team Management Interface]:::frontend
        
        FE_LW --> UI_COMP
        FE_IN --> UI_COMP
        UI_COMP --> AUTH_V
        UI_COMP --> TEAM_UI
    end

    subgraph Core
        AUTH[Authentication System]:::auth
        TEAM[Team Management System]:::core
        API[API Token Management]:::api
        PROF[Profile Management]:::core
        TFA[Two-Factor Auth]:::auth

        AUTH --> TEAM
        AUTH --> API
        AUTH --> PROF
        AUTH --> TFA
    end

    subgraph Services
        ACT[Actions]:::service
        EVT[Events System]:::service
        MAIL[Mail Services]:::service
        CONT[Contracts]:::service

        ACT --> EVT
        EVT --> MAIL
        ACT --> CONT
    end

    subgraph Data
        MOD[Models]:::data
        MIG[Migrations]:::data
        FACT[Factories]:::data

        MIG --> MOD
        FACT --> MOD
    end

    Frontend --> Core
    Core --> Services
    Services --> Data

    classDef frontend fill:#3498db
    classDef core fill:#2ecc71
    classDef auth fill:#f1c40f
    classDef api fill:#e67e22
    classDef service fill:#9b59b6
    classDef data fill:#34495e

    click FE_LW "https://github.com/laravel/jetstream/tree/5.x/stubs/livewire/resources/views/"
    click FE_IN "https://github.com/laravel/jetstream/tree/5.x/stubs/inertia/resources/js/"
    click TEAM_UI "https://github.com/laravel/jetstream/blob/5.x/src/Http/Controllers/Inertia/TeamController.php"
    click AUTH "https://github.com/laravel/jetstream/tree/5.x/stubs/app/Actions/Fortify/"
    click TEAM "https://github.com/laravel/jetstream/tree/5.x/src/Actions/"
    click API "https://github.com/laravel/jetstream/blob/5.x/src/Http/Controllers/Inertia/ApiTokenController.php"
    click PROF "https://github.com/laravel/jetstream/blob/5.x/src/Http/Controllers/Inertia/UserProfileController.php"
    click EVT "https://github.com/laravel/jetstream/tree/5.x/src/Events/"
    click MAIL "https://github.com/laravel/jetstream/tree/5.x/src/Mail/"
    click CONT "https://github.com/laravel/jetstream/tree/5.x/src/Contracts/"
    click MOD "https://github.com/laravel/jetstream/blob/5.x/src/Team.php"
    click MIG "https://github.com/laravel/jetstream/tree/5.x/database/migrations/"
    click FACT "https://github.com/laravel/jetstream/tree/5.x/database/factories/"
    click UI_COMP "https://github.com/laravel/jetstream/tree/5.x/stubs/inertia/resources/js/Components/"
    click AUTH_V "https://github.com/laravel/jetstream/tree/5.x/stubs/livewire/resources/views/auth/"
```
