Baseleg Docs

Package boundaries

Baseleg is a modular monolith with an explicit dependency direction.

Allowed dependencies

  • apps/*packages/application/*, packages/ui, and selected packages/domain/* (types/value objects only)
  • packages/application/*packages/domain/*, packages/shared/*
  • packages/infrastructure/*packages/domain/*, packages/shared/*
  • packages/domain/*packages/shared/*
  • packages/uipackages/shared/*

Forbidden dependencies

  • Domain must not import infrastructure.
  • UI must not import infrastructure.
  • Application must not import infrastructure implementations directly (use ports + wiring).
  • Astro pages/routes must not import Drizzle schema or repository implementations.
  • Shared must not depend on domain/application/infrastructure/ui.

Good imports

// apps/web: call a use case
import { createPerson } from '@baseleg/application-people';
// application: use domain + shared
import type { PersonId } from '@baseleg/domain-people';
import { Result } from '@baseleg/shared-result';
// infrastructure: implement a repository using domain types
import type { PersonId } from '@baseleg/domain-people';

Bad imports

// domain must not import infrastructure
import { db } from '@baseleg/infrastructure-db';
// UI/routes must not talk directly to DB/schema
import { peopleTable } from '../../../db/schema';
// UI must not import repository implementations
import { PeopleRepositoryD1 } from '@baseleg/infrastructure-repositories';