How carlossalasamper/react-native-clean-architecture works
Project Type & Purpose
• This is a React Native mobile application scaffold with an emphasis on maintaining Clean Architecture principles.
• It leverages Expo for development (with different commands for web, Android, and iOS), and includes integration with external libraries such as Inversiland for dependency injection, MobX for state management, react-navigation for routing, and i18n for localization.
• The main goal of the project is to provide a well-structured, layered codebase with a clearly defined separation of concerns across Domain, Application, Infrastructure, and Presentation layers.
• Dependency Injection System (AppModule.ts): Acts as the root configuration for wiring together the various modules.
• Core Bounded Context ("core" directory):
• Domain Layer: Contains business rules, entities (see files in src/core/domain).
• Application Layer: Use cases (see src/core/application/UseCase.ts, etc.).
• Infrastructure Layer: Technical implementations such as the custom HttpClient.
• Presentation Layer: React Native code (components, hooks, navigation, i18n).
• Post Bounded Context ("post" directory):
• Domain Layer: PostEntity and post-related specifications.
• Application Layer: Use cases such as GetPostsUseCase and FindPostUseCase.
• Infrastructure Layer: Implementations like PostRepository.
• Presentation Layer: Screens, components, and state management stores for posts.
• Android (native project layer): Contains build configuration, native code setup, and resources.
• External Services & Libraries: Identify integrations for Expo, MobX, react-navigation, ESLint, Husky, CommitLint, etc.
Relationships & Interactions
• Directional data flow starting from the Presentation Layer, which handles the user interface (React Native screens, components, navigation) communicating with the Application Layer via use cases.
• The Application Layer (use cases and services) interacts with the Domain (business rules, entities) and Infrastructure (repository implementations, HTTP client).
• The Infrastructure Layer provides implementations of external integrations and technical details that serve both the Core and Post bounded contexts.
• The dependency injection container (AppModule.ts) ties together these somewhat independent modules by injecting the correct implementations into their respective consumers.
• The Android directory should be represented as the native platform-specific container for React Native, linking with resources and build configurations.
Architectural Patterns & Design Principles
• Clean Architecture/Onion Architecture: Illustrate the four layers (Domain, Application, Infrastructure, Presentation) ensuring that higher-level layers (Domain) are isolated from lower-level implementation details (Infrastructure).
• Bounded Contexts: Clearly separate “core” and “post” as different modules, each with its independent layers, yet integrated in the application via the dependency injection container.
• That core functionalities (e.g., localization, navigation, state management) are loosely coupled using libraries and custom hooks.
• To capture all essential architectural components and their interactions. Avoid oversimplification by listing each significant module rather than aggregating everything into one blob.
Happy diagramming!