Skip to content

Projects Design

Status: Work in progress

VersionDateAuthorStatusDescription
0.12025-01-07isierraWIPInitial version

Tdp.Projects repository

Introduction

The Projects module belongs to the core domain of the system and is responsible for managing modules, projects, licenses, contracts, etc.

Diagram

Location of Project Module in the system with respect to other modules

The main concepts of the Projects module are:

Diagram

Diagram of the main concepts and relations of the Projects module

Design

Service Architecture

Module Design

The Module entity represents a service or module in the system, like users, booking, maintenance, etc. Each module has a set of entities, parameters, and permissions that define the functionality of the module.

Diagram

Module Value Objects

ModuleElementId

The module element identifier is a unique key that represents a module element in the system. It is used to assign operations to roles and users, to reference dependent modules, etc.

It allows to implement the hierarchical structure of permissions, where each permission is composed of a series of elements that represent the area, module, resource, category, and operation of the permission.

The hierarchy usually should contain the following elements, but this could change depending on the complexity of each module:

ElementPrefixDescription
AreaA:The area of the application where the element belongs to
ModuleM:The module of the application where the element belongs to
ResourceR:The resource or entity type that the element is related to
OperationO:The operation that the element allows to perform
ParameterP:The parameter that the element is related to

The areas in the system are: core, support, business, etc.

The modules in the system are: users, projects, zones, booking, etc.

The resources or entities in the system are: module, user, role, project, zone, room, meeting, work_order, etc.

The categories of the resources only apply to some complex resources, like work_order. Some examples of sub-resources are: preventive, corrective, etc.

The operations in the system are: create, read, modify, delete, etc.

Examples of permission ids at different levels of the hierarchy are:

PermissionID
Facility ManagementA:fm.
Booking ModuleA:fm.M:booking.
Meeting RoomsA:fm.M:booking.R:room.
Create RoomA:fm.M:booking.R:room.O:create.
Read/List RoomsA:fm.M:booking.R:room.O:read.
Show Security CodeA:fm.M:booking.R:room.O:passcode.
MeetingsA:fm.M:booking.R:meeting.
Create MeetingA:fm.M:booking.R:meeting.O:create.
Read/List MeetingsA:fm.M:booking.R:meeting.O:read.
CoreA:core.
Users ModuleA:core.M:users.
UserA:core.M:users.R:user.
Delete UserA:core.M:users.R:user.O:delete.
Value Object
PermissionId:
Type: string
Constraints:
MinLength: 2
MaxLength: 255
Regex: "^((?<type>[AMROP])\:(?<key>[a-z_]+)\.)*$"
ModuleElementKey

The operation key is a key that represents the kind of operation that a permission allows to perform, if it is an operation permission.

The operation key DOES NOT include the type or the separator, only the key.

The known operation types are:

  • read for Read
  • create for Create
  • modify for Modify
  • delete for Delete

Other less-known operations could be defined like approve, print, cancel, etc.

Value Object
OperationKey:
Type: string
Constraints:
MinLength: 1
MaxLength: 20
Regex: "^[a-z_]+$"

Module Fields

To define the classes that define this module element hierarchy, the following classes and fields are used:

Diagram
ModuleElementDefinition

The fields with their data types are described below:

FieldTypeConstraints
ElementIdModuleElementId
ElementKeyModuleElementKey
DisplayNameDisplayName
DescriptionDescription?
ModuleDefinition

The fields with their data types are described below:

FieldTypeConstraints
ActiveByDefaultBoolean
DependsOnModuleElementId[]
ProjectIdEntityId?prefix:proj
VersionsModuleVersionDescription[]
ParametersModuleParameterDefinition[]
ResourcesModuleResourceDefinition[]
ModuleVersionDescription

The fields with their data types are described below:

FieldTypeConstraints
VersionStringlength:1,20
ChangesDescription
ModuleResourceDefinition

The fields with their data types are described below:

FieldTypeConstraints
ResourcesModuleResourceDefinition[]
OperationsModuleOperationDefinition[]
ModuleOperationDefinition

The fields with their data types are described below:

FieldTypeConstraints
OrderInteger
AccessTypesModuleAccessType[]
ModuleParameterDefinition

The fields with their data types are described below:

FieldTypeConstraints
DataTypeJsonSchema
DefaultValueStringvalid serialized json

Module Shared Domain Models

Domain Model
ModuleElementDefinition:
ElementId:
ElementKey:
DisplayName:
Description:
Domain Model
ModuleDefinition:
...ModuleElementDefinition:
ActiveByDefault: bool
DependsOn: ModuleElementId list
ProjectId: EntityId?
Versions: ModuleVersionDescription list
Parameters: ModuleParameterDefinition list
Resources: ModuleResourceDefinition list
Domain Model
ModuleVersionDescription:
Version: string
Changes: string
Domain Model
ModuleResourceDefinition:
...ModuleElementDefinition:
Resources: ModuleResourceDefinition list
Operations: ModuleOperationDefinition list
Domain Model
ModuleOperationDefinition:
...ModuleElementDefinition:
Order: int
AccessTypes: ModuleAccessType list
Domain Model
ModuleParameterDefinition:
...ModuleElementDefinition:
DataType: JsonSchema
DefaultValue: string

