Skip to content

Commit 40413cf

Browse files
authored
Merge pull request #132 from Deltares/doc/DEI-249-Architecture-doc-
Doc/dei 249 architecture doc
2 parents 28a416d + 098a306 commit 40413cf

File tree

8 files changed

+847
-2
lines changed

8 files changed

+847
-2
lines changed

docs/api/application_overview.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Application overview
2+
3+
The application is setup using a layered architecture (see [link](architecture.md)).
4+
5+
To create the application you will need to create these three components: logger, data-access layer and model builder (see [main.py](https://github.com/Deltares/D-EcoImpact/blob/main/main.py)).
6+
7+
```python
8+
# configure logger and data-access layer
9+
logger: ILogger = LoggerFactory.create_logger()
10+
da_layer: IDataAccessLayer = DataAccessLayer(logger)
11+
model_builder = ModelBuilder(da_layer, logger)
12+
13+
# create and run application
14+
application = Application(logger, da_layer, model_builder)
15+
application.run(path)
16+
```
17+
18+
The logger provides logging functionality to the application, like reporting errors, warnings, user information and debug messages and is created using a factory pattern.
19+
The DataAccessLayer gives the application access to the file system and allows for parsing of input and output.
20+
The modelbuilder uses the builder pattern to create a model from a IModelData data object (created by the data-access layer).
21+
22+
## Running the application
23+
24+
After constructing the application, the application should be ready to run.
25+
During the running of the application the following steps are executed.
26+
27+
![Application execution](../assets/images/Application_run.svg)
28+
29+
The application starts by reading the `ModelData` object from the input files via the `IDataAccessLayer`.
30+
This gets passed to the `IModelBuilder`to convert the `ModelData` into a `IModel` that can be run.
31+
The static `ModelRunner` will then be called to run the created `IModel` and do the real computation.
32+
33+
## Model run
34+
35+
When the `ModelRunner` `run_model` command is executed, the following steps are performed (using `RuleBasedModel` and `ICellBasedRule` as an example).
36+
37+
![Model execution](../assets/images/Model_run.svg)
38+
39+
The `ModelRunner` starts by validating the model (`RuleBasedModel` in this example).
40+
The `RuleBasedModel` delegates the validation of the set of rules that it is composed with, calling the validate on every rule (`ICellBasedRule` in this example).
41+
After the model is successfully validated, the initialize of the model is called. In case of the `RuleBasedModel`, this creates an instance of the `RuleProcessor` and initializes it.
42+
43+
The `ModelRunner` continues by calling the `execute` method on the `RuleBasedModel` that in turn calls `process_rules` on the `RuleBasedProcessor`.
44+
This method loops over all the specified rules and executes the rules based on their type. So for example, with the `ICellBasedRule` the `RuleBasedProcessor` will loop over all the cells and call the `ICellBasedRule` execute method for every cell.
45+
46+
When the model execute has successfully finished with the execute step, the `finalize` method will be called on the model to clean up all resources.
47+
48+
## Class diagram
49+
50+
![Overview class diagram](../assets/images/Overview.svg)

docs/api/architecture.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Main Architecture (Layered Application)
2+
3+
A layered application architecture is a design approach that organizes the components of a software system into distinct layers, each with specific responsibilities.
4+
This separation of concerns enhances maintainability, scalability, and testability. The main layers typically include:
5+
6+
![Layered Architecture](../assets/images/layered-architecture.svg)
7+
8+
*Figure 1: A layered architecture with Business Logic, and Data Access layers.*
9+
10+
## 1. Business Logic Layer
11+
The Business Logic Layer (BLL) contains the core functionality and business rules of the application.
12+
It processes data received from the Data Access Layer and applies business rules.
13+
This layer ensures that the business rules are consistently applied across the application.
14+
15+
## 2. Data Access Layer
16+
The Data Access Layer (DAL) is responsible for interacting with the data storage system.
17+
It provides an abstraction over the data sources, allowing the Business Logic Layer to access data without needing to know the details of the data storage.
18+
19+
## 3. Cross-cutting Concerns
20+
Crosscutting concerns are aspects of the application that affect multiple layers and components (like logging).
21+
By centralizing these concerns, the application can maintain consistency and reduce redundancy.
22+
Lines changed: 110 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)