# saujanmgr/react-native-fast-image architecture

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

- Interactive diagram: https://gitdiagram.com/saujanmgr/react-native-fast-image
- Repository: https://github.com/saujanmgr/react-native-fast-image

## Overview

This is a React Native FastImage implementation for OpenHarmony. An application supplies image props to the React wrapper, which sends them to the native view; the native view resolves sources and coordinates asynchronous remote loading. The loader fetches and decodes images, uses memory and disk caches, and reports downloaded-file updates back across the C++/ArkTS bridge. The package also exposes image sizing, prefetch/cache queries, cache clearing, load events, and image styling. Relationships are limited to those shown in excerpts or the source index; unsampled native details are not expanded.

Main entry points: [`harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp`](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp) (View Instance), [`harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts`](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts) (Remote Loader), [`harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts`](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts) (Image Loader Module), [`harmony/fast_image/src/main/cpp/FastImageLoaderTurboModule.h`](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageLoaderTurboModule.h) (Source Resolver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_react["React API"]
  node_wrapper["FastImage API<br/>[index.tsx]"]
  node_native_component["Native View Spec"]
end

subgraph group_native["Native View"]
  node_native_view["View Instance"]
  node_image_node["Image Node<br/>[FastImageNode.cpp]"]
  node_source_uri["Source URI<br/>[Uri.cpp]"]
  node_source_resolver["Source Resolver"]
  node_events["Load Events<br/>[EventEmitters.cpp]"]
  node_color["Color Utilities<br/>[Color.cpp]"]
end

subgraph group_loading["Image Loading"]
  node_remote_loader["Remote Loader"]
  node_remote_source["Decoded Image Source"]
  node_memory_cache[("Memory Cache")]
  node_disk_cache[("Disk Cache")]
end

subgraph group_bridge["TurboModule Bridge"]
  node_loader_module["Image Loader Module"]
  node_view_module["View Cache Module"]
  node_package["TurboModule Package"]
end

node_app(("Application"))
node_http["HTTP Fetch"]

node_app -->|"sets image props"| node_wrapper
node_wrapper -->|"renders"| node_native_component
node_native_view -->|"updates"| node_image_node
node_native_view -->|"parses source"| node_source_uri
node_native_view -->|"resolves remote source"| node_source_resolver
node_native_view -.->|"emits events"| node_events
node_loader_module -->|"loads image"| node_remote_loader
node_remote_loader -->|"fetches data"| node_http
node_remote_loader -->|"checks cache"| node_memory_cache
node_remote_loader -->|"reads and writes"| node_disk_cache
node_remote_loader -->|"creates source"| node_remote_source
node_loader_module -->|"posts source updates"| node_source_resolver
node_source_resolver -->|"receives source messages"| node_loader_module
node_view_module -->|"clears caches"| node_loader_module
node_package -->|"registers module"| node_loader_module
node_package -->|"registers module"| node_view_module
node_native_view -->|"uses color parsing"| node_color

click node_wrapper "https://github.com/saujanmgr/react-native-fast-image/blob/sig/src/index.tsx"
click node_native_component "https://github.com/saujanmgr/react-native-fast-image/blob/sig/src/FastImageViewNativeComponent.ts"
click node_native_view "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp"
click node_image_node "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageNode.cpp"
click node_source_uri "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/Uri.cpp"
click node_source_resolver "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageLoaderTurboModule.h"
click node_events "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/EventEmitters.cpp"
click node_loader_module "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts"
click node_view_module "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/RNCFastImageViewTurboModule.ts"
click node_remote_loader "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts"
click node_remote_source "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageSource.ts"
click node_memory_cache "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageCache.ts"
click node_disk_cache "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageDiskCache.ts"
click node_package "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastImagePackage.ts"
click node_color "https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/colorUtils/Color.cpp"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_wrapper,node_native_component toneBlue
class node_native_view,node_image_node,node_source_uri,node_source_resolver,node_events,node_color toneAmber
class node_remote_loader,node_remote_source,node_memory_cache,node_disk_cache toneMint
class node_loader_module,node_view_module,node_package toneRose
class node_app,node_http toneIndigo
```

## Components

### React API

- [FastImage API](https://github.com/saujanmgr/react-native-fast-image/blob/sig/src/index.tsx): `src/index.tsx`
- [Native View Spec](https://github.com/saujanmgr/react-native-fast-image/blob/sig/src/FastImageViewNativeComponent.ts): `src/FastImageViewNativeComponent.ts`

### Native View

- [View Instance](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp): `harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp`
- [Image Node](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageNode.cpp): `harmony/fast_image/src/main/cpp/FastImageNode.cpp`
- [Source URI](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/Uri.cpp): `harmony/fast_image/src/main/cpp/Uri.cpp`
- [Source Resolver](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/FastImageLoaderTurboModule.h): `harmony/fast_image/src/main/cpp/FastImageLoaderTurboModule.h`
- [Load Events](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/EventEmitters.cpp): `harmony/fast_image/src/main/cpp/EventEmitters.cpp`
- [Color Utilities](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/cpp/colorUtils/Color.cpp): `harmony/fast_image/src/main/cpp/colorUtils/Color.cpp`

### Image Loading

- [Remote Loader](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts): `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts`
- [Decoded Image Source](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageSource.ts): `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageSource.ts`
- [Memory Cache](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageCache.ts): `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageCache.ts`
- [Disk Cache](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageDiskCache.ts): `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageDiskCache.ts`

### TurboModule Bridge

- [Image Loader Module](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts): `harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts`
- [View Cache Module](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/RNCFastImageViewTurboModule.ts): `harmony/fast_image/src/main/ets/RNCFastImageViewTurboModule.ts`
- [TurboModule Package](https://github.com/saujanmgr/react-native-fast-image/blob/sig/harmony/fast_image/src/main/ets/FastImagePackage.ts): `harmony/fast_image/src/main/ets/FastImagePackage.ts`

### Other components

- **Application**
- **HTTP Fetch**

## Connections

- Application → FastImage API: sets image props (evidence: `src/index.tsx`)
- FastImage API → Native View Spec: renders (evidence: `src/index.tsx`)
- View Instance → Image Node: updates (evidence: `harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp`)
- View Instance → Source URI: parses source (evidence: `harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp`)
- View Instance → Source Resolver: resolves remote source (evidence: `harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp`)
- View Instance → Load Events: emits events
- Image Loader Module → Remote Loader: loads image (evidence: `harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts`)
- Remote Loader → HTTP Fetch: fetches data (evidence: `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts`)
- Remote Loader → Memory Cache: checks cache (evidence: `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts`)
- Remote Loader → Disk Cache: reads and writes (evidence: `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts`)
- Remote Loader → Decoded Image Source: creates source (evidence: `harmony/fast_image/src/main/ets/FastRemoteImageLoader/RemoteImageLoader.ts`)
- Image Loader Module → Source Resolver: posts source updates (evidence: `harmony/fast_image/src/main/ets/FastImageLoaderTurboModule.ts`)
- Source Resolver → Image Loader Module: receives source messages (evidence: `harmony/fast_image/src/main/cpp/FastImageLoaderTurboModule.h`)
- View Cache Module → Image Loader Module: clears caches (evidence: `harmony/fast_image/src/main/ets/RNCFastImageViewTurboModule.ts`)
- TurboModule Package → Image Loader Module: registers module (evidence: `harmony/fast_image/src/main/ets/FastImagePackage.ts`)
- TurboModule Package → View Cache Module: registers module (evidence: `harmony/fast_image/src/main/ets/FastImagePackage.ts`)
- View Instance → Color Utilities: uses color parsing (evidence: `harmony/fast_image/src/main/cpp/FastImageViewComponentInstance.cpp`)
