Clean Architecture, DDD and CQRS using Symfony 6

Overview

Task manager system using Clean Architecture, DDD and CQRS. CI

Environment setup

  1. Install Docker
  2. Clone the project: git clone https://github.com/k0t9i/TaskManager.git
  3. Run docker containers: docker-compose up -d --build
  4. Setup application: make setup. This step installs the composer dependency, generates JWT keys, creates databases, runs migrations, warms up the cache and reloads the supervisor.

Performing checks

  • make test - phpunit tests
  • make code-style - php-cs-fixer checks
  • make static-analysis - psalm checks
  • make check-all - all of the above

Application structure

The application contains 4 nodes:

Each node is a separate bound context, communication between them occurs only through the event bus.

Database

All data is stored on one server in different databases, you can see the database structure via adminer http://127.0.0.1:9080/.

Repository structure

All source code is in app directory:

app
|-- config // Symfony configurations
|   |-- projections // Projection configurations
|   |-- projects // Project configurations
|   |-- shared // Common for all nodes
|   |-- tasks // Task configurations
|   `-- users // User configurations
|-- src // Application code
|   |-- Projections // Projection code
|   |-- Projects // Project code
|   |-- Shared // Common for all nodes
|   |-- Tasks // Task code
|   `-- Users // User code
|-- symfony // Symfony framework
`-- tests // Tests
    |-- Projections
    |-- Projects
    |-- Shared // Common for all nodes
    |-- Tasks
    |-- Users
    `-- bootstrap.php // Common for all nodes

After starting docker containers, local directories are mapped in the same way for all containers, for example for projects:

  • ./app/symfony:/var/www/symfony
  • ./logs/supervisor/projects:/var/log/supervisor
  • ./app/config/shared:/var/www/config/shared
  • ./app/config/projects:/var/www/config/app
  • ./app/src/Shared:/var/www/src/Shared
  • ./app/src/Projects:/var/www/src/Projects
  • ./app/tests/Shared:/var/www/tests/Shared
  • ./app/tests/Projects:/var/www/tests/Projects
  • ./app/tests/bootstrap.php:/var/www/tests/bootstrap.php

Code structure

.
|-- Projects // Code related to a specific bound context
|   |-- Application // Application layer depends only on Domain layer
|   |   |-- Command
|   |   |-- Handler // Command and query handlers
|   |   |-- Query
|   |   |-- Service // Application services
|   |   `-- Subscriber // Domain event subscribers
|   |-- Domain // Domain logic layer does not depend on other layers
|   |   |-- Collection
|   |   |-- Entity // Entities and aggregate roots
|   |   |-- Exception // Domain exceptions
|   |   |-- Repository // Repository interfaces
|   |   `-- ValueObject
|   `-- Infrastructure // Infrastructure layer depends on Domain and Application layers
|       |-- Controller // Symfony controllers
|       |-- Persistence // Migrations, entity mapping in database
|       `-- Repository // Repository realizations
`-- Shared // Common code for all bound contexts
    |-- Application
    |-- Domain
    |-- Infrastructure
    `-- SharedBoundedContext

Buses

Command and query buses are synchronous, implemented via the symfony messenger.

