|
| 1 | +--- |
| 2 | +name: polylith-concepts |
| 3 | +description: Provides foundational knowledge about Polylith architecture, including the glossary (bases, components, projects, workspaces), theme layouts, and package manager mapping. Use this when you need to understand Polylith terminology or how the repository is structured conceptually before taking action. |
| 4 | +--- |
| 5 | + |
| 6 | +# Polylith Concepts & Glossary |
| 7 | + |
| 8 | +## Glossary |
| 9 | + |
| 10 | +### Bricks |
| 11 | +The fundamental units of code in Polylith — **components** and **bases**. Bricks are reusable, isolated, and organized under a single **namespace**. |
| 12 | + |
| 13 | +### Components |
| 14 | +Reusable, isolated bricks that implement business logic or capabilities. Components are consumed by bases and by other components, never the other way around. |
| 15 | + |
| 16 | +### Bases |
| 17 | +Bricks that serve as the **entry point** of a deployable application — for example HTTP APIs, CLIs, message-queue consumers, AWS Lambda handlers, GCP Cloud Functions, or scheduled jobs. A base wires together components and exposes the application to its runtime. |
| 18 | + |
| 19 | +### Namespace |
| 20 | +The top-level Python package name under which all bricks live (e.g. `mycompany`). Defined once in `[tool.polylith].namespace` in `workspace.toml`; shared by every brick. |
| 21 | + |
| 22 | +### Workspace |
| 23 | +The root directory of a Polylith repository. Contains `workspace.toml`, the root `pyproject.toml` (which **is** the development project), the `bases/`, `components/`, `projects/`, and `development/` directories, and a single shared lock file. |
| 24 | + |
| 25 | +### Projects |
| 26 | +Lightweight `pyproject.toml` configurations under `projects/<name>/` that **reference bricks** to produce deployable artifacts (Docker images, wheels, Lambda packages). Projects contain no Python source code of their own. |
| 27 | + |
| 28 | +### Development Project |
| 29 | +The root `pyproject.toml` itself — a single, unified Python environment that includes **every** brick and **every** dependency (production and dev). Used for local development, REPL sessions, and notebooks under `development/`. |
| 30 | + |
| 31 | +### Dependencies |
| 32 | +- The **development project** (root `pyproject.toml`) holds **all** dependencies, including dev-only ones. |
| 33 | +- Each **project** under `projects/` holds only its **production** dependencies. |
| 34 | +- With **uv workspaces**, individual projects don't need to pin third-party versions — the root `pyproject.toml` and the shared lock file pin versions centrally. |
| 35 | + |
| 36 | +## Package & Dependency Management mapping |
| 37 | + |
| 38 | +The `poly` CLI is package-manager-agnostic — only the **command prefix** changes. Each SKILL.md repeats the prefix detection rule inline so the agent doesn't need this README to act. The full table: |
| 39 | + |
| 40 | +| Tool | Detection signal | Command prefix | |
| 41 | +|-------------------------------|------------------------------------------------------------------------|-------------------| |
| 42 | +| **uv** (recommended) | `uv.lock` present, or `[tool.uv]` in `pyproject.toml` | `uv run poly …` | |
| 43 | +| **Poetry** | `[tool.poetry]` in `pyproject.toml`, `poetry.lock` | `poetry poly …` (via `poetry-polylith-plugin`) | |
| 44 | +| **PDM** | `[tool.pdm]` in `pyproject.toml`, `pdm.lock` | `pdm run poly …` | |
| 45 | +| **Hatch** | `[tool.hatch]` in `pyproject.toml` | `hatch run poly …`| |
| 46 | +| **Rye** | `requirements.lock` + `[tool.rye]` | `rye run poly …` | |
| 47 | +| **Activated virtualenv** | `$VIRTUAL_ENV` set, or none of the above | `poly …` | |
| 48 | + |
| 49 | +If multiple signals are present, prefer the lock file that exists, then `[tool.<x>]` markers, then plain `poly`. |
| 50 | + |
| 51 | +## Themes |
| 52 | + |
| 53 | +`[tool.polylith.structure].theme` controls the on-disk brick layout: |
| 54 | + |
| 55 | +- **`loose`** (recommended) — flat `<bricks_dir>/<namespace>/<brick>/` directories with tests in a top-level `test/` folder. Used by `python-polylith` itself and by most public examples. |
| 56 | +- **`tdd`** — each brick is its own directory with `src/` and `test/` siblings. |
| 57 | + |
| 58 | +> The CLI default for `poly create workspace --theme` is **`tdd`**. Always pass `--theme loose` explicitly when loose is wanted. |
0 commit comments