Guide: Create a New Project
This guide walks through creating a new monorepo project from scratch. Follow the steps in order.
Prefer a working example? Clone LitePress — the reference implementation of these standards — and adapt it instead of greenfield scaffolding.
Prerequisites
- .NET 10 SDK installed with
global.jsonversion constraint. - Node.js 22 and pnpm 10 installed.
- Docker installed (for local database via .NET Aspire).
- Git configured.
Step 1: Initialize the Repository
mkdir {ProjectName}cd {ProjectName}git initCopy root templates from docs/templates/:
.nvmrc→ repository rootpackage.json→ repository rootpnpm-workspace.yaml→ repository rootturbo.json→ repository rootci-workflow.yml→.github/workflows/ci.ymlDockerfile.api→Dockerfile.apiDockerfile.web→Dockerfile.webdockerignore→.dockerignoreproject-agents.md→AGENTS.md(fill placeholders)
Step 2: Create Root Monorepo Packages
Copy docs/templates/config/packages/api-types/ and docs/templates/config/packages/api-client/ to packages/.
Step 3: Create the .NET Solution
mkdir -p apps/apicd apps/apidotnet new sln -n {ProjectName}
dotnet new classlib -n {ProjectName}.Domain -o src/{ProjectName}.Domaindotnet new classlib -n {ProjectName}.Application.Write.Contracts -o src/{ProjectName}.Application.Write.Contractsdotnet new classlib -n {ProjectName}.Application.Write -o src/{ProjectName}.Application.Writedotnet new classlib -n {ProjectName}.Application.Read.Contracts -o src/{ProjectName}.Application.Read.Contractsdotnet new classlib -n {ProjectName}.Application.Read -o src/{ProjectName}.Application.Readdotnet new classlib -n {ProjectName}.Application.Reactions -o src/{ProjectName}.Application.Reactionsdotnet new classlib -n {ProjectName}.Infrastructure -o src/{ProjectName}.Infrastructuredotnet new web -n {ProjectName}.WebApi -o src/{ProjectName}.WebApidotnet new worker -n {ProjectName}.Worker -o src/{ProjectName}.Workerdotnet new aspire-apphost -n {ProjectName}.AppHost -o src/{ProjectName}.AppHostdotnet new aspire-servicedefaults -n {ProjectName}.ServiceDefaults -o src/{ProjectName}.ServiceDefaults
dotnet new xunit -n {ProjectName}.Domain.Tests -o tests/{ProjectName}.Domain.Testsdotnet new xunit -n {ProjectName}.Application.Tests -o tests/{ProjectName}.Application.Testsdotnet new xunit -n {ProjectName}.Integration.Tests -o tests/{ProjectName}.Integration.Testsdotnet new xunit -n {ProjectName}.Architecture.Tests -o tests/{ProjectName}.Architecture.Tests
dotnet sln add src/**/*.csproj tests/**/*.csprojCopy into apps/api/ from docs/templates/:
global.jsonDirectory.Build.propsDirectory.Packages.props.config/dotnet-tools.json(from section below)
Pin package versions from standards.manifest.json.
Step 4: Configure Project References
See docs/conventions/backend/solution-structure.md section 5. WebApi references Application.Write.Contracts, Application.Read.Contracts, Infrastructure, and ServiceDefaults.
Worker references Infrastructure, Application.Write, Application.Reactions, and ServiceDefaults. Worker MUST NOT reference WebApi.
Step 5: Install NuGet Packages
Use docs/templates/config/Directory.Packages.props as the starting point. Key packages per project are listed in docs/conventions/backend/solution-structure.md sections 6 and 7.
Infrastructure uses LiteBus.Commands.Abstractions and LiteBus.Events.Abstractions only, not full LiteBus packages.
Step 6: Set Up WebApi
- Copy
Program.csand supporting files fromdocs/blueprints/backend/program-cs.md. - Copy
EndpointExtensionsfromdocs/blueprints/backend/endpoint-extensions.md. - Copy
GlobalExceptionHandlerfromdocs/conventions/backend/exception-hierarchy.md. - Copy auth files from
docs/conventions/backend/authentication-and-authorization.md. - Configure WebApi
.csprojfor build-time OpenAPI perdocs/conventions/backend/api-layer.md.
Step 7: Set Up Infrastructure and Worker
- Copy
InfrastructureServiceRegistrationfromdocs/blueprints/backend/infrastructure-service-registration.md. - Add Outbox and Idempotency from blueprints when required.
- Copy Worker
Program.csfromdocs/blueprints/backend/worker-program-cs.md. - Copy AppHost from
docs/blueprints/backend/apphost.md.
Step 8: Set Up Tests
- Copy architecture tests from
docs/blueprints/backend/architecture-tests.md. - Copy integration factory from
docs/blueprints/backend/integration-test-factory.md.
Step 9: Create the First Domain Aggregate
Follow docs/conventions/backend/domain-layer.md. Write the operation and test docs first using docs/guides/write-use-case-doc.md.
Step 10: Create the First Migration
dotnet tool restoredotnet ef migrations add InitialCreate \ --project apps/api/src/{ProjectName}.Infrastructure \ --startup-project apps/api/src/{ProjectName}.WebApiStep 11: Set Up Next.js Frontend
mkdir -p apps/webcd apps/webpnpm create next-app . \ --typescript \ --app \ --no-eslint \ --no-tailwind \ --no-import-aliasDo not pass --src-dir. The app lives at apps/web/app/.
Then:
- Copy
next.config.tsfromdocs/blueprints/frontend/next-config.md. - Copy
playwright.config.tsfromdocs/templates/config/playwright.config.tstoapps/web/. - Copy
eslint.config.tsfromdocs/templates/config/eslint.config.ts. - Copy
lib/env.ts,lib/api/client.ts, andproxy.tsfrom frontend blueprints. - Install pinned versions from
standards.manifest.json.
Step 12: Domain Documentation
Set up the domain doc tree under docs/domain/:
- Copy
docs/templates/docs/domain-system-index.mdtodocs/domain/README.md. - Copy
docs/templates/docs/domain-agent-index.jsontodocs/domain/agent-index.jsonand fill from the system index. - For the first feature, copy
docs/templates/docs/domain-feature.mdtodocs/domain/{feature}/README.md. - For each use case, copy
docs/templates/docs/domain-use-case.mdtodocs/domain/{feature}/{use-case}.mdanddomain-use-case.tests.mdtodocs/domain/{feature}/{use-case}.tests.md. Fill YAML frontmatter on each doc.
Read docs/guides/write-use-case-doc.md and docs/guides/agentic-domain-driven-design.md before the first use case.
Step 13: Production Infrastructure (optional)
Copy VPS deployment templates from docs/templates/config/infra/ to infra/:
docker-compose.prod.ymlCaddyfile
Add a committed .env.example with variable names only. See docs/conventions/shared/infrastructure-as-code.md.
Step 14: Verify
dotnet tool restoredotnet build apps/api/{ProjectName}.slnx --configuration Releasedotnet test apps/api/{ProjectName}.slnx --configuration Release --no-buildpnpm install --frozen-lockfilepnpm lint && pnpm type-check && pnpm test && pnpm builddotnet run --project apps/api/src/{ProjectName}.AppHostComplete docs/guides/definition-of-done.md.