Skip to content

Commit 8f96b0f

Browse files
committed
architecture notes in CONTRIBUTING
1 parent 7582ae0 commit 8f96b0f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

CONTRIBUTING.md

+37
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,40 @@ $ git push --tags
146146
```
147147

148148
Travis will then deploy to PyPI if tests pass.
149+
150+
151+
## Architecture Notes
152+
153+
**The View**
154+
155+
- builds Ui,
156+
- reacts to data changes (by updating the Ui)
157+
- listens for events and forwards them to the Intent
158+
159+
**The Intent**
160+
161+
- receives events
162+
- if some data is affected by the event, figure out which data source corresponds to that data
163+
- transforms the event data to the data format required by the data source
164+
- transform returned data source data to the data format required by the Ui
165+
- else, no data is affected by the event, handle the event (often using a util class).
166+
- an example of this is sending invoices by mail.
167+
168+
**The Model (a.k.a data layer)**
169+
170+
- defines the entity
171+
- define the entity source (file, remote API, local database, in-memory cache, etc)
172+
- if a relational database is used, define the entity's relationship to other entities
173+
- maintain the integrity of that relation (conflict strategies for insert operations are defined here, and integrity errors are thrown here, for example)
174+
- defines classes that manipulate this source (open, read, write, ....)
175+
176+
177+
As you go outer in layers (the outmost layer is the Ui, the innermost is the data layer), communication can occur down_ward across layers, and horizontally (for lack of a better word) BUT a layer cannot skip the layer directly below it. This is to say:
178+
179+
* Data sources can communicate with each other. Thus `ClientDatasource.delete_client` can call. `ContractDatasource.get_contract ` for example.
180+
181+
* Intents can communicate with each other, and with any data source. Thus `ClientIntent` can call `ContractIntent` or `ContractDatasource` for example.
182+
The Ui can communicate with any intent (though often the Ui is tied to only a single intent, and the intent can instead call the 'other' intent). But it cannot communicate with a data source -> this would violate the do not skip layers rule.
183+
An inner layer cannot have a dependency on the layer above it. Thus an intent cannot instantiate a Ui class, and a data source cannot instantiate an Intent class.
184+
185+
![](assets/images/mvi-concept.png)

assets/images/mvi-concept.png

90.6 KB
Loading

0 commit comments

Comments
 (0)