# venturaproject/symfony-api-platform architecture

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

- Interactive diagram: https://gitdiagram.com/venturaproject/symfony-api-platform
- Repository: https://github.com/venturaproject/symfony-api-platform

## Overview

##### High-Level Architecture Components

- Frontend Layer (Next.js)
- Backend Layer (Symfony/API Platform)
- Infrastructure Layer

##### Key Components

Frontend Section:
- Next.js Application (Port 4000)
- Components Layer (/src/components)
- Services Layer (/src/services)
- Context Layer (Auth Context)
- Pages Layer
- i18n Internationalization

Backend Section (Port 8800):
- API Platform Layer
- Bounded Contexts:
- Product Context
- User Context
- Shared Context
- CQRS Implementation:
- Command Bus
- Query Bus
- Event Bus
- Doctrine ORM
- Security Layer

Infrastructure Section:
- Nginx
- PHP-FPM
- Node
- Supervisor
- Database

##### Architectural Patterns to Highlight

Following patterns with distinct visual elements:
- Hexagonal Architecture (Ports and Adapters)
- Application Layer
- Domain Layer
- Infrastructure Layer
- CQRS Pattern Flow
- Event-Driven Architecture
- Repository Pattern
- Domain-Driven Design Boundaries

##### Component Relationships

- Frontend to Backend API calls
- Command/Query flow in CQRS
- Event propagation
- Database interactions
- Authentication flow

##### Specific Implementation Details

For each bounded context (Product, User), show:
- Commands (Create, Update, Delete)
- Queries (GetAll, GetById)
- Domain Events
- DTOs
- Resources
- Repositories

##### Additional Elements

Include:
- API Platform Swagger UI
- JWT Authentication flow
- i18n translation flow
- Event listeners and subscribers
- Exception handling flow

##### Implementation Notes

Notes for:
- Port numbers (4000, 8800)
- Technology stack versions
- Key configuration files
- Important dependencies

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend["Frontend Layer (Port 4000)"]
        direction TB
        NextApp["Next.js Application"]
        Components["Components Layer"]:::frontend
        Services["Services Layer"]:::frontend
        AuthContext["Auth Context"]:::frontend
        Pages["Pages Layer"]
        I18N["i18n Internationalization"]:::frontend
    end

    subgraph Backend["Backend Layer (Port 8800)"]
        direction TB
        API["API Platform"]:::backend
        
        subgraph BC["Bounded Contexts"]
            direction TB
            subgraph PC["Product Context"]
                direction TB
                PCommands["Commands"]:::backend
                PQueries["Queries"]:::backend
                PDomain["Domain"]:::backend
                PInfra["Infrastructure"]:::backend
            end
            
            subgraph UC["User Context"]
                direction TB
                UCommands["Commands"]:::backend
                UQueries["Queries"]:::backend
                UDomain["Domain"]:::backend
                UInfra["Infrastructure"]:::backend
            end
            
            subgraph SC["Shared Context"]
                direction TB
                CommandBus["Command Bus"]:::backend
                QueryBus["Query Bus"]:::backend
                EventBus["Event Bus"]:::backend
            end
        end
        
        Security["Security Layer"]:::backend
        ORM["Doctrine ORM"]:::backend
    end

    subgraph Infra["Infrastructure Layer"]
        direction TB
        Nginx["Nginx"]:::infra
        PHP["PHP-FPM"]:::infra
        Node["Node"]:::infra
        Supervisor["Supervisor"]:::infra
        DB[(Database)]:::database
    end

    %% Relationships
    NextApp --> Components
    NextApp --> Services
    NextApp --> AuthContext
    NextApp --> Pages
    NextApp --> I18N
    
    API --> BC
    CommandBus --> PCommands
    CommandBus --> UCommands
    QueryBus --> PQueries
    QueryBus --> UQueries
    EventBus --> PDomain
    EventBus --> UDomain
    
    PC --> ORM
    UC --> ORM
    ORM --> DB
    
    Frontend --> API
    API --> Security

    %% Click Events
    click Components "https://github.com/venturaproject/symfony-api-platform/tree/main/frontend/src/components"
    click Services "https://github.com/venturaproject/symfony-api-platform/tree/main/frontend/src/services"
    click AuthContext "https://github.com/venturaproject/symfony-api-platform/blob/main/frontend/src/context/AuthContext.tsx"
    click I18N "https://github.com/venturaproject/symfony-api-platform/blob/main/frontend/src/i18n.ts"
    
    click PCommands "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/Product/Application/Command"
    click PQueries "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/Product/Application/Query"
    click PDomain "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/Product/Domain"
    click PInfra "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/Product/Infrastructure"
    
    click UCommands "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/User/Application/Command"
    click UQueries "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/User/Application/Query"
    click UDomain "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/User/Domain"
    click UInfra "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/User/Infrastructure"
    
    click CommandBus "https://github.com/venturaproject/symfony-api-platform/blob/main/api/src/Shared/Infrastructure/Bus/CommandBus.php"
    click QueryBus "https://github.com/venturaproject/symfony-api-platform/blob/main/api/src/Shared/Infrastructure/Bus/QueryBus.php"
    click EventBus "https://github.com/venturaproject/symfony-api-platform/blob/main/api/src/Shared/Infrastructure/Bus/DomainEventBus.php"
    
    click Security "https://github.com/venturaproject/symfony-api-platform/tree/main/api/src/Shared/Infrastructure/Security"
    click Nginx "https://github.com/venturaproject/symfony-api-platform/tree/main/infrastructure/nginx"
    click PHP "https://github.com/venturaproject/symfony-api-platform/tree/main/infrastructure/php"
    click Node "https://github.com/venturaproject/symfony-api-platform/tree/main/infrastructure/node"
    click Supervisor "https://github.com/venturaproject/symfony-api-platform/tree/main/infrastructure/supervisor"

    %% Styles
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef infra fill:#607D8B,color:white
    classDef database fill:#FF9800,color:white

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Component"]:::backend
        Infra_L["Infrastructure Component"]:::infra
        DB_L[(Database)]:::database
    end
```
