---
title: Engineering Standards
summary: Practical coding, API, contract, naming, formatting, and analysis rules and how automated checks enforce them.
owners:
  - architecture-enabling-team
badges:
  - content: Standards
    backgroundColor: teal
    textColor: teal
---

Apply these standards at the boundary where a change is made. Automated checks catch many violations, but passing CI does not replace clear ownership or compatible contracts.

<Admonition type="warning" title="Non-negotiable">
	Keep business logic inside its owning service, preserve public contract compatibility, propagate
	cancellation through asynchronous work, and never commit credentials. Do not introduce MediatR;
	request handling uses the existing source-generated mediator.
</Admonition>

## Rules and enforcement

| Area                | Follow                                                                                                                                                                  | How it is enforced                                                |
| :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------- |
| Service design      | Use Domain-Driven Design and Vertical Slice Architecture. Services own their business rules and persistence; do not add direct service-to-service project dependencies. | Architecture tests and review                                     |
| C#                  | Prefer nullable-aware, file-scoped code. Seal endpoints, handlers, DbContexts, integration events, and test classes by default. Keep warnings actionable.               | Compiler warnings as errors, Roslyn analyzers, architecture tests |
| Async work          | Use `async`/`await` end to end and pass `CancellationToken` through every asynchronous boundary.                                                                        | Analyzers and review                                              |
| Requests and APIs   | Keep endpoint handlers focused; use explicit API versions and apply authorization at the endpoint boundary. Validate input and return consistent errors.                | Build checks, tests, and review                                   |
| Messaging contracts | Name events `[Action][Entity]IntegrationEvent`. Publish only fields consumers need; preserve message identity and ownership metadata.                                   | Pact contract tests and review                                    |
| Protocol Buffers    | Lint schemas, check backward compatibility, and regenerate the schema lock after an intentional change.                                                                 | Buf checks and consumer coordination                              |
| PostgreSQL          | Use `snake_case` for identifiers, columns, tables, and raw SQL.                                                                                                         | Review and database tests                                         |
| Frontend            | Use Bun, keep workspace imports within the allowed dependency direction, avoid `any`, and provide accessible interactions.                                              | Boundary checks, TypeScript checks, ESLint                        |
| Formatting          | Apply the repository formatter to changed files; do not suppress a formatter or analyzer finding globally.                                                              | Git hooks and CI                                                  |

## Run the relevant checks

- **Backend:** `mise run build`, then the relevant test task from [[doc|development/005-testing]].
- **Frontend:** run `bun run boundaries`, `bun run check-types`, and `bun run lint` in the frontend workspace.
- **Protocol Buffers:** after installing Buf with `mise run setup:buf`, run `buf lint`, `buf breaking --against lock.binpb`, and `buf build -o lock.binpb` from the schema workspace. Commit the schema and refreshed lock together.
- **Formatting:** use `mise run format:cs`, `mise run format:fe`, or `mise run format:docs` for the changed area.

CI repeats the applicable format, analyzer, architecture, boundary, contract, and test checks. See [[doc|development/008-testing-matrix]] for which suites apply and [[doc|development/006-pull-request-process]] for merge requirements.
