I am trying to apply DDD to the design of a Release Management system.

Domain Entities

  • Project: The project/product/system.
  • ProjectEnvironment: The environments (Test, Staging, Prod) that exist for this project. Each project has its own defined environments.
  • ProjectVersion: A specific version of the project. This would be associated with a deployment package.

    Class diagram of entities

Aggregate Boundary

From this I would have Project be the aggregate root and ProjectEnvironment and ProjectVersion be aggregates of Project. Neither of these can exist without Project.


I would then only have a ProjectRepository which would provide persisted Projects with all the included ProjectVersion and ProjectEnvironment aggregates (and consequently can only be accessed through their respective Project).


  1. Should there be a VersionRepository and a EnvironmentRepository? A GetVersionById() method on the ProductRepository sounds wrong. But then wouldn't supplying multiple repositories threaten the aggregate boundary?

  2. Should there be a 'ProjectService' which would handle and validate the aggregates using the three repositories? In order to safeguard against invalid data, client code would only be able to reference the 'ProjectService'.

1 Answer 1


If your ProjectVersion does not make sense without a Project then there's no need to have a repository of them. All versions for a project should be contained wtihin the aggregate. Furthermore your aggregate itself is where your validation should take place. This ensures that your aggregate is always consistent and valid.

public class Project {
    private List<ProjectVersion> Versions = new List<ProjectVersion>();

    public void AddVersion(Version version, string notes) {
        if(Versions.Any(x => x.Version > version)) {
            throw new Exception("Invalid version given. Version cannot be lower than the highest current version.");
        Versions.Add(new ProjectVersion(this, version, notes));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.