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:
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
▾ workspace▾ bases▾ mybase▸ src▸ test▸ resources
src directory usually contains two namespaces, one for the API and one for the "thin" implementation: