Giter Site home page Giter Site logo

ddd-playground's Introduction

DDD Playground

For a more acurated DDD, CQRS and Event Sourcing implementation see here

Wallet API in Symfony following DDD (Domain Driver Design).

Examples in the repo

  • User authentication based in JWT
  • UUID as binary to improve the performance and create a nightmare for the dba.
  • Automated tasks with ant.
  • Dev and CI environments in Docker. Boosting build speed with docker cache layers in pipeline. Orchestrating with Docker Compose.
  • An example of table inheritance and discriminator strategy
  • How to deal with EAV (Entity-Attribute-Value) with Json data type.
  • Code structured in layers as appears in DDD in php book.
  • Test for api in behat accessing via web server (Acceptance tests).
  • Integration test with Lakion api test case and Alice for fixtures and how to integrate it with behat.
  • Command Bus implementation
  • DomainEvents
  • Events to RabbitMQ
  • Events stored in ElasticSearch and Kibana for reading in :5601 ย 

The folder structure

src
  \
   |\ Application     `Contains the Use Cases of the domain system and the Data Transfer Objects`
   |
   |\ Domain          `The system business logic layer`
   |
   |\ Infrastructure  `Its the implementation of the system outside the model. I.E: Persistence, serialization, etc`
   |
    \ UI              `User Interface. This use to be inside the Infrastructure layer, but I don't like it.`

The tests

The tests follow the same structure and the phpunit tests are tagged with group tags: unit or functional.

The aceptation tests are inside the test UI layer and attack the application from outside using Guzzle.

The Environment setup

The environment is in PHP7.1 and the development containers are on etc/infrastructure/dev/docker-compose.yml

Up environment with: docker-compose -f etc/infrastructure/dev/docker-compose.yml up -d

Install dependencies: docker-compose -f etc/infrastructure/dev/docker-compose.yml exec fpm sh -lc 'composer install'

Setup database, etc with : docker-compose -f etc/infrastructure/dev/docker-compose.yml exec fpm sh -lc 'ant build'

Start async listeners: docker-compose -f etc/infrastructure/dev/docker-compose.yml exec fpm sh -lc 'bin/console rabbitmq:multiple-consumer events'

  • Rabbit Management: :15672 Rabbit

  • Kibana: :5601 Kibana

CI/CD

Follow the Jenkinsfile or the gitlab-ci.yml file, it's clear enough and contains a simply workflow to:

  • build the isolated environment
  • docker-compose -p to avoid parallel jobs conflicts
  • provision the environment
  • run the test
  • extract reports
  • Build and store the artifacts (Docker images)
  • Clean the environment

ddd-playground's People

Contributors

1ma avatar ismael-benitez avatar jorge07 avatar mablae avatar pascal08 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ddd-playground's Issues

User model uses ArrayCollection

I noticed that User domain model has aggregation with Doctrine Array Collections, does not it violates DDD principles? We should create interface for collection in domain common bundle and the adapter for ArrayCollection in infrastrucutre layer, should not we?

{version} not used/validated

When try to call any API Endpoint that requires {version} it is not being validated and in fact you could use any value.

I.e GET /api/{version}/user/fc03e3ec-c3a1-11e6-a4a6-cec0c932ce01.json (empty/null value)
image

but also: GET /api/wrong_version/user/fc03e3ec-c3a1-11e6-a4a6-cec0c932ce01.json
image

No such file or directory

docker-compose -f etc/infrastructure/dev/docker-compose.yml exec fpm bin/console rabbitmq:multiple-consumer events
ERROR: .IOError: [Errno 2] No such file or directory: u'.\\etc/infrastructure/dev/docker-compose.yml'

[Identifier] serializer group not being used for User

The [Identifier] serializer group not being used for User.
In fact AggregatedRootId is also not using it:

Leos\Domain\Common\ValueObject\AggregateRootId:
    properties:
        uuid:
            expose: true
            groups: [Basic]

It is being used by the transition id, but the user is not using that ;)

User's Auth Roles not persisted

The User's Auth Roles are not persisted.
To fix that, we should add:
Infrastructure/SecurityBundle/Resources/config/persistence/ValueObject/AuthUser.orm.yml

    roles:
      type: json_array
      nullable: false

The UI/Controller tests check for an array in the role attribute response but do not check the content.
The Domain/User/testGetters doesn't test it at all, but testing it there will always pass, as it is set in the User entity.
Maybe it could be tested on the Infrastructure/Persistence level?

Empty response upon user registration

The auth/register (in the SecurityController) redirects and returns the response from get_user (in the UserController) [- Shouldn't this be decoupled?]

But the response is empty:
image

Nelmio's api/doc is inaccessible without authentication

Authentication is required to view Nelmio's Documentation @ api/doc:

{
code: 401,
message: "JWT Token not found"
}

Even though a api:doc:dump is being made by the build.xml it would be a good idea to allow access to the the docs without authentication.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.