/
├── ios iOS Native Code.
├── android Android Native Code.
├── tests Unit tests.
├── e2e Tests e2e.
└── src
├── bounded-context
│ ├── presentation React Native UI logic, containers, screens, components.
│ │ ├── i18n
│ │ ├── navigations
│ │ ├── components
│ │ └── stylesheets
│ ├── application Application business logic (Use cases).
│ │ └── hooks
│ ├── domain Enterprise business logic.
│ │ ├── entity
│ │ ├── failures
│ │ └── value-object
│ └── infrastructure Interface to communicate with other contexts. (Local and remote resources)
│ ├── sagas
│ ├── services
│ ├── integrations
│ └── redux
└── shared
The rule of dependency can help you to intelligently divide and conquer, using concepts from Clean Architecture We can build apps more stables and more scalable.
Separate the application in bounded contexts, you can think in this like a module and communicate the different bounded contexts thought interfaces by this way we have more possibilities to scale the application if we need in a future.
In this case this can be a great idea to abstract the business logic and uses cases from the UI (react native code), to get that we will use layers:
- Presentation.
- Use cases.
- Domain.
- Infrastructure.
In this layer are all the react native code, in less words the view. (components, styles, routing, theme...)
In this layer we place the Use cases, this interact with the Domain layer and know about the Entities that each Use case need to do a specific task. This layer encapsulate the application logic and orchestrate the flow of data.
The domain encapsulate:
- Entities
- Value objects
- Failures
Entities encapsulate Enterprise wide business rules. An entity can be an object with methods, or it can be a set of data structures and functions.
Value objects is used to model concepts in our system, such as identifiers, dates or date ranges, prices, weights, speeds (virtually any magnitude is modelable as a used-vehicle), or even titles, names or addresses. Entities, for example, are composed of Value Objects.
Failures is a abstraction layer to handle the exceptions from the repository/infrastructure layer.
Here live the repositories, local and remote resources as services. (Store, API connections, LocalStorage, device resources like location, etc)