Skip to content

Monorepo ​

Guide draft monorepo pnpm turbo build architecture

How the repository is split into apps and packages, how pnpm, the catalog and Turborepo tie them together, and where build outputs go; use before adding a package, a dependency or a build step.

Resource and sources

Since v5 the repository is a pnpm workspace driven by Turborepo. The v4 flat layout (lib/, api/, mod/, root express.js) is gone; see Migrating a v4 fork.

Layout ​

PackageDirectoryRole
@geolytix/xyz-appapps/xyzXYZ API, router and server.
@geolytix/mappapps/mappMAPP library; also the npm package.
@geolytix/mapp-uiapps/uiMAPP.UI library.
@geolytix/xyz-auth-appapps/authTemplate for a custom authentication host.
@geolytix/xyz-saml-appapps/samlXYZ with the optional SAML routes.
@geolytix/xyz-devdbpackages/devdbIn-memory PGlite PostGIS database for tests and examples.
@geolytix/xyz-testhostpackages/testhostLocal XYZ host with the devdb, for browser tests and test views.

Other root directories:

  • public/ holds the views, icons, dictionaries, css and the built bundles served by XYZ.
  • utils/ holds release, deploy and knowledge scripts, and the knowledge portal in utils/knowledge/site/.
  • varlock/ holds environment schemas, eg. the vanilla schema the XYZ tests run with.
  • knowledge/ is this bundle.

pnpm workspace and catalog ​

pnpm-workspace.yaml lists the packages. Every third-party version is declared once in its catalog: section; a manifest refers to it as "catalog:". Local packages refer to each other as "workspace:*".[1]

  • Add or bump a dependency in the catalog, then reference it with catalog:.
  • allowBuilds lists the packages allowed to run install scripts.
  • Use the pnpm version in the root packageManager field.[2]

Dependencies ​

Each package declares the dependencies it uses; check its package.json rather than a list here.

  • XYZ (apps/xyz) needs Node.js 22 or later. Its runtime dependencies are express, pg, bcrypt, jsonwebtoken and varlock. The AWS SDK, resend and the OpenTelemetry exporters are optionalDependencies, imported dynamically only when the feature is configured.[3]
  • @node-saml/node-saml is a dependency of apps/saml only, so a deployment without SAML does not install it.
  • MAPP and MAPP.UI have no runtime dependencies. ol is a peer dependency of the npm package, loaded as a global. µhtml is vendored as source in apps/mapp/lib/utils/uhtml.mjs, not installed.
  • The devdb uses PGlite with PostGIS; the testhost adds express and vt-pbf.

Development dependencies are declared at the root or in the app that uses them:

ToolDeclared inPurpose
turborootRuns tasks across the packages.
BiomerootLint and format (pnpm lint).
Vitemapp, uiBuilds the library bundles and css.
Vitest, Playwrightroot, appsUnit and browser tests; see TESTING.md.
publintmappChecks the npm package.
VitePress, markdown-it, yamlrootKnowledge portal and checks.

Turborepo ​

Run tasks from the root; turbo.json defines build, dev, test, test:coverage, lint and workspace:cache.[4]

  • build depends on ^build. The mapp and ui turbo.json files declare their outputs in public/ and dist/, so turbo can restore them from cache.
  • test depends on transit, which only follows the dependency graph: a change in a dependency invalidates the test cache without running builds.
  • A cached run prints FULL TURBO and no test counts. Use --force to run the tests again.
  • Each app has its own vitest.config.mjs; there is none at the root.
  • Filter by package name, eg. pnpm build --filter=@geolytix/mapp.

The root scripts are the entry points: pnpm dev, pnpm build, pnpm test, pnpm test:xyz, pnpm test:mapp, pnpm test:ui, pnpm testview, and the knowledge:* scripts. See DEVELOPING.md and TESTING.md.

Build outputs ​

BuildOutput
@geolytix/mappapps/mapp/dist/mapp.js, mapp.css (npm package), copied to public/js/lib and public/css
@geolytix/mapp-uipublic/js/lib/ui.js, public/css/ui.css
XYZnone; it runs from source
  • Both library builds write into public/js/lib without emptying it, so one build keeps the other's bundle. The mapp build empties dist first.
  • The bundles are gitignored. The release workflow commits them to main and the release tag only, so a release checkout is deployable without a build.[5] Don't commit them on a development branch.
  • .vercelignore excludes the library sources, the XYZ tests, devdb and testhost from a Vercel deployment. A deployment of main or a release tag serves the committed bundles; a development branch must be built first.[6] See Release builds for the release workflow.

Versions ​

The XYZ version lives in the root package.json (with a v), the root README, apps/mapp/lib/mapp.mjs and apps/mapp/package.json. The other app manifests have no version. Change it with pnpm bump:patch|minor|major; utils/check-version.js checks that all four match.[7] See RELEASING.md.


  1. pnpm-workspace.yaml ↩︎

  2. package.json ↩︎

  3. apps/xyz/package.json ↩︎

  4. turbo.json ↩︎

  5. .gitignore ↩︎

  6. .vercelignore ↩︎

  7. utils/bump-version.js ↩︎

XYZ v5.1.0. Generated from knowledge/ at dd7a6fa27736502733499c1bf485f15659b10338. Concepts marked draft are not reviewed.