Short answer

Building blocks represent your source code. Your building blocks should be an abstraction of your source code.

The problem: There can be several possibilities how you can aggregate source code constructs to building blocks. I’m afraid you have to read the longer answer below…

Longer Answer

Mapping code to building blocks is a challenge, which we like to demonstrate by a small example, see the following figure. In its center you see a directory listing of (Python) source code files making up the system. Both on the left and the right side of the images you find different, but perfectly valid building block structures for these files.

Different mappings of code to building blocks

Both versions were created with different abstraction criteria, both are possible.

In reality, you should organize your source code along your abstraction criteria. Some technologies or frameworks impose certain directory structures that can suggest completely different building block structures than those intended by the architects.

Especially layer structures (view, application, infrastructure) found in some technologies can obfuscate any business- or domain structures that could be useful in understanding the overall organization of the system.

Keep the mapping of source code to building blocks close to either the:

  • directory structure of your source code files
  • modularization constructs of your programming language. In Java, for example, this could be packages.

Every single piece of source code should be contained in one of your level-1 building blocks.