garage44.eu/jeroen/cartopolis

logclone: git clone https://garage44.eu/jeroen/cartopolis.git

.. /docs/adr/015-workspace-module-boundaries.md

raw

ADR-015: Workspace Module and Crate Boundaries


Metadata:


Context

Problem: Networking (ADR-008/009), coordinates (ADR-006), and protocol types outgrow a single main.rs + flat src/. Without crate boundaries, sim and client duplicate logic or create import cycles.

Requirements:

Decision

The Cargo workspace has four members (Cargo.toml), with strict dependency direction — both binaries depend on cartopolis_core, never on each other:

A fifth crate cartopolis_geo (geo/place lookups) is planned, not yet built (ADR-028).

Rust ecosystem: root [workspace.dependencies] pins aligned versions of tokio, serde, tracing, thiserror, glam, etc. Protocol/codec hot paths could later carry criterion benches in cartopolis_core.

Rationale

Primary Reasoning:

  1. Compile times: Smaller crates rebuild faster during client-only iteration.
  2. Correct layering: Prevents accidental renderer imports in the sim.
  3. Matches ADR-007: Two binaries naturally map to two crate roots + shared lib.

Alternatives Considered:

AlternativeProsConsRejected Because
Monorepo single crateSimplest nowBecomes tangledWill hurt at ADR-008
Many micro-cratesMax isolationOverheadToo many for current size
Feature flags onlyOne packageStill couples depsWeak boundary vs crates

Consequences

Positive:

Negative:

Related