# Start a Consumer Repository

## Purpose

A LiteSpec consumer is a project built against the LiteSpec standard, and this tutorial turns an empty folder into one: its configuration, its first Intent records, the Behavior specified from them, one working use case, and a passing model check. A use case names what the product does for an actor, a person or system using it, and the model check confirms the records, code, and tests agree. This tutorial follows one backend stack and one frontend stack, the `dotnet` backend with a React frontend, so every step runs the same way for every reader. A developer follows these steps once, when creating the consumer. Each step names the standard it satisfies, and the tutorial adds no rule of its own.

## Prerequisites

- Install the .NET SDK and Node.js releases the adopted release pins under `stack` in its `litespec.manifest.yaml`.
- Read nothing in advance: each step links the standard it satisfies, so open each linked page at its step.
- Ship the `dotnet` backend with a React frontend: this tutorial follows that pair from the `dotnet-react` preset. When the product ships another frontend, follow this tutorial first, then declare that frontend with its own how-to, [Add a Svelte Frontend](https://litespec.dev/6.0.0/guide/add-a-svelte-frontend.md) or [Add a Blazor Frontend](https://litespec.dev/6.0.0/guide/add-a-blazor-frontend.md).
- To start with records only and no stack, follow [Start with Records Only](https://litespec.dev/6.0.0/guide/start-with-records-only.md) instead of this tutorial.

## Lesson

This lesson creates a new project. The `litespec new` commands below write each record from its template with example values, so replace every example value with the project's own before committing. After the project runs, adding new intent to it follows the one sequence under [New Intent in a Running Project](https://litespec.dev/6.0.0/core/agent.md#new-intent-in-a-running-project) on the agent page, and the check steps below walk that same order for the first slice.

1. Install the LiteSpec CLI for the adopted release as the [CLI overview](https://litespec.dev/6.0.0/tools/README.md#install-the-cli) shows. Check that `dotnet litespec --help` prints the command list from the consumer root. This satisfies `litespec/workspace/structure#use-the-canonical-root-tree`.
2. Run `dotnet litespec init --preset dotnet-react --size small` and confirm `.litespec/project.yaml` exists. The [initialize command](https://litespec.dev/6.0.0/tools/init.md) lists what the command writes. This satisfies `litespec/core/scope#select-a-size-a-shape-and-stacks`.
3. Select extensions only when their criteria already hold. Write each selection in the object form with its criterion. This satisfies `litespec/core/scope#select-conditional-extensions-explicitly` and `litespec/core/scope#record-selected-extensions`.
4. Set `paths.behaviorDocs` in `.litespec/project.yaml` to the Behavior root and confirm the path names that folder. This satisfies `litespec/core/scope#point-behavior-docs-at-the-behavior-root`.
5. Create the toolchain configuration from the manifest pins named on the [project file](https://litespec.dev/6.0.0/reference/project-file.md) and [manifest](https://litespec.dev/6.0.0/reference/manifest.md) pages. Check that the SDK, build, package, tool manifest, and JavaScript toolchain pins match the manifest. This satisfies `litespec/backend/dotnet/config#set-the-sdk-floor-at-the-workspace-root`, `litespec/backend/dotnet/config#centralize-net-build-settings`, `litespec/backend/dotnet/config#centralize-nuget-versions`, `litespec/backend/dotnet/config#commit-the-tool-manifest`, and `litespec/workspace/config#pin-the-javascript-toolchain`.
6. Add only the packages the manifest already pins. Record each new package approval explicitly. This satisfies `litespec/workspace/dependencies#pin-every-dependency-version-centrally` and `litespec/workspace/dependencies#approve-new-packages-explicitly`.
7. Create the API solution and its projects as [Write Code for a Use Case](https://litespec.dev/6.0.0/guide/write-code-for-a-use-case.md) and the [.NET architecture](https://litespec.dev/6.0.0/backend/dotnet/architecture.md) and [backend testing](https://litespec.dev/6.0.0/backend/testing.md) pages describe. Check that the solution holds the projects those pages require for a small server project. This satisfies `litespec/backend/dotnet/architecture#separate-the-shared-kernel-from-the-modules`, `litespec/backend/testing#keep-the-test-suites-the-size-requires`, and `litespec/backend/dotnet/packages#run-litespec-analyzers-in-the-business-projects-and-hosts`.
8. Apply the naming rules: match each C# file to its primary type and each namespace to its folder. This satisfies `litespec/backend/dotnet/naming#match-c-files-and-primary-types` and `litespec/workspace/naming#keep-namespaces-aligned-with-folders`.
9. Write the product record. Run `dotnet litespec new product <name>` and fill its `boundary`, its `addresses`, and its `summary`. This satisfies `litespec/core/intent#state-one-product` and `litespec/core/intent#keep-intent-in-its-homes`.
10. Write one module with its first feature. Run `dotnet litespec new module <module>`, write the problem the feature answers, then follow [Write a Feature Under a Problem](https://litespec.dev/6.0.0/guide/write-a-feature-under-a-problem.md) to add the feature and its requirements. This satisfies `litespec/core/intent#keep-intent-in-its-homes` and `litespec/core/intent#identify-every-requirement`.
11. State which constraints apply. Run `dotnet litespec new constraint <name>` once per outside rule and complete the record, or record that none applies. This satisfies `litespec/core/intent#answer-every-constraint` and `litespec/core/scope#answer-the-constraints-question`.
12. Record the first decision. Run `dotnet litespec new decision <name>` and complete the record and its explanation file. This satisfies `litespec/core/intent#shape-each-decision-page`.
13. Write the people records. Run `dotnet litespec new actor <name>` once per party and `dotnet litespec new role <name>` once per grantable set. Create the module permission list from its template and add each permission with `dotnet litespec new entry .litespec/behavior/modules/<module>/permissions.yaml permission <name>`. When the slice exchanges anything with an outside system, run `dotnet litespec new external-system <name>` and complete the record.
14. Write one journey. Run `dotnet litespec new journey <name>` and complete the record with its `serves`, `startedWhen`, `finishedWhen`, steps, and `branches`. This satisfies `litespec/core/intent#order-each-journey-toward-one-goal`, `litespec/core/intent#write-journey-steps-as-sentences-with-ids`, `litespec/core/intent#state-when-each-journey-starts`, and `litespec/core/intent#state-when-each-journey-finishes`.
15. Check the Intent records. Run `dotnet litespec model check` from the consumer root and fix every finding that names a record written so far before continuing. The run sees records only at this point, so it still reports missing Behavior record types and unreached Intent until step 16. The [model command](https://litespec.dev/6.0.0/tools/model.md) page lists the findings and their levels.
16. Specify the module from Intent. Leave this tutorial now and complete [Model a Behavior Module](https://litespec.dev/6.0.0/tutorial/model-domain.md) from its first step to its last, then return here, run `dotnet litespec model check`, and fix every finding before code moves. This satisfies `litespec/core/system#group-module-use-case-files-by-aggregate` and `litespec/core/model#author-one-slice-at-a-time`.
17. Implement one use case. Move the transition into a business method, keep the handler narrow, commit once, expose one endpoint, and authorize the target. Code points up to its record through its mark. This satisfies `litespec/backend/domain#express-transitions-through-business-methods`, `litespec/backend/application#keep-command-handlers-to-load-call-and-stage`, `litespec/backend/dotnet/persistence#commit-once-in-the-command-pipeline`, `litespec/backend/dotnet/api#use-one-endpoint-per-operation`, and `litespec/backend/application#enforce-target-authorization-in-the-pipeline`.
18. Declare the React frontend. Declare the application tree and mirror the backend use case path. This satisfies `litespec/frontend/web/structure#use-the-frontend-application-tree`. Build each pattern Default and record it with `source: recommended`, waiting for an owner only when a route departs from the Default or no Default exists, and compose each route from one floorplan. This satisfies `litespec/frontend/ui#compose-each-route-from-one-floorplan`.
19. Deliver one complete slice. Ship source, tests, contracts, and operating evidence for one use case. This satisfies `litespec/core/system#deliver-one-complete-use-case`.
20. Add the operating records. Write the settings and runbooks, add deployment, backup, restore, and rollback, and configure the pipeline gates. This satisfies `litespec/quality/operations#start-the-stack-with-one-local-command` and `litespec/quality/ci#run-applicable-gates-on-every-pull-request`.
21. Run the boundary gates and the test suites the changed areas select, so the latest test run stands before the model reads it.
22. Run `dotnet litespec model check` and confirm the run exits with no open blocking finding. The [model command](https://litespec.dev/6.0.0/tools/model.md) page lists its exit codes and what it reports.
23. Run `dotnet litespec model render` and commit what it wrote. This satisfies `litespec/core/release#run-consistency-checks`.
24. Run `dotnet litespec book` and open the journey detail, the way product reviewers read the change.

## What You Built

- A consumer repository at small size that the model check accepts.
- One coded use case with Intent, Behavior, code, tests, and generated contracts.
- When the next use case is specified, follow [Write Code for a Use Case](https://litespec.dev/6.0.0/guide/write-code-for-a-use-case.md) to place each of its code elements with its mark and check.
- When the product ships another frontend, [Add a Svelte Frontend](https://litespec.dev/6.0.0/guide/add-a-svelte-frontend.md) and [Add a Blazor Frontend](https://litespec.dev/6.0.0/guide/add-a-blazor-frontend.md) declare it. The checks are documented on [Model Builder](https://litespec.dev/6.0.0/tools/model.md); all commands are listed on the [command index](https://litespec.dev/6.0.0/tools/README.md).
