# justteshi/sylius-tutorial architecture

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

- Interactive diagram: https://gitdiagram.com/justteshi/sylius-tutorial
- Repository: https://github.com/justteshi/sylius-tutorial

## Overview

The Sylius Standard Edition is a fully featured, decoupled eCommerce framework built on top of Symfony and Doctrine. Its purpose is to provide a highly flexible, scalable platform for building custom eCommerce solutions. The project’s file tree and README indicate that it is a full-stack application with clearly separated frontend and backend components, comprehensive configuration management, and containerized deployment support via Docker.

##### Main Components
- Frontend:
- Assets: Two key directories (assets/admin and assets/shop) hold the JavaScript entry points for the administration and storefront interfaces. These are built using tools like Webpack (see webpack.config.js and webpack_encore.yaml), and yarn is used for dependency management.
- Public: The public/ directory contains index.php and other publicly accessible files (like .htaccess) which serve as the entry point for incoming HTTP requests.
- Backend:
- Symfony Application: Most of the business logic lives in the src/ directory with controllers, entities (organized by domain like Order, Product, User, etc.), and a Kernel (src/Kernel.php) that bootstraps the application.
- Configuration: The config/ directory contains various sub-directories and files that configure bundles, API Platform (a REST API backend), security, Doctrine (ORM) settings, routing, and other environment-specific configurations.
- Services: Service definitions are included in config/services.yaml and corresponding test files (services_test.yaml) to tailor dependency injection for different environments.
- Database & Persistence:
- Doctrine ORM: Entities in src/Entity are mapped for relational DB storage via Doctrine. Migrations (in src/Migrations) help with schema versioning and evolution.
- APIs & External Integrations:
- API Platform: Configured under config/api_platform for exposing a robust REST API.
- External Libraries: Integration with JWT, FOS REST, and other bundles, which are configured in various YAML files.
- Testing & Development Tools:
- BDD Tools: Behat (features) and PHPSpec (phpspec.yaml.dist) demonstrate a behavior-driven-development workflow.
- Continuous Integration: GitHub workflows under .github/workflows and CI configurations like ecs.php and phpstan.neon ensure code quality.
- Deployment & Containerization:
- Docker: Multiple Docker-related files (Dockerfile, docker-compose.yml, docker-compose.prod.yml, and subfolders under docker/) indicate that the application is containerized. Separate configurations exist for development and production environments.

##### Relationships and Interactions
- Client Interaction:
- Users access the frontend (both Shop and Admin interfaces) via a web browser that loads the application from the public directory.
- The assets (JavaScript, CSS) are built and served by a Node/webpack service that communicates back to the Symfony backend.
- Backend Processing:
- HTTP requests reach the Symfony application (via index.php in public/) that routes them through the controllers in src/Controller.
- The controllers interact with business logic (entities, services, repositories) and trigger database operations through Doctrine.
- API Exposure:
- API Platform exposes endpoints from configured entities, allowing for external integrations and modern frontend frameworks to consume data.
- Dockerized Environment:
- Docker containers are used for PHP (with separate configurations for production and development), Nginx (as the web server), Node (for asset building), and possibly a database container.
- Testing & CI:
- Automated testing is integrated via PHPUnit, Behat, and PHPSpec. CI workflows manage builds, tests, and deployments.

