How kervisvasquez1993/ddd-moviedb-react works
Main Components
• Mobile Platform Layers:
• iOS: The “ios” folder holds all the native iOS code, Xcode project configurations, assets, and the app’s entry points (e.g., AppDelegate).
• Android: The “android” folder contains all native Android code, Gradle build scripts, configuration files, and source code (e.g., MainActivity.kt, MainApplication.kt).
• JavaScript/TypeScript Application Layers (Within “src”):
• Presentation Layer:
▫ Organized under “src/presentation” and further subdivided into components, screens, navigation, hooks, and themes. This layer represents the UI and user interaction logic, including the navigation stack (StackNavigator.tsx) and various screens (home, details).
• Core/Domain Layer:
▫ Present in “src/core” with entities and use-cases. This exemplifies Clean Architecture practices by isolating business logic. For example, use-cases for movies (now-playing, popular, top-rated, upcoming) and entities like movie.entity.ts.
• Infrastructure Layer:
▫ Found in “src/infrastructure”, includes interfaces (e.g., movie-db.responses.ts) and mappers (e.g., movie.mapper.ts). It handles data transformation and communication with external systems.
• Configuration Layer:
▫ Located in “src/config”, which includes HTTP adapters (e.g., axios.adapters.ts) and movieDB adapter indicating how external APIs or services are accessed.
• Testing:
• The “__tests__” folder includes tests (e.g., App.test.tsx) ensuring that components and business logic work as expected.
• Bundling/Build Tools:
• Metro bundler: With configurations such as metro.config.js and Babel (babel.config.js) for transpiling the code.
• Linting/Formatting: Files like .eslintrc.js, .prettierrc.js ensure code quality.
Flow and Interactions
• Application Entry Point:
• index.js serves as the entry script, which initializes the app by mounting App.tsx from “src/App.tsx.” Metro bundler plays a role in bundling and serving the JavaScript code.
• User Interactions & UI:
• The Presentation layer (screens, components, navigation) handles user inputs.
• Data flow flows from the UI layer into custom hooks, which then invoke use-case functions in the core layer.
• Business Logic:
• Use-cases encapsulate specific business rules (such as fetching “popular movies”) and interact with the infrastructure layer for API calls using the configured adapters.
• Data Integration:
• External services are accessed via HTTP adapters stored under “src/config/adapters/http” and using the movieDB adapter. The data fetched is processed using mappers in the “infrastructure/mappers” folder.
• Native Integrations:
• The native directories (ios and android) show how the React Native JavaScript code is integrated into respective mobile platforms, bridging the gap between native code and JavaScript runtime.
Architectural Patterns & Principles
• Clean Architecture or Layered Architecture:
• The separation into Presentation, Core, and Infrastructure indicates that the project is built with a clear separation of concerns.
• Adapter Pattern:
• Usage of HTTP adapters suggests that the project isolates the external API calls from the business logic, making it easier to swap out implementations if needed.
• Component-Based UI:
• The division of “src/presentation” into various components reinforces the component-based design typical in React Native apps.