Skip to content

2. Discovery

Chabardes edited this page Jun 9, 2022 · 8 revisions

Current state of the dojo

Features

Some basic features have already been implemented, try them out !

Make the following graphQL requests

  1. create a hero
  2. create a level 1 dragon
  3. make the hero attack the dragon
  4. get the hero data, he should have gained xp and a loot.

Code

Take a look around in the docs and src directory, we have 4 modules following the principles described in the DDH Notion page. Each modules is split into core, interface and infrastructure:

  • core contains the domain entities and the applications (queries and commands) acting on them. This is where all the business logic lives.
  • interface contains the various ways we can call the core applications. It can be REST controllers, GraphQL resolvers, AMQP consumers, or presenters to be called from other modules.
  • infrastructure contains the technical implementations of the methods called by our core applications, it is the glue between the applications and the outside world: databases, third-party services, AMQP publishers...

Ports and Adapters

One of the main features of Libeo's backend architecture is the use of the Ports and Adapters pattern. In our implementation of the pattern :

  • Ports are defined in the core, around our domain entities. And implemented in the infrastructure. This is the inversion of control (IoC): The outer layers (interface and infrastructure) depends on the inner layer (core) and never the contrary.
  • They are mostly CRUD (Create Read Update Delete) operations on entities.
  • Ports are abstract methods of an abstract class. Usually the class will be named ${entity}Ports, and the methods should describe what is done with the entity getById, create, etc...
  • Adapters are NestJS Providers implementing these abstract classes : they have the @Injectable decorator, which means NestJS will be able to inject them. Read more about NestJS dependency injection.

Here are the most common ports you will use. But you can also write more specific ports for your entities.

Clone this wiki locally