##### Architectural Patterns and Design Principles
- Decoupled Architecture: Frontend assets and backend are clearly separated.
- Domain-Driven Design: The entity structure in src/Entity is organized by domain (e.g., Order, Product, User) to encapsulate business logic.
- Service-Oriented: The dependency injection and extensive use of external bundles promote modularity and reusability.
- Containerization: The use of Docker and separate configuration files for various environments supports agile and consistent deployments across environments.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Web Browser"]:::external
        PublicEntry["Public Entry (index.php)"]:::frontend
        AdminIF["Admin Interface"]:::frontend
        ShopIF["Shop Interface"]:::frontend
    end

    %% Application Layer
    subgraph "Application Layer"
        Controllers["Controllers (src/Controller)"]:::backend
        Kernel["Kernel (src/Kernel.php)"]:::backend
        BusinessLogic["Business Logic & Entities (src/Entity)"]:::backend
        Config["Configuration & Services (config/)"]:::config
        APIPlatform["API Platform & Integrations"]:::config
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        DB["Database (Doctrine ORM)"]:::persistence
        Migrations["Migrations (src/Migrations)"]:::persistence
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        PHPContainer["PHP Container (Docker)"]:::infra
        NginxContainer["Nginx Container (Docker)"]:::infra
        NodeContainer["Node Container (Docker)"]:::infra
        DockerConfig["Docker Config"]:::infra
        CICD["CI/CD & Testing Tools"]:::infra
    end

    %% Connections in Presentation Layer
    Browser -->|"SendsRequest"| NginxContainer
    NginxContainer -->|"ForwardsRequest"| PublicEntry
    PublicEntry -->|"RoutesRequest"| Controllers
    NodeContainer -->|"BuildsAssets"| AdminIF
    NodeContainer -->|"BuildsAssets"| ShopIF
    AdminIF -->|"RendersUI"| Browser
    ShopIF -->|"RendersUI"| Browser

    %% Connections in Application Layer
    Kernel -->|"Bootstraps"| Controllers
    Controllers -->|"Processes"| BusinessLogic
    Config -->|"InjectsConfig"| Controllers
    APIPlatform -->|"Exposes"| BusinessLogic

    %% Connections in Persistence Layer
    BusinessLogic -->|"CRUD"| DB
    Migrations -->|"MigratesSchema"| DB

    %% Connections in Infrastructure Layer
    DockerConfig -->|"Configures"| PHPContainer
    DockerConfig -->|"Configures"| NginxContainer
    DockerConfig -->|"Configures"| NodeContainer
    PHPContainer -->|"Runs"| Kernel
    CICD -->|"RunsTestsOn"| Config
    CICD -->|"RunsTestsOn"| BusinessLogic

    %% Class Definitions
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef config fill:#d3d3d3,stroke:#000,stroke-width:2px;
    classDef persistence fill:#ffe4b5,stroke:#000,stroke-width:2px;
    classDef infra fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef external fill:#c0c0c0,stroke:#000,stroke-width:2px;

    %% Click Events
    click AdminIF "https://github.com/justteshi/sylius-tutorial/blob/master/assets/admin/entry.js"
    click ShopIF "https://github.com/justteshi/sylius-tutorial/blob/master/assets/shop/entry.js"
    click PublicEntry "https://github.com/justteshi/sylius-tutorial/blob/master/public/index.php"
    click Controllers "https://github.com/justteshi/sylius-tutorial/tree/master/src/Controller"
    click Kernel "https://github.com/justteshi/sylius-tutorial/blob/master/src/Kernel.php"
    click BusinessLogic "https://github.com/justteshi/sylius-tutorial/tree/master/src/Entity"
    click Config "https://github.com/justteshi/sylius-tutorial/tree/master/config/"
    click APIPlatform "https://github.com/justteshi/sylius-tutorial/tree/master/config/api_platform"
    click Migrations "https://github.com/justteshi/sylius-tutorial/tree/master/src/Migrations"
    click CICD "https://github.com/justteshi/sylius-tutorial/tree/master/.github/workflows"
    click DockerConfig "https://github.com/justteshi/sylius-tutorial/tree/master/docker/"
    click NodeContainer "https://github.com/justteshi/sylius-tutorial/tree/master/docker/node"
    click NginxContainer "https://github.com/justteshi/sylius-tutorial/tree/master/docker/nginx"
    click PHPContainer "https://github.com/justteshi/sylius-tutorial/tree/master/docker/php"
```
