Polylith
Search…
Base
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 components (for the same interface) 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:
1
▾ workspace
2
▾ bases
3
▾ mybase
4
▸ src
5
▸ test
6
▸ resources
Copied!
The src directory usually contains two namespaces, one for the API and one for the "thin" implementation:
1
▾ src
2
api.clj
3
core.clj
Copied!
Code examples of bases can be found in the RealWorld example app and in the Polylith Tool.
Last modified 22d ago
Copy link