Add your first domain

This tutorial adds a Projects domain: a workspace's projects, each with a name and a status — planned, active or done. It is small on purpose: the point is the path, not the feature. Every step follows the Workspaces domain, which the Starter ships as the reference to copy, so when in doubt open the matching Workspaces file.

You should have read Domains and modules and Reads and writes first.

What you will build

  • POST /api/v1/workspaces/{workspaceId}/projects — a member of the workspace's organization creates a project.
  • PUT /api/v1/workspaces/{workspaceId}/projects/{id}/status — moves it to another status.
  • GET /api/v1/workspaces/{workspaceId}/projects — lists them.
  • A Projects page under the workspace: /acme-corp/workspaces/12/projects.

Projects belong to workspaces, but they are a domain of their own: they ask Workspaces whether a workspace exists through its public contract, never through its repository. That is the one cross-domain door this tutorial uses.

What you will create

back/
├── Blouppy.Projects.Models/                 Project, ProjectStatus, the domain events
├── Blouppy.Projects.Abstractions/           IProjectsService, ProjectCreation, ProjectStatusChange
├── Blouppy.Projects/                        ProjectsService, the validators, AddProjectsDomain()
├── Blouppy.Projects[.Models].UnitTests/
├── Blouppy.SharedKernel/Types/ProjectId.cs
├── Blouppy.Infrastructure.Database.Abstractions/Projects/   the write and read ports
├── Blouppy.Infrastructure.Database/Projects/                configuration, repositories
├── Blouppy.ApiQuery[.Abstractions]/Projects/                IProjectsApiQueryService
└── Blouppy.Web/Controllers/Api/Projects/                    ProjectsController, DTOs
front/application/src/app/
├── api/projects-api.service.ts
└── features/project/                       service, page, its route under the workspace

No .PublicData for Projects yet: a domain gets one the day another domain needs a fact from it.

The steps

#StepThe Workspaces file to copy
1The model and the databaseBlouppy.Workspaces.Models/Teams/Team.cs, Blouppy.Infrastructure.Database/Workspaces/Teams/
2The write sideBlouppy.Workspaces/Teams/TeamsService.cs, Blouppy.Workspaces/WorkspaceCreationValidator.cs
3The read side and the APIBlouppy.ApiQuery/Workspaces/Teams/, Blouppy.Web/Controllers/Api/Workspaces/Teams/TeamsController.cs
4The Angular featurefront/application/src/app/features/workspace/
5Tests and checksthe Workspaces test projects

Teams are the closest example: like a project, a team hangs under a workspace (/workspaces/{workspaceId}/teams).