Module Domain Events

Event ModuleWasDefined is triggered when a module is created or updated in the system. It should be a very rare event, as the module definition should be stable.

Domain Event
ModuleWasDefined:
module: ModuleDefinition

Module Use Cases

Define Module Use Case

This command overwrite the module definition in the system, independent of whether the module is already defined or not. It is used to define the modules that are available in the system. Each service should have a startup workflow that uses this operation to publish any changes to the module definitions.

Command
ModuleCommandDefine:
Module: ModuleDefinition
Response
ModuleCommandDefineSuccess:
Created: bool # True if the module definition has been created. False otherwise
Updated: bool # True if the module definition has been updated. False otherwise
Emits
ModuleWasDefined: # when the module definition has been created or updated
List Modules Use Case

This query returns the list of modules that are defined in the system.

Query
ModuleQueryList:
Filter:
SearchText: string # On Id, DisplayName, Description
Id: EntityIdFilter
DisplayName: StringFilter
ActiveByDefault: BooleanFilter
Sorting:
Id:
DisplayName:
Paging: # See pattern for details
Response
ModuleQueryListSuccess:
ItemsPage: # List
ElementId:
ElementKey:
DisplayName:
Description:
CreatedAt:
ModifiedAt:
# See paging pattern for details
Updates on
ModuleWasDefined:
Fetch Module Details Use Case

This query returns the details of multiple modules in the system.

Query
ModuleQueryFetch:
ModuleIds: ModuleElementId list
Response
ModuleQueryFetchSuccess:
Items: ModuleDefinition list

Culture Design

Culture Fields

The fields with their data types are described below:

FieldTypeConstraints
CultureCodeStringlength:1,20
EnglishNameDisplayName
NativeNameDisplayName

Culture Events

Domain Event
CultureWasDefined:
CultureCode: string # StreamKey
EnglishName: string
NativeName: string
Domain Event
CultureWasDeleted:
CultureCode: string # StreamKey

Culture Commands

CultureCommandDefine

The CultureCommandDefine command is used to define a culture in the system.

Domain Command
CultureCommandDefine:
CultureCode: string # StreamKey
EnglishName: string
NativeName: string
Response
CultureCommandDefineSuccess:
Updated: bool
Emits
CultureWasDefined: # when the culture has been created or updated
CultureCommandDelete

The CultureCommandDelete command is used to delete a culture in the system.

Domain Command
CultureCommandDelete:
CultureCode: string # StreamKey
Response
CultureCommandDeleteSuccess:
Deleted: bool
Emits
CultureWasDeleted: # when the culture has been deleted

Culture Queries

CultureQueryList

The CultureQueryList query is used to list the cultures that are defined in the system.

Query
CultureQueryList:
Filter:
SearchText: string # On CultureCode, EnglishName, NativeName
Sorting:
CultureCode:
EnglishName:
NativeName:
Response
CultureQueryListSuccess:
ItemsPage: # List
CultureCode:
EnglishName:
NativeName:
# See paging pattern for details
Updates on
CultureWasDefined:
CultureWasDeleted:
CultureQueryFetch

Project Design

:::caution[TBD]I. Event fan out rules, even. Fan out rules even. Sign out. We leverage Alba an exit. Docker. Setup System under Test fixture. Turn your system under test. The host is boss. Connection feast. I host, I hope. I know, I know. Destiny’s that sexy? Test this 10. Oh well. :::

Module License Design

Usage License Design

Identity Provider Design

Module Definition

This is the definition of the Projects module in the system. It includes the entities, parameters, and permissions that are part of the current module. This service has to publish this information at startup to the corresponding Define Module command, using the published client for it.

- kind: Module
moduleId: A:core.M:projects.
displayName: Projects
description: Manages projects, licenses, infrastructure, etc.
activeByDefault: true
dependsOn:
- A:support.M:authorization.
- A:support.M:communication.
- A:support.M:datacollector.
- A:support.M:processes.
entities:
- kind: ModuleEntity
entityId: A:core.M:projects.E:module.
displayName: Module
description: Represents a module of functionality on the system that can be enabled or disabled for a given project.
- kind: ModuleEntity
entityId: A:core.M:projects.E:culture.
displayName: Culture
description: Represents the different cultures that can be used in the system, defining the language, the date format, and other cultural data.
- kind: ModuleEntity
entityId: A:core.M:projects.E:project.
displayName: Project
description: Represents a project, which is a set of resources that belong to a given client and they need to manage them as a cohesive unit.
- kind: ModuleEntity
entityId: A:core.M:projects.E:project.
displayName: Project
description: Represents a project, which is a set of resources that belong to a given client and they need to manage them as a cohesive unit.
parameters:
- kind: ModuleParameter
parameterId: mprmImportExportProject
displayName: Enable Import/Export Project
description: Enable the import/export functionality for projects
dataType: |
{ type: "boolean" }
defaultValue: "false"
permissions: []