Developer Guide
While CrowdVision is implemented using Mongoose schemas across different microservices, conceptually, the system follows a Domain-Driven Design (DDD) approach.
Understanding the “Ubiquitous Language” and the boundaries of our data models is essential before writing any code. The system is divided into three primary Bounded Contexts:
This context is responsible for who users are, what organizations they belong to, and what permissions they hold within those organizations.
classDiagram
class Account {
<<Aggregate Root>>
+String _id
+String name
+String email
+String password
+String totpSecret
+IDomainMembership[] memberships
}
class Domain {
<<Aggregate Root>>
+String _id
+String name
+Boolean isVisibleFromOutside
+String authStrategy
+Types.ObjectId[] subdomains
+IDomainTOTPSecrets totpSecrets
+ISSOConfig ssoConfig
}
class IDomainMembership {
<<Value Object>>
+String domainName
+Role role
+String externalId
}
class ISSOConfig {
<<Value Object>>
+String issuerUrl
+String clientId
+String clientSecret
}
class IDomainTOTPSecrets {
<<Value Object>>
+String business_admin
+String business_staff
+String standard_customer
}
Account "1" *-- "many" IDomainMembership : contains
Domain "1" *-- "0..1" ISSOConfig : contains
Domain "1" *-- "1" IDomainTOTPSecrets : containsThe Account is the aggregate root representing a human user or system entity.
The Domain represents an organization (e.g., a university or a company). It dictates the rules of engagement for its members.
This context models the physical reality of the spaces we are monitoring. It is completely isolated from user authentication.
classDiagram
class Building {
<<Aggregate Root>>
+String id
+String[] domains
+Room[] rooms
}
class Room {
<<Entity>>
+String id
+Number capacity
+Number temperature
+Number no_person
+String color
+Number maxTemperature
+Coordinates position
+Dimensions dimensions
}
class Coordinates {
<<Value Object>>
+Number x
+Number y
+Number z
}
class Dimensions {
<<Value Object>>
+Number width
+Number height
+Number depth
}
Building "1" *-- "many" Room : contains
Room "1" *-- "1" Coordinates : located at
Room "1" *-- "1" Dimensions : sized byThe Building is the core spatial aggregate.
A Room only exists within the context of a Building.
This context is lightweight and focused entirely on message delivery.
classDiagram
class Subscription {
<<Aggregate Root>>
+String endpoint
+Keys keys
}
class Keys {
<<Value Object>>
+String p256dh
+String auth
}
Subscription "1" *-- "1" Keys : usesThe Subscription model is strictly used by the Web Push protocol (VAPID).