---
title: "One folder, one bounded context, in each language"
description: The folder, what each language allows, and which changes most.
source: context.dh.md
---
<!-- Made by dh llm from the source; nobody edits this file. -->

# One folder, one bounded context, in each language

**Yes, one bounded context can be one folder with its own project, in all four languages. Each was built and run with 2 to 3 contexts, a kernel and tests inside the folder, then scaled to 25 or more.** You meant project, and that is what was built: a standard project, not one library per layer.

## The folder, as files

```filetree
contexts/
  orders/
    context.yaml  # id, owner, needs, uses
    contract/
      v1/  # what others may use
    src/
      register  # the one function the kernel calls
      api/
        v1/  # URLs, controllers, request and response models
      mcp/  # MCP tools
      domain/  # model, service, ports
      data/  # data model, repository, migrations
    policies.yaml  # auth policies
    config/  # its own settings
    flags.yaml  # required
    segments.yaml  # optional
    events.yaml  # optional
    observability/  # contract, alerts, runbooks
    docs/  # its own docs
    tests/
      unit/
      integration/
      sit/
      smoke/
kernel/  # finds and wires every context
dependency.yaml  # one per service
```

## What each language allows

| Language | What a context is | Files outside the folder when you add one | What blocks another context's internals |
|---|---|---|---|
| Go | one package tree, one Go module | 1 generated wiring file | the compiler |
| Bun | one workspace package and a contract package | 1: `bun.lock` | TypeScript; our checker for relative paths |
| .NET | a project, a contract project, a test project | 0, with no lock file in the host | the compiler |
| Flutter | three packages: contract, src, tests | 0 tracked | **only our checker** |

All MEASURED.

## Can tests, docs and observability live inside?

| Language | Tests inside run | Planted failing test fails | Test files in the shipped build |
|---|---|---|---|
| Go | yes | yes | 0 |
| Bun | yes, with SIT | yes | 0 |
| .NET | yes | yes | 0 |
| Flutter | yes | yes | 0 |

- Docs and runbook files were kept out of every shipped build. MEASURED
- The obs tool ran on a context's own folder in Bun and Flutter. MEASURED. Go and .NET: NOT TESTED.
- The docs framework was not run on these folders: it is not finished. NOT TESTED
- SIT ran only in Bun. Flutter device tests were NOT TESTED.

## Guarding the layers inside one project
The compiler no longer does it. A check does, and each was proven with a planted breach. MEASURED

| Language | Check | When it fails |
|---|---|---|
| Go | depguard and our generator | lint, generate |
| Bun | our 150-line boundary checker | check |
| .NET | our analyzer | build |
| Flutter | our boundary checker | check |

## Speed with 25 contexts

| Language | From clean | After one edit | One context's tests |
|---|---|---|---|
| Go | 43 s | 2.2 to 4.3 s | 0.75 s |
| Bun | 5.5 s (type check) | 3.7 s | 0.21 s |
| .NET, the app | 77 s | 10 s | 2.8 s |
| .NET, with every test project | 161 s | 11.7 s | 2.8 s |
| Flutter, 27 contexts | 43 s (generate, analyze) | 8.3 s | 6.8 s |

MEASURED on a busy 32-core box. Compare within a language, not between languages.

## Does this change .NET the most? Yes. Is it possible? Yes.

| Rank | Language | Template files that move | What really changes |
|---|---|---|---|
| 1, most | .NET | 64 of 428 (API template) | the four layer projects and the solution file go; the shared DbContext; a new layer check |
| 2 | Flutter | 0 of 559 (template has no features); 180 in alcohol.neon | packages per context; two generated files; a boundary check |
| 3 | Bun | 42 of 409 (consumer template) | packages per context; 6 root configs; a boundary check |
| 4, least | Go | 4 of 248 | about 10 config files; one generated file per context |

- Counts: MEASURED, except Flutter's 0, which is REASONED. The order is REASONED from structure, because the templates differ in size.

- One page each: [Go](go.md), [Bun](bun.md), [.NET](dotnet.md), [Flutter](flutter.md).

## What each language cannot do cleanly
- **Go:** no `src/` folder and no module per context. Two new libraries on neighbouring lines conflict in `go.mod`.
- **Bun:** two new contexts conflict in `bun.lock`, one hunk, fixed by `bun install`. `merge=union` is unsafe there.
- **.NET:** a lock file in the host conflicts on every new context. Keep none there, as the template does today.
- **Flutter:** one shared package map, so an undeclared import compiles. Stale generated files break every command until `task gen`. Two new libraries can conflict in `pubspec.lock`.
- All of these lock-file clashes are git conflicts, so none breaks main silently.
