# dream-sports-labs/react-native-fast-image architecture

> Architecture diagram of the GitHub repository dream-sports-labs/react-native-fast-image, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dream-sports-labs/react-native-fast-image
- Repository: https://github.com/dream-sports-labs/react-native-fast-image

## Overview

##### Main Components
- JavaScript/React Native Layer:
- The src directory holds the main JS code (e.g., FastImageViewNativeComponent, index.tsx) that bridges React Native’s Image API to the native implementations.
- The API exposes static methods (preload, clearMemoryCache, clearDiskCache) and properties used by client code.
- Native Modules:
- iOS Component: The ios folder contains native Objective-C/Swift code (headers and implementation files like FFFastImageView, FFFastImageSource, and the manager classes) that interface with SDWebImage.
- Android Component: The android folder (and additional Android implementation within ReactNativeFastImageExample and separate native code in android/src) contains Java and Kotlin files (e.g., FastImageGlideModule, FastImageViewModuleImplementation) that interface with Glide and also support new architecture patterns for TurboModules and Fabric.
- Example Implementations:
- ReactNativeFastImageExample: A complete React Native project that demonstrates integration of the FastImage component, including platform-specific setups for iOS and Android.
- ReactNativeFastImageExampleServer: A lightweight Node.js server used to serve image resources in demonstrations.
- Supporting and Configuration Infrastructure:
- Build, linting, and CI/CD configurations (various files under .github, build.gradle files, babel.config, jest.config, etc.).
- Documentation and guides (docs folder) that explain integration details, troubleshooting, and advanced configurations (like using Glide’s AppGlideModule).

##### Relationships and Interactions
- The JS Layer (React component) calls the FastImage API methods and renders the image.
- Under the hood, the JavaScript bridge communicates with the respective native modules for iOS and Android.
- The native modules then use their platform-specific libraries (SDWebImage or Glide) for image fetching, caching, and performance enhancements.
- The new RN architecture elements (TurboModules/Fabric Renderer) are integrated within the native module registration and communication.
- Example applications consume the library to demonstrate real-world usage of these interactions.

##### Architectural Patterns and Design Principles
- Bridging: A clear separation exists between the JavaScript abstraction (the drop-in image component) and native implementations. The native bridging abstracts caching and loading operations.
- Platform-Specific Modules: Android and iOS code bases are separated, ensuring that each uses its best practices and native libraries.
- Compatibility with New Architecture: Support for TurboModules and Fabric indicates the use of advanced RN architectural patterns.
- Modular and Extensible: The project is organized into discrete directories (src, ios, android, examples) that allow for focused development and testing.

- “React Native JS Layer” (inside show the FastImage API, view components, utility functions).
- “Native iOS Module” (list key classes like FFFastImageView, FFFastImageSource, and dependency on SDWebImage).
- “Native Android Module” (include classes like FastImageGlideModule, FastImageViewModuleImplementation and mention Glide integration).
- “Example Applications” (ReactNativeFastImageExample and ExampleServer).
- “CI/CD & Development Tools” (GitHub workflows, build scripts, configuration files for ESLint, Babel, Jest, etc.).
- Data flow from the React Native JS Layer to the Native Modules.
- The connection from the native modules to the underlying image caching libraries.
- How the example applications utilize the overall library via the exposed API.
c. Annotations or callouts specifying that:
- The architecture leverages separate pipelines for platform-specific code.
- Integration points exist for new RN architecture (TurboModules and Fabric).
- Distinguish between UI/JS components, native modules, external libraries (SDWebImage/Glide), and configuration/deployment artifacts.

## Diagram (Mermaid)

```mermaid
graph TD
    %% React Native JS Layer
    subgraph "React Native JS Layer"
        JS1["FastImage API"]:::js
    end

    %% Native Modules
    subgraph "Native Modules"
        subgraph "Native iOS Module"
            IOS1["FFFastImageView (SDWebImage)"]:::ios
            IOS2["FFFastImageSource"]:::ios
            IOS1 -->|"integrates"| IOS2
        end
        subgraph "Native Android Module"
            AND1["FastImageGlideModule (Glide)"]:::android
            AND2["FastImageViewModuleImplementation"]:::android
            AND1 -->|"registers"| AND2
        end
    end

    %% External Libraries
    SD["SDWebImage"]:::ext
    GL["Glide"]:::ext

    %% New RN Architecture Components
    RNArch["TurboModules/Fabric"]:::arch

    %% Example Applications
    subgraph "Example Applications"
        EX1["ReactNativeFastImageExample"]:::example
        EX2["ReactNativeFastImageExampleServer"]:::example
    end

    %% CI/CD & Development Tools
    CICD["GitHub Workflows & Build Scripts"]:::cicd

    %% Relationships
    JS1 -->|"bridges"| IOS1
    JS1 -->|"bridges"| AND1
    IOS1 -->|"uses"| SD
    AND1 -->|"uses"| GL
    RNArch -->|"integrates with"| IOS1
    RNArch -->|"integrates with"| AND1
    EX1 -->|"consumes"| JS1
    EX2 -->|"consumes"| JS1
    CICD -.->|"configures"| JS1
    CICD -.->|"configures"| IOS1
    CICD -.->|"configures"| AND1

    %% Click Events
    click JS1 "https://github.com/dream-sports-labs/react-native-fast-image/blob/main/src/FastImageViewNativeComponent.ts"
    click IOS1 "https://github.com/dream-sports-labs/react-native-fast-image/blob/main/ios/FastImage/FFFastImageView.h"
    click IOS2 "https://github.com/dream-sports-labs/react-native-fast-image/blob/main/ios/FastImage/FFFastImageSource.mm"
    click AND1 "https://github.com/dream-sports-labs/react-native-fast-image/blob/main/android/src/main/java/com/dylanvann/fastimage/FastImageGlideModule.java"
    click AND2 "https://github.com/dream-sports-labs/react-native-fast-image/blob/main/android/src/main/java/com/dylanvann/fastimage/FastImageViewModuleImplementation.java"
    click EX1 "https://github.com/dream-sports-labs/react-native-fast-image/tree/main/ReactNativeFastImageExample/"
    click EX2 "https://github.com/dream-sports-labs/react-native-fast-image/tree/main/ReactNativeFastImageExampleServer/"
    click CICD "https://github.com/dream-sports-labs/react-native-fast-image/tree/main/.github/"

    %% Styles
    classDef js fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef ios fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef android fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef example fill:#D5F5E3,stroke:#145A32,stroke-width:2px;
    classDef cicd fill:#D6EAF8,stroke:#2874A6,stroke-width:2px;
    classDef ext fill:#E8DAEF,stroke:#6C3483,stroke-width:2px,stroke-dasharray: 5 5;
    classDef arch fill:#FAD7A0,stroke:#CA6F1E,stroke-width:2px,stroke-dasharray: 3 3;
```
