# kervisvasquez1993/ddd-moviedb-react architecture

> Architecture diagram of the GitHub repository kervisvasquez1993/ddd-moviedb-react, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kervisvasquez1993/ddd-moviedb-react
- Repository: https://github.com/kervisvasquez1993/ddd-moviedb-react

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level: React Native App Entry & Bundler
    subgraph "React Native App Entry"
        direction TB
        A1["index.js"]:::entry
        A2["App.tsx"]:::entry
    end

    B["Metro Bundler"]:::build

    %% Native Platforms
    subgraph "Native Platforms"
        direction TB
        C1["iOS Native Code"]:::native
        C2["Android Native Code"]:::native
    end

    %% JavaScript Code Layers
    subgraph "React Native Code"
        direction TB

        %% Presentation Layer
        subgraph "Presentation Layer"
            direction TB
            D1["Components"]:::presentation
            D2["HomeScreen.tsx"]:::presentation
            D3["DetailsScreen.tsx"]:::presentation
            D4["Navigation (StackNavigator.tsx)"]:::presentation
            D5["Hooks (useMovies.tsx)"]:::presentation
            D6["Themes (index.ts)"]:::presentation
        end

        %% Core / Domain Layer
        subgraph "Core/Domain Layer"
            direction TB
            E1["Entities"]:::core
            E2["Use Cases"]:::core
        end

        %% Infrastructure & Configuration Layer
        subgraph "Infrastructure & Config Layer"
            direction TB
            F1["Infrastructure Interfaces"]:::infra
            F2["Mappers"]:::infra
            F3["HTTP Adapters"]:::config
            F4["MovieDB Adapter"]:::config
        end
    end

    %% Testing and Build Tools
    G["Tests"]:::test
    H["Build & Linting Tools"]:::build

    %% Connections
    A1 --> A2
    A2 -->|"initializes"| B
    B -->|"loads UI"| D4
    D4 -->|"renders"| D2
    D4 --> D1
    D4 --> D3
    D2 -->|"user interaction"| D5
    D5 -->|"invokes"| E2
    E2 -->|"fetches data"| F3
    F3 --> F4
    F4 -->|"maps data"| F2
    F2 -->|"returns data"| E2
    E2 -->|"provides output"| D5
    D5 -->|"updates"| D2

    %% Native Bridges
    A2 -->|"bridges to"| C1
    A2 -->|"bridges to"| C2

    %% Additional connections
    B -->|"bundles code"| H
    H -->|"ensures quality"| G

    %% Click Events
    click A1 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/index.js"
    click A2 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/App.tsx"
    click B "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/metro.config.js"
    click C1 "https://github.com/kervisvasquez1993/ddd-moviedb-react/tree/main/ios/theMovieDB"
    click C2 "https://github.com/kervisvasquez1993/ddd-moviedb-react/tree/main/android/app/src/main/java/com/themoviedb"
    click D1 "https://github.com/kervisvasquez1993/ddd-moviedb-react/tree/main/src/presentation/components"
    click D2 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/presentation/screens/home/HomeScreen.tsx"
    click D3 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/presentation/screens/details/DetailsScreen.tsx"
    click D4 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/presentation/navigation/StackNavigator.tsx"
    click D5 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/presentation/hooks/useMovies.tsx"
    click D6 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/presentation/themes/index.ts"
    click E1 "https://github.com/kervisvasquez1993/ddd-moviedb-react/tree/main/src/core/entities"
    click E2 "https://github.com/kervisvasquez1993/ddd-moviedb-react/tree/main/src/core/use-cases/movies"
    click F1 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/infrastructure/interfaces/movie-db.responses.ts"
    click F2 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/infrastructure/mappers/movie.mapper.ts"
    click F3 "https://github.com/kervisvasquez1993/ddd-moviedb-react/tree/main/src/config/adapters/http"
    click F4 "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/src/config/adapters/movieDB.dapter.ts"
    click G "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/__tests__/App.test.tsx"
    click H "https://github.com/kervisvasquez1993/ddd-moviedb-react/blob/main/babel.config.js"

    %% Styles
    classDef entry fill:#ffebcd,stroke:#000,stroke-width:2px;
    classDef build fill:#fafad2,stroke:#000,stroke-width:2px;
    classDef native fill:#dda0dd,stroke:#000,stroke-width:2px;
    classDef presentation fill:#add8e6,stroke:#000,stroke-width:2px;
    classDef core fill:#90ee90,stroke:#000,stroke-width:2px;
    classDef infra fill:#f08080,stroke:#000,stroke-width:2px;
    classDef config fill:#ffb6c1,stroke:#000,stroke-width:2px;
    classDef test fill:#d3d3d3,stroke:#000,stroke-width:2px;
```
