Bases are the building blocks that exposes a public API to the outside world.

A base is an encapsulated block of code that can be assembled together with a set of components into services, libraries or tools. Bases achieve encapsulation and composability by separating their private implementation from their public API:

The dark blue represents the implementation and the light blue represents the API.

A base has a "thin" implementation which delegates to components where the business logic is implemented.

A base has one role and that is to be a bridge between the outside world and the logic that performs the "real work", our components. Bases don't perform any business logic themselves, they only delegate to components.

As a result, we can easily add more functionality to a base by either re-using existing components or by adding new ones. The components are accessed through their interfaces, which allow us to use different versions of a component in different projects, e.g. development, test, stage and production, which makes Polylith an incredibly flexible way of organising code.

Each base lives in a separate directory under the bases directory, where it has a src, test and resources directory:

▾ workspace
▾ bases
▾ mybase
▸ src
▸ test
▸ resources

The src directory usually contains two namespaces, one for the API and one for the "thin" implementation:

▾ src

Code examples of bases can be found in the RealWorld example app and in the Polylith Tool.