> For the complete documentation index, see [llms.txt](https://polylith.gitbook.io/polylith/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://polylith.gitbook.io/polylith/architecture/2.2.-base.md).

# Base

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

<figure><img src="/files/PMKCQT2jzRKNUOpIhMJ7" alt=""><figcaption></figcaption></figure>

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:

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

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

```
▾ src
    api.clj
    core.clj
```

Code examples of bases can be found in the [RealWorld example app](https://github.com/furkan3ayraktar/clojure-polylith-realworld-example-app) and in the [Polylith Tool](https://cljdoc.org/d/polylith/clj-poly/CURRENT/doc/readme).
