GraphQL

Write an awesome doc for GraphQL. A very nice an practical one extracted from GraphQL official documentation.

View on GitHub

Intro

So why knowing the concept of DDD is important? because:

[!CAUTION]

# To simplify things let’s just think that we only have an API. So for the time being let’s say application = our backend.

Domain

[!NOTE]

By “specific area”, or “certain thematic area” we meant to say coherent and atomic.

Palpable example in TS

A simple invoice billing domain files & folders.
An example of directories and files with DDD in mind in TS

The cost of DDD

Different types of domains

  • DDD is very elastic.
  • DDD allows you to use it in specified parts of your solution.
  • DDD + simple CRUD + external modules is OK.
  • From a strategic perspective we usually group them by their complexity and importance for a company.
Categories
Core
Generic
Supporting
  • AKA core domains.
  • What differentiates a company from another.
  • The innovation that a company introduces to gain an advantage over its competitors (company's competitive advantage).
  • If it is simple to implement is also simple to copy.
  • Not necessarily technical. E.g. an ECommerce app for a carpenter.
  • Change often (where you need to not stagnate).
  • Core features of the API.
  • Will be the core purpose of your application.
  • The problem your software solution wants to solve.
  • Business activities that all companies do in the same way.
  • Ready-to-use implementations are widely available.
  • No real need for innovation or proprietary solutions here, e.g. auth.
  • Contains logic which from a strategic perspective is not important as other core domain.
  • Necessary functions that enable the core domain to operate effectively.
  • No real competitive advantage or business differentiation.
  • The main criterion for distinguishing them: they're simple to implement.
  • Usually CRUD-based systems.

Complexity of different types of domains

Core is the most complex, then we have generic ones that are less complex and most of times outsourced, lastly we have supporting domains which are the simplest ones

Identifying boundaries of domains

Separate core domains from the rest, ensuring proper design decisions. To do so we need meetings with domain experts and together try to understand obtained knowledge about the system.

Some examples

Vet helping system

Client says something like this:

I have a lot of patients nowadays and still, I'm using a notebook to schedule appointments and classic paper patients' documentations. It's hard for me to work with patients and at the same time scheduling visits or exporting patients' diagnoses for their owners. I can't afford a secretary in the long run so I've decided to implement a schedule and diagnosis system which won't need my attention to book patients or share the diagnosis with owners.
The custom notation of the entire flow of our vet helping system with authenticated users.
  • The most important thing to you is to automate the registration process or provide a mechanism for storing a patient's diagnosis and data.
    • We don't have to use DDD for everything; authentication module is a normal module.
    • Core domain
      • Scheduling an appointment, canceling and list our appointments.
      • Attach consultation/diagnosis results during an appointment to registered pets and allow to read diagnosis for pets' owners.
  • Less emphasis on the invoice system, which can be e.g. bought from an external company.
    Or you can implement it on your own, but as simple as it's possible. The invoice module is a generic domain.
  • Implement a module responsible for calculating health level of a pet. A number between 0 to 10.Calculated according to the pet's blood tests results, diagnosis, and subjective vet mark.
    A cool feature to show that information or use it by the vet to make some decisions but it's not important business logic. This is a supportive domain.

Project structure for this example.