Learn
Learn UseCase Forge
Build a precise mental model of commands, executions, policies, output, cancellation, and terminal results.
Learn UseCase Forge
UseCase Forge coordinates application work that has a lifecycle: it can be admitted or rejected, queued, started, cancelled, failed, completed, observed, and eventually closed. This guide starts with the smallest useful UseCase and then adds policies only when a concrete operational problem requires them.
Start with the problem
Consider catalog search. A user can type faster than the network responds, leave the screen while a request is running, or submit a query that makes the old result obsolete. A plain async function can fetch data, but it does not define which request may start, which request should be cancelled, what the UI observes while work is running, or how the feature shuts down.
UseCase Forge makes those decisions explicit:
user or system input
↓ Command
input policy decides whether and when it may enter
↓ accepted Execution
processing policy relates it to running work
↓ handler publishes State
Snapshot exposes State, phase, result, and active work
The package is useful when an operation needs repeatable lifecycle rules. A direct method call remains the better choice for work that has no meaningful admission, concurrency, cancellation, observation, or diagnostics requirements.
The five terms to know first
| Term | Meaning |
|---|---|
| Command | A typed request to perform one application operation. |
| Execution | One accepted attempt with its own identity and lifecycle. |
| State | The business data currently owned by the UseCase. |
| Snapshot | State plus observable execution metadata. |
| Instruction | A policy value that controls input or processing behavior. |
Recommended path
- Getting started — install the core package and execute one typed command.
- Core concepts — understand command, execution, snapshot, result, and group identity.
- Lifecycle — follow an accepted command from admission to finalization.
- Policies — choose input and processing behavior deliberately.
- Architecture — understand the responsibility boundaries behind the public API.
What this documentation does not assume
UseCase Forge is not a dependency injection container, a repository abstraction, or a replacement for domain modeling. It owns execution coordination. Your application continues to own business rules, persistence, navigation, presentation, and service boundaries.