Architecture
The layers and their dependency rules, the ports, how the map adapter works and how to add an adapter of your own.
This page is built from ARCHITECTURE.md in the repository, which is where it is edited.
At a glance
The document is long, so the site gives each section its own page. A section that is still long is cut into numbered parts.
- Layers and dependency rules: Which package may import which, and what each layer must not do.
- Building the SDK packages: How the six SDK packages are built, and in what order.
- Ports: The interfaces the app depends on, each with a real adapter, a fake and a contract suite.
- The map adapter: MapLibre GL JS is the only map engine, and the ui never imports it.
- Data layers: How data layers are defined, loaded and shown on the map.
- Drawing: How shapes are drawn, edited, imported, exported and shared.
- Adding an adapter: An adapter reaches the ui through the services.
- How tests substitute services: Unit tests wrap components in ServicesProvider with fakes.
- The reference host's pages: The routes of the reference site.
About this document
MapCairn separates what the app does from what it runs on. The interface and the pure logic depend on small interfaces (ports). Concrete code that touches a map engine, a browser service or a network service (adapters) lives in one place each and is wired together once, in the composition root.
An arrow means "imports". Each box is a package under packages/, so core is packages/core. core holds the ports (types only), the pure logic, the fakes and the contract suites, and imports no other package, as do theme (the tokens and their contrast maths) and react (generic hooks). Only the host imports the MapLibre adapter, and no SDK package imports the host. The host also imports core and theme directly, which the picture leaves out.