1---2name: forze-skills3description: Build backend services with Forze — specs, deps modules, handlers, governed aggregates, FastAPI routes, identity and tenancy, encryption, messaging, realtime, durable execution, analytics, and deterministic simulation testing. Use when writing or wiring an application that depends on forze and its integration packages.4---56# Forze78Forze is a Python framework for Domain-Driven Design and Hexagonal Architecture in backend9services. This skill is a routing index: the reference files under `references/` hold the actual10material, and you read the ones a task needs.1112## The mental model, in four sentences1314Your application declares **logical specs** — a `DocumentSpec`, a `QueueSpec`, a `StorageSpec` —15that name a resource without naming any physical thing. **Deps modules** map those names to real16backends (a Postgres table, an SQS queue, an S3 bucket) at wiring time. **Handlers** receive an17`ExecutionContext` and reach infrastructure only through ports resolved from it. The **runtime**18composes the registries, freezes them, and runs operations through the pipeline.1920Everything else is a consequence of that split. If a handler mentions a table name, a bucket, or21an adapter import, something has gone wrong — and most anti-patterns in these references are a22version of that one mistake.2324## Read the bundle, not one file2526**Most tasks need three to five references, and reading one is usually wrong.** These are27procedures, not independent rules: an aggregate declared without its backend config is an app28that does not start, and a handler written without the execution context is a handler that29reaches for the wrong things. Start from the table below and read the whole row.3031| I want to… | Read, in order |32|---|---|33| Bootstrap a new service | `architecture` → `spec-naming-and-routes` → `deps-resolution` → `runtime-lifecycle` |34| Add a governed aggregate | `aggregate-models` → `document-spec` → `aggregate-kit` → `spec-to-backend-config` → `testing-with-mock` |35| Write a custom handler | `execution-context` → `handlers` → `query-dsl` |36| Expose it over HTTP | `fastapi-setup` → `fastapi-generated-routes` → `fastapi-identity` |37| Encrypt a field | `field-encryption` → `kms-backends` → `spec-to-backend-config` |38| Simulate my service under faults | `dst-simulation` → `dst-invariants` → `testing-with-mock` |3940If the task is not one of these, pick from the index below — but check whether it decomposes into41a row first.4243## Index4445### Foundations4647| Reference | Covers |48|---|---|49| [architecture](references/architecture.md) | Layered architecture, contracts and adapters, what may import what |50| [execution-context](references/execution-context.md) | `ExecutionContext`, the ports on it, transactions, identity and tenancy in a handler |51| [handlers](references/handlers.md) | Handler patterns for the common operation shapes, and the gotchas |5253### Specs, deps and wiring5455| Reference | Covers |56|---|---|57| [spec-naming-and-routes](references/spec-naming-and-routes.md) | `StrEnum` spec names, transaction routes, why one name is one route |58| [spec-to-backend-config](references/spec-to-backend-config.md) | Mapping a logical name to Postgres, Mongo, Redis, storage, queue and workflow config |59| [deps-resolution](references/deps-resolution.md) | Plain vs routed deps, how handlers resolve ports, merge conflicts |60| [deps-custom-module](references/deps-custom-module.md) | Writing your own `DepsModule` and `DepKey` for a private integration |61| [runtime-lifecycle](references/runtime-lifecycle.md) | `build_runtime`, lifecycle steps, the spec inventory |62| [operation-composition](references/operation-composition.md) | Operation registries, pipeline stages, hooks, mapping steps |63| [testing-with-mock](references/testing-with-mock.md) | `forze_mock` in tests — every port in memory, no containers |6465### Domain6667| Reference | Covers |68|---|---|69| [aggregate-models](references/aggregate-models.md) | The four models, base fields, mixins, update validators |70| [document-spec](references/document-spec.md) | `DocumentSpec` / `SearchSpec`, schema alignment, composition DTOs |71| [aggregate-kit](references/aggregate-kit.md) | `AggregateKit` — one declaration for a governed vertical slice |7273### Reading and writing data7475| Reference | Covers |76|---|---|77| [document-facade](references/document-facade.md) | `DocumentFacade`, raw ports, adapter boundaries, cache-aware reads |78| [query-dsl](references/query-dsl.md) | Filters, sorts, projections, cursor paging |79| [search](references/search.md) | `SearchFacade`, hub and federated search, rebuilding an index |8081### Events, messaging and realtime8283| Reference | Covers |84|---|---|85| [messaging-queues](references/messaging-queues.md) | Queue contracts, SQS and RabbitMQ wiring |86| [messaging-pubsub-streams](references/messaging-pubsub-streams.md) | Pub/sub, streams, consumer-group discipline, shutdown |87| [outbox-notifications](references/outbox-notifications.md) | Transactional notifications — stage in the transaction, relay after commit |88| [realtime-catalog](references/realtime-catalog.md) | Declaring an event catalog and publishing from a handler |89| [realtime-transports](references/realtime-transports.md) | Socket.IO, SSE and WebSocket behind one wire protocol; offline mailbox |9091### Durable execution9293| Reference | Covers |94|---|---|95| [temporal](references/temporal.md) | `DurableWorkflowSpec`, Temporal deps, schedules, worker context |96| [inngest](references/inngest.md) | Inngest events, functions, steps, serving; the self-hosted Postgres runner |9798### Interface99100| Reference | Covers |101|---|---|102| [fastapi-setup](references/fastapi-setup.md) | Context dependency, lifespan, middleware, error handlers |103| [fastapi-generated-routes](references/fastapi-generated-routes.md) | `attach_*_routes`, hand-written routes, deadline headers, MCP projection |104| [fastapi-identity](references/fastapi-identity.md) | Binding identity at the boundary, cookie mode, principal eligibility |105106### Identity, tenancy and secrets107108| Reference | Covers |109|---|---|110| [authn](references/authn.md) | Boundary binding, the verify-then-resolve pipeline, authn deps, authz |111| [oidc](references/oidc.md) | External IdPs, token verifiers, principal resolution |112| [tenancy](references/tenancy.md) | Tenant identity, routed clients, isolation tiers, the admin plane, provisioning |113| [secrets](references/secrets.md) | Secret-backed configuration and its backends |114115### Encryption116117| Reference | Covers |118|---|---|119| [field-encryption](references/field-encryption.md) | `FieldEncryption`, what gets sealed, strict mode after backfill |120| [kms-backends](references/kms-backends.md) | Vault and cloud KMS, per-tenant keys (BYOK), rotation vs replacement |121122### Other planes123124| Reference | Covers |125|---|---|126| [object-storage](references/object-storage.md) | `StorageSpec`, S3 and GCS, tenant-aware buckets, presigned and multipart |127| [http-outbound](references/http-outbound.md) | Declarative outbound HTTP integrations, auth, tenant routing |128| [analytics](references/analytics.md) | `AnalyticsSpec`, named SQL templates, BigQuery and ClickHouse |129| [graph](references/graph.md) | Node and edge specs, traversal ports, Neo4j |130| [inference](references/inference.md) | `InferenceSpec`, local / HTTP / SageMaker backends, capabilities |131132### Testing under faults133134| Reference | Covers |135|---|---|136| [dst-simulation](references/dst-simulation.md) | Declaring a simulation over your own operations, schedulers, fault and latency injection |137| [dst-invariants](references/dst-invariants.md) | Invariants, reachability targets, reading a `ViolationReport` |138139### Running in production140141| Reference | Covers |142|---|---|143| [errors](references/errors.md) | `CoreException`, adapter exception mapping, FastAPI error responses |144| [logging-metrics](references/logging-metrics.md) | Structured logging, call context, operation and resilience metrics |145| [resilience](references/resilience.md) | Retry, breaker, bulkhead, rate limit, hedging; invocation deadlines |146| [shutdown-fleet](references/shutdown-fleet.md) | Graceful drain, quiesce, readiness, fleet posture across replicas |147148## Reference149150> Docs are versioned. These links use `latest` (the newest release). If your app pins an older151> `forze` minor, replace `latest` in the URL with that version (e.g. `.../forze/0.6/...`), or use152> the version selector on the site.153154- [Forze documentation](https://morzecrew.github.io/forze/latest/)155- [Quickstart](https://morzecrew.github.io/forze/latest/get-started/quickstart/)156- [Contracts overview](https://morzecrew.github.io/forze/latest/reference/contracts/)