Aggregates, values, and events. An aggregate is a kind of entity that, as you can see here, provides a transactional scope, a la a database transaction around this entire set of objects. objects. Again, this blue sticky represents a command, submit application. The application, submit application command, is being received by an application entity. And based on this command, it's basically setting up the initial application data. And part of the data of the inside the application is this value object known as progress. And this is tracking the steps that have been accomplished. For example, submitted. So after the application has accepted the submit command, then the first step is going to be recorded, submitted. In a different use case, risk assessed, rate calculated, and quote generated are the steps that could be tracked by the application. This is known as a value object as opposed to an entity that represents the entire transactional boundary as an aggregate. And this is a domain event, which is a record of the fact that the proposal was submitted. It's stated in past tense, and it is known now as a fact because, in fact, the application has been submitted. been submitted. Model behavior is shown here represented by submit agent customer application which is being received by the model and as part of the behavior as I showed before we have this business set of business rules or constraints that we need for an agent underwriting policy. submitted event, after it occurs, this policy will apply to the next step before the agent customer can be imported because we have to know that the agent underwriting policy was satisfied based on the agent customer application being submitted. agent-customer application being submitted. So having business rules inside a bounded context model is very important as part of the model behavior. Domain services are known as stateless operations. So you can see that we have a domain service here, quote generator, and it is generating a quote, and the result, the outcome of that stateless operation or domain service is a policy quote, a noun, an entity, which itself, again, is an aggregate inside a database transactional boundary. Again, business logic represented by different kinds of policies is important. So not only do we have some business rules, So not only do we have some business rules, but we have exact calculations based on the kinds of things that we want to have happen across the model. So a rate calculator will base its rate calculations on price calculation rules as a policy. As a result, the rate calculated event can be emitted from the model, and it will have a premium value attached to it, or as part of the domain event, premium will be captured by rate calculated as part of its fact. This shows that commands lead to events. So imagine this user interface, policy application user interface, and we collect some information about the individual who is applying for an insurance policy. They click the Apply Now to apply for the policy, and as a result, we have a command, And as a result, we have a command, a software command that is formed in the background application submitted event, assuming that this command was valid with all the information needed and that it was accepted, then we can say that the policy application was submitted. This is now a fact. There's another way for events to occur, and this can be, for example, because of a time, a date and a time being reached. In this case, notice that on August the 20th or the 20th of August, I'm sorry, on the 31st day of August, and this was in the year 2020, at 2359.59, so right just before midnight, we want to know that this time occurred, and as a way of knowing that this time occurred, we capture this information inside a domain event. But notice that the domain event is not named the 31st of August, 2020, at 2300 hours, 59 minutes, and 59 seconds. No, it's named month ended. So within a sales context, we are interested in a month ending because we need to capture the fact that, let's say, all the sales contracts that have been made before this point are good. Any contracts that are still being negotiated, still being worked out, are not considered part of the month of August closed sales. of August closed sales. On the other hand, we have the exact same date, but in a completely different context, the accounting context. And inside the accounting context, this exact same date, the 31st of August in the year 2020, at the 23rd hour, 59th minute, that 59th second generates an event ledger period closed. So you can see that the accounting department or the accounting function within the company is now closing the books for that accounting period or the ledger period. So not only can events happen from the commands, but they can happen from non-command sources such as time.