Polylith
Search…
Component
Components are the main building blocks in Polylith.
A component is an encapsulated block of code that can be assembled together with a base and a set of other components into services, libraries or tools. Components achieve encapsulation and composability by separating their private implementation from their public interface:
The dark green represents the implementation and the light green represents the interface.
Each component lives in a separate directory under the components directory, and contains a src, test and resources directory:
1
▾ workspace
2
▾ components
3
▾ mycomponent
4
▸ src
5
▸ test
6
▸ resources
Copied!
The src directory often contains at least two namespaces, one for the interface and one for the implementation:
1
▾ src
2
interface.clj
3
core.clj
Copied!
A component's interface is a namespace that exposes a collection of functions for other components or bases to call. Each function in a component’s interface “passes-through” to an equivalent function in its private implementation (the core namespace in this example). This “pass-through” approach enables full code navigation and refactoring, whilst maintaining encapsulation.
Code examples of components can be found in the RealWorld example app and in the Polylith Tool.
Last modified 1mo ago
Copy link