# inspector-apm/inspector-symfony architecture

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

- Interactive diagram: https://gitdiagram.com/inspector-apm/inspector-symfony
- Repository: https://github.com/inspector-apm/inspector-symfony

## Overview

##### Main Components Identification

a) Core Bundle Components:
- Inspector Bundle Core (central component)
- DependencyInjection System
- Event Listeners
- Middleware Components
- Tracers/Monitors

b) Integration Points:
- Doctrine DBAL Integration
- Symfony HTTP Kernel
- Console Commands
- Messenger System
- Twig Template Engine

##### Component Relationships

Use the following connection types:

##### Specific Component Details

Core Components (Blue):
- InspectorBundle (Main entry point)
- DependencyInjection (Configuration handling)
- Event Listeners (Various monitoring points)

Middleware Components (Green):
- Doctrine Middleware (SQL monitoring)
- Messenger Middleware (Queue monitoring)
- Twig Tracer (Template rendering)

Integration Points (Orange):
- HTTP Kernel Integration
- Console Commands
- Database Queries
- Message Queue

##### Implementation Details

a) Monitoring Flow:
- How data flows from monitored components
- Data collection points
- Transmission to Inspector APM service

b) Version Support:
- Support for different Doctrine versions (V2, V3, V4)
- Symfony version compatibility

##### Additional Notes

- Bundle's non-intrusive nature
- Automatic monitoring capabilities
- Configuration points
- Extension possibilities

Remember to:
- Use consistent styling
- Version compatibility notes
- Both synchronous and asynchronous operations
- Configuration points

This will provide a complete overview of how the Inspector Bundle integrates with Symfony applications and communicates with the Inspector APM service while monitoring various application components.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Symfony Application"
        IB["Inspector Bundle"]:::core
        click IB "https://github.com/inspector-apm/inspector-symfony/blob/master/src/InspectorBundle.php"
        
        subgraph "Core Components"
            DI["Dependency Injection"]:::core
            click DI "https://github.com/inspector-apm/inspector-symfony/tree/master/src/DependencyInjection"
            Config["Configuration"]:::config
            click Config "https://github.com/inspector-apm/inspector-symfony/blob/master/src/DependencyInjection/Configuration.php"
            Services["Services Config"]:::config
            click Services "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Resources/config/services.yml"
        end

        subgraph "Event Listeners"
            KES["Kernel Events Subscriber"]:::listener
            click KES "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Listeners/KernelEventsSubscriber.php"
            CES["Console Events Subscriber"]:::listener
            click CES "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Listeners/ConsoleEventsSubscriber.php"
            MES["Messenger Events Subscriber"]:::listener
            click MES "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Listeners/MessengerEventsSubscriber.php"
        end

        subgraph "Middleware & Tracers"
            DM["Doctrine Middleware"]:::middleware
            click DM "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Doctrine/Middleware/InspectorMiddleware.php"
            SQLT["SQL Segment Tracer"]:::tracer
            click SQLT "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Doctrine/Middleware/InspectorSQLSegmentTracer.php"
            MM["Messenger Middleware"]:::middleware
            click MM "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Messenger/MessengerMonitoringMiddleware.php"
            TT["Twig Tracer"]:::tracer
            click TT "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Twig/TwigTracer.php"
        end

        subgraph "Doctrine Version Support"
            V2["V2 SQL Logger"]:::version
            click V2 "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Doctrine/V2/InspectorSQLLogger.php"
            V3["V3 Connection"]:::version
            click V3 "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Doctrine/Middleware/V3/Connection.php"
            V4["V4 Connection"]:::version
            click V4 "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Doctrine/Middleware/V4/Connection.php"
        end

        subgraph "Integration Points"
            HTTP["HTTP Kernel"]:::integration
            Console["Console Commands"]:::integration
            click Console "https://github.com/inspector-apm/inspector-symfony/blob/master/src/Command/InspectorTestCommand.php"
            DB["Database Queries"]:::integration
            MQ["Message Queue"]:::integration
            Twig["Twig Templates"]:::integration
        end
    end

    IAPM["Inspector APM Service"]:::external

    %% Connections
    IB --> DI
    DI --> Config
    DI --> Services
    
    IB -.-> KES & CES & MES
    KES --> HTTP
    CES --> Console
    MES --> MQ
    
    DM --> DB
    SQLT --> DB
    MM --> MQ
    TT --> Twig
    
    V2 & V3 & V4 --> DB
    
    HTTP & Console & DB & MQ & Twig -.-> IAPM

    %% Styles
    classDef core fill:#a8d1f0,stroke:#333
    classDef config fill:#f5d6a7,stroke:#333
    classDef listener fill:#d4f0a8,stroke:#333
    classDef middleware fill:#f0a8d1,stroke:#333
    classDef tracer fill:#a8f0d1,stroke:#333
    classDef version fill:#d1a8f0,stroke:#333
    classDef integration fill:#f0d1a8,stroke:#333
    classDef external fill:#cccccc,stroke:#333

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Configuration"]:::config
        L3["Event Listeners"]:::listener
        L4["Middleware"]:::middleware
        L5["Tracers"]:::tracer
        L6["Version Support"]:::version
        L7["Integration Points"]:::integration
        L8["External Service"]:::external
    end
```
