Architecture hexagonale

Préambule

Symfony 6.0
Voir le dépôt sur mon GitHuB
Tout n'est pas implémenté, je me suis attaché à mettre en valeur les choix d'architecture, de leur implémentation et d'organisation du code
Uniquement le backend est développé et pour des facilités de test des commandes de console Symfony sont créées.

Le projet est écrit sur Symfony 6

🐳 Outils nécessaires

  1. docker
  2. docker-compose
  3. git

🛠 Installation du projet

git clone https://github.com/benoit-deuffic/ticklive.git ticklive
make install

🔥 Exécution de l'application

make up

✅ Tester

  1. Créer des produits: docker-compose exec php ./bin/console app:dbal-create-product test test3 3.25 {"food":true,"to-take":false}
  2. lister les produits: docker-compose exec php ./bin/console app:dbal-list-product

🎯 Architecture Hexagonale

Ce référentiel suit le modèle d'architecture hexagonale. De plus, il est structuré à l'aide de "modules".
Avec cela, nous pouvons voir que la structure actuelle d'un contexte délimité est :
$ tree -L 5 src

src
├── Application
│   └── Product
│   ├── Create
│   │   ├── BusCreateProductCommand.php
│   │   ├── BusCreateProductCommandHandler.php
│   │   ├── DBALCreateProductCommand.php
│   │   └── MockCreateProductCommand.php
│   ├── List
│   │   ├── DBALListProductCommand.php
│   │   └── MockListProductCommand.php
│   └── Search
│   ├── BusSearchProduct.php
│   ├── BusSearchProductQuery.php
│   ├── BusSearchProductResponse.php
│   ├── DBALSearchProductCommand.php
│   └── MockSearchProductCommand.php
├── Domain
│   ├── Bus
│   │   ├── Command
│   │   │   ├── Command.php
│   │   │   ├── CommandBus.php
│   │   │   └── CommandHandler.php
│   │   └── Query
│   │   ├── Query.php
│   │   ├── QueryBus.php
│   │   ├── QueryHandler.php
│   │   └── Response.php
│   ├── Entity
│   │   ├── Product.php
│   │   └── Stock.php
│   ├── Persister
│   │   └── ProductInterface.php
│   └── Repository
│   └── ProductInterface.php
├── Infrastructure
│   ├── Adapter
│   │   ├── DBAL
│   │   │   ├── ProductPersister.php
│   │   │   └── ProductRepository.php
│   │   └── Mock
│   │   ├── ProductPersister.php
│   │   └── ProductRepository.php
│   ├── Bus
│   │   ├── Command
│   │   │   └── InMemoryCommandBus.php
│   │   ├── HandlerBuilder.php
│   │   └── Query
│   │   └── InMemoryQueryBus.php
│   ├── Http
│   │   ├── GetProductActionController.php
│   │   └── SearchProductResponder.php
│   └── Symfony
└── Kernel.php

La couche Application organise les Command et Query par des dossiers Objet/Action
La couche Domain organise les éléments métier
La couche Infrastructure organise les Adapters

🎯 CQRS

Une implementation de type CQRS est mise en oeuvre de manière à séparer les écritures par des Command
des opérations de lecture par des Query.
Ici je n'ai rien inventé de nouveau, une bonne explication de l'implémentation est visible en CQRF with Symfony