# symfony/http-kernel architecture

> Architecture diagram of the GitHub repository symfony/http-kernel, 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/symfony/http-kernel
- Repository: https://github.com/symfony/http-kernel

## Overview

##### Main Components

a. Core Components:
- HttpKernel (Central Processing Unit)
- Event Dispatcher System
- Controller System
- Exception Handling System
- Cache System
- Profiler System

b. Request Flow Components:
- Request Handler
- Controller Resolver
- Argument Resolver
- Response Generator

**┌─ Input Layer ─────────────────────┐**
- HTTP Request                      │
- ┬───────────────────┘
- ↓
**┌─ Kernel Layer ─────────────────────────────────────────┐**
- ┌─ Event Dispatcher ─────────────────────────────────┐ │

- ┌─ HttpKernel ────────────────────┐              │ │
- ┌─────────────┐ ┌─────────────┐ │              │ │
- Controller  │ │  Argument   │ │  ← Events    │ │
- Resolver   │ │  Resolver   │ │              │ │
- ┘ └─────────────┘ │              │ │
- ┘              │ │
- ┘ │
- ┬─────────────────────────────┘
- ↓
**┌─ Processing Layer ──────────────────────────────────────┐**
- ┌─ Controller ─────┐  ┌─ Cache ──────┐  ┌─ Profiler ─┐ │
- Arguments     │  │ - Store      │  │ - Timeline  │ │
- Processing    │  │ - Strategy   │  │ - Data      │ │
- ┘  └─────────────┘  └────────────┘ │
- ┬─────────────────────────────┘
- ↓
**┌─ Output Layer ────────────────────┐**
- HTTP Response                     │
- ┘

##### Key Relationships

- Event Flow: Show how events propagate through the system
- Request Processing Pipeline: Illustrate the sequential processing steps
- Component Dependencies: Show how different parts interact
- Cache Integration: Demonstrate how caching interfaces with the main system

##### Important Details

a. Event System:
- KernelEvents (request, controller, view, response, terminate)
- Event Listeners
- Event Subscribers

b. Controller System:
- ArgumentResolver chain
- ValueResolvers
- Controller Resolution process

c. Exception Handling:
- Exception Listeners
- Error Controllers
- HTTP Exception hierarchy

##### Implementation Notes

- Use standardized UML notation where appropriate
- Use clear, readable fonts
- Version information if relevant

##### Specific Component Relationships

How the following interact:
- HttpKernel → EventDispatcher
- Controller Resolver → ArgumentResolver
- Cache System → Response handling
- Profiler → Event System

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        Request[HTTP Request]:::io
    end

    subgraph KernelLayer
        subgraph EventSystem
            EventDispatcher["Event Dispatcher"]:::event
            Events["KernelEvents"]:::event
            EventListeners["Event Listeners"]:::event
        end

        subgraph CoreKernel
            HttpKernel["HttpKernel Core"]:::core
            ControllerResolver["Controller Resolver"]:::core
            ArgumentResolver["Argument Resolver"]:::core
        end
    end

    subgraph ProcessingLayer
        subgraph ControllerSystem
            Controller["Controller Processing"]:::processing
            Arguments["Argument Processing"]:::processing
        end

        subgraph CacheSystem
            Cache["Cache System"]:::cache
            CacheClearer["Cache Clearer"]:::cache
            CacheWarmer["Cache Warmer"]:::cache
        end

        subgraph ProfilerSystem
            Profiler["Profiler"]:::profiler
            DataCollector["Data Collector"]:::profiler
        end

        subgraph ExceptionSystem
            ExceptionHandler["Exception Handler"]:::error
            ErrorController["Error Controller"]:::error
        end
    end

    subgraph Output
        Response[HTTP Response]:::io
    end

    %% Relationships
    Request --> EventDispatcher
    EventDispatcher --> HttpKernel
    HttpKernel --> ControllerResolver
    ControllerResolver --> ArgumentResolver
    ArgumentResolver --> Controller
    Controller --> Cache
    Cache --> Response
    HttpKernel --> ExceptionHandler
    ExceptionHandler --> ErrorController
    ErrorController --> Response
    EventDispatcher --> Events
    Events --> EventListeners
    EventListeners --> HttpKernel
    Controller --> Arguments
    HttpKernel --> Profiler
    Profiler --> DataCollector
    Cache --> CacheClearer
    Cache --> CacheWarmer

    %% Click Events
    click HttpKernel "https://github.com/symfony/http-kernel/blob/7.2/HttpKernel.php"
    click EventDispatcher "https://github.com/symfony/http-kernel/tree/7.2/Event/"
    click Events "https://github.com/symfony/http-kernel/blob/7.2/KernelEvents.php"
    click EventListeners "https://github.com/symfony/http-kernel/tree/7.2/EventListener/"
    click ControllerResolver "https://github.com/symfony/http-kernel/blob/7.2/Controller/ControllerResolver.php"
    click ArgumentResolver "https://github.com/symfony/http-kernel/blob/7.2/Controller/ArgumentResolver.php"
    click Controller "https://github.com/symfony/http-kernel/tree/7.2/Controller/"
    click ExceptionHandler "https://github.com/symfony/http-kernel/tree/7.2/Exception/"
    click Cache "https://github.com/symfony/http-kernel/tree/7.2/HttpCache/"
    click CacheClearer "https://github.com/symfony/http-kernel/tree/7.2/CacheClearer/"
    click CacheWarmer "https://github.com/symfony/http-kernel/tree/7.2/CacheWarmer/"
    click Profiler "https://github.com/symfony/http-kernel/tree/7.2/Profiler/"
    click DataCollector "https://github.com/symfony/http-kernel/tree/7.2/DataCollector/"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef event fill:#4CAF50,stroke:#2E7D32,color:white
    classDef processing fill:#FFC107,stroke:#FFA000,color:black
    classDef cache fill:#FF9800,stroke:#F57C00,color:white
    classDef profiler fill:#9C27B0,stroke:#7B1FA2,color:white
    classDef error fill:#f44336,stroke:#c62828,color:white
    classDef io fill:#90A4AE,stroke:#546E7A,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Event System]:::event
        L3[Processing]:::processing
        L4[Cache]:::cache
        L5[Profiler]:::profiler
        L6[Error Handling]:::error
        L7[Input/Output]:::io
    end
```