The event bus is asynchronous, implemented via the symfony messenger and RabbitMQ (http://127.0.0.1:15672/). Events are received from RabbitMQ through the Symfony Messenger, which is launched using the supervisor.

You might also like...
Documentation on clean coding and demonstration of studied clean coding principals with PHP.

practice-php-clean-code Documentation on clean coding and demonstration of studied clean coding principals with PHP. The document contained in this re

A research raw data repository for researchers of Arba Minch University built using Codeigniter which follows MVC architecture. The front-end is build using Bootstrap.

Arba Minch University Dataset Repository This system is a research dataset repository for Arba Minch University researchers and is build using Codeign

Small convention based CQRS library for PHP

LiteCQRS for PHP Small naming-convention based CQRS library for PHP (loosely based on LiteCQRS for C#) that relies on the MessageBus, Command, EventSo

PHP Lightweight Message Bus supporting CQRS.
PHP Lightweight Message Bus supporting CQRS.

Prooph Service Bus PHP 7.1+ lightweight message bus supporting CQRS and Micro Services Important This library will receive support until December 31,

Demo project for the API Platform / DDD Workshop

Workshop DDD x API Platform This is a demo project used for the DDD x API Platform Workshop by @chalasr & @mtarld from @coopTilleuls. Checkout git clo

A DDD microservice did in laravel, to test infrastructure

A DDD microservice did in laravel, to test infrastructure

The game is implemented as an example of scalable and high load architecture combined with modern software development practices
The game is implemented as an example of scalable and high load architecture combined with modern software development practices

Crossword game The game is implemented as an example of scalable and high load architecture combined with modern software development practices Exampl

Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Detect flaws in your architecture before they drag you down into the depths of dependency hell ... What it does System Requirements Installation Phive

The Lucid Architecture for Scalable Laravel Applications.
The Lucid Architecture for Scalable Laravel Applications.

Website: https://lucidarch.dev Documentation: https://docs.lucidarch.dev Social: we share updates & interesting content from the web Twitter: @lucid_a

Owner
null
A Symfony project made with DDD, CQRS and Hexagonal Architecture

Symfony Blog DDD + CQRS + Hexagonal Architecture A Symfony blog project made with CQRS, Hexagonal Architecture and DDD Docker integration This project

null 5 Aug 10, 2022
Because every Wedding RSVP website needs to follow DDD, CQRS, Hexagonal Architecture, Event Sourcing, and be deployed on Lambda.

Our Wedding Website Because every Wedding RSVP website needs to follow DDD, CQRS, Hexagonal Architecture, Event Sourcing, and be deployed on Lambda. ?

Edd Mann 3 Aug 21, 2022
Ecotone Framework is Service Bus Implementation. It enables message driven architecture and DDD, CQRS, Event Sourcing PHP

This is Read Only Repository To contribute make use of Ecotone-Dev repository. Ecotone is Service Bus Implementation, which enables message driven arc

EcotoneFramework 308 Dec 29, 2022
🐘 🎯 Hexagonal Architecture, DDD & CQRS in PHP

?? ?? Hexagonal Architecture, DDD & CQRS in PHP Example of a PHP application using Domain-Driven Design (DDD) and Command Query Responsibility Segrega

CodelyTV 2.5k Jan 6, 2023
POC d'un projet Clean Architecture + DDD

Proof Of Concept - Clean Architecture & DDD Installation Dans un premier temps, cloner le repository : git clone https://github.com/TBoileau/rse cd rs

Thomas Boileau 11 Sep 3, 2022
Enraged Xenomorph - DDD/CQRS Symfony Application Boilerplate

Enraged Xenomorph - DDD/CQRS Symfony Application Boilerplate This project is very opinionated attempt to compile a bit of experience, few good practic

Gniewomir Świechowski 1 Jan 10, 2022
Orkestra is a library of infrastructure and architecture helpers for creating CQRS applications

Orkestra Orkestra is an opinionated framework with a plethora of recommendations on architectural design that we use internally at Morebec to develop

Morébec 2 Aug 18, 2021
FFCMS 3 version core MVC architecture. Build-on use with ffcms main architecture builder.

FFCMS 3 version core MVC architecture. Build-on use with ffcms main architecture builder.

FFCMS 0 Feb 25, 2022
Test and enforce architectural rules in your Laravel applications. Keep your app's architecture clean and consistent!

Laravel Arkitect Laravel Arkitect lets you test and enforce your architectural rules in your Laravel applications, and it's a PHPArkitect wrapper for

SMorteza Ebadi 55 Dec 17, 2022
my personal example of Laravel clean architecture

what is this repo about Clean Architect Laravel ###run we assume docker desktop is up and running open up a terminal cd project directory run "cp .env

Sadegh Salari 37 Dec 23, 2022