# favger/react-content-loader architecture

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

- Interactive diagram: https://gitdiagram.com/favger/react-content-loader
- Repository: https://github.com/favger/react-content-loader

## Overview

##### Project type and purpose
- This is an open-source UI component library (“react-content-loader”) that provides SVG-powered placeholder loading animations for both React DOM (web) and React Native.
- It exposes a core ContentLoader component, a set of built-in presets (Facebook, Instagram, Code, List, BulletList), and a custom mode API so consumers can craft arbitrary SVG skeleton screens.

##### File-structure analysis
- Top-level: project config and metadata (.eslintrc.json, .prettierrc.js, .travis.yml, package.json, rollup.config.js, tsconfig.*).
- docs & .storybook: configuration and source for the documentation site / storybook gallery.
- src/
- native/ – React Native implementation (ContentLoader.tsx, Svg.tsx, presets, tests).
- web/ – React DOM implementation (ContentLoader.tsx, Svg.tsx, presets, tests).
- shared/ – shared code (uid generator), plus any types.
- Each platform folder has its own index.ts → main entry, a local package.json in native to manage react-native-svg peer dependency.
- build pipeline: rollup.config.js generates separate bundles for web and native, producing minified UMD/Esm/CommonJS outputs.
- tests: jest.web.config.js and jest.native.config.js target each implementation, with __tests__ and snapshots alongside code.

##### README insights
- Describes dual-mode usage (import from 'react-content-loader' or '/native'), lists props & options, shows examples & CDN usage.
- Mentions dev scripts: build, dev (docz), test (TS checking, unit tests), storybook.

a. Main components
- Source modules (src/shared, src/web, src/native)
- Build & bundling (Rollup, Babel)
- Test harness (Jest configured per target)
- Documentation site (Docz + Storybook)
- CI pipeline (Travis CI integration)
- Published packages (NPM registry for web and native artifacts)
- External dependencies (React, react-native-svg)
b. Relationships & interactions
- src/shared is consumed by both web and native implementations.
- rollup.config.js reads src/web & src/native entry points, applies Babel/TypeScript transforms → emits dist/web/* & dist/native/*.
- jest.web.config.js & jest.native.config.js import built code (or raw TSX via Babel) for unit tests.
- .storybook loads web components from src/web to render examples; docs/index.stories.tsx wires both web & native presets.
- CI (Travis) orchestrates: npm run build → npm run test → npm run dev (docs smoke) → publishes to NPM on tags.
- Consumers import either “react-content-loader” (web) or “react-content-loader/native” (RN) from NPM.
c. Architectural patterns
- Monorepo-style split: one codebase, multiple platform targets.
- Single Responsibility: shared utilities isolated in shared/; platform specifics in web/ and native/.
- CI/CD pipeline enforces code quality (ESLint, Prettier, TS typing), testing, and automated releases.
d. Key technologies
- React & React Native (for rendering)
- react-native-svg (native SVG support)
- TypeScript (typed interfaces), Babel (JSX→JS)
- Rollup (bundle generation), Jest (testing)
- Storybook & Docz (component gallery & docs)
- Travis CI (continuous integration)

##### Final pointers
- Three outputs (web, native, docs) and their consumers.
- Don’t omit the shared/ layer—it’s the linchpin of code reuse.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD
    CI["Travis CI"]:::ci

    %% Source Modules
    subgraph "Source Modules"
        direction TB
        Shared["src/shared"]:::modules
        WebImpl["src/web"]:::modules
        NativeImpl["src/native"]:::modules
    end

    %% Shared Utilities
    UID["uid.ts"]:::modules
    Shared --> UID
    click UID "https://github.com/favger/react-content-loader/blob/master/src/shared/uid.ts"

    %% Web Implementation Details
    subgraph "Web Implementation"
        direction TB
        WebIndex["index.ts"]:::modules
        WebContentLoader["ContentLoader.tsx"]:::modules
        WebSvg["Svg.tsx"]:::modules
        subgraph "Presets"
            direction TB
            WS_Bullet["BulletListStyle.tsx"]:::modules
            WS_Code["CodeStyle.tsx"]:::modules
            WS_Facebook["FacebookStyle.tsx"]:::modules
            WS_Instagram["InstagramStyle.tsx"]:::modules
            WS_List["ListStyle.tsx"]:::modules
        end
    end
    WebImpl --> WebIndex
    WebImpl --> WebContentLoader
    WebImpl --> WebSvg
    WebImpl --> WS_Bullet
    WebImpl --> WS_Code
    WebImpl --> WS_Facebook
    WebImpl --> WS_Instagram
    WebImpl --> WS_List

    click WebIndex "https://github.com/favger/react-content-loader/blob/master/src/web/index.ts"
    click WebContentLoader "https://github.com/favger/react-content-loader/blob/master/src/web/ContentLoader.tsx"
    click WebSvg "https://github.com/favger/react-content-loader/blob/master/src/web/Svg.tsx"
    click WS_Bullet "https://github.com/favger/react-content-loader/blob/master/src/web/presets/BulletListStyle.tsx"
    click WS_Code "https://github.com/favger/react-content-loader/blob/master/src/web/presets/CodeStyle.tsx"
    click WS_Facebook "https://github.com/favger/react-content-loader/blob/master/src/web/presets/FacebookStyle.tsx"
    click WS_Instagram "https://github.com/favger/react-content-loader/blob/master/src/web/presets/InstagramStyle.tsx"
    click WS_List "https://github.com/favger/react-content-loader/blob/master/src/web/presets/ListStyle.tsx"

    %% Native Implementation Details
    subgraph "Native Implementation"
        direction TB
        NativeIndex["index.ts"]:::modules
        NativeContentLoader["ContentLoader.tsx"]:::modules
        NativeSvg["Svg.tsx"]:::modules
        subgraph "Presets"
            direction TB
            NS_Bullet["BulletListStyle.tsx"]:::modules
            NS_Code["CodeStyle.tsx"]:::modules
            NS_Facebook["FacebookStyle.tsx"]:::modules
            NS_Instagram["InstagramStyle.tsx"]:::modules
            NS_List["ListStyle.tsx"]:::modules
        end
    end
    NativeImpl --> NativeIndex
    NativeImpl --> NativeContentLoader
    NativeImpl --> NativeSvg
    NativeImpl --> NS_Bullet
    NativeImpl --> NS_Code
    NativeImpl --> NS_Facebook
    NativeImpl --> NS_Instagram
    NativeImpl --> NS_List

    click NativeIndex "https://github.com/favger/react-content-loader/blob/master/src/native/index.ts"
    click NativeContentLoader "https://github.com/favger/react-content-loader/blob/master/src/native/ContentLoader.tsx"
    click NativeSvg "https://github.com/favger/react-content-loader/blob/master/src/native/Svg.tsx"
    click NS_Bullet "https://github.com/favger/react-content-loader/blob/master/src/native/presets/BulletListStyle.tsx"
    click NS_Code "https://github.com/favger/react-content-loader/blob/master/src/native/presets/CodeStyle.tsx"
    click NS_Facebook "https://github.com/favger/react-content-loader/blob/master/src/native/presets/FacebookStyle.tsx"
    click NS_Instagram "https://github.com/favger/react-content-loader/blob/master/src/native/presets/InstagramStyle.tsx"
    click NS_List "https://github.com/favger/react-content-loader/blob/master/src/native/presets/ListStyle.tsx"

    %% Dependencies
    React["React"]:::external
    RNSVG["react-native-svg"]:::external
    React --> WebImpl
    RNSVG --> NativeImpl

    %% Build & Bundling
    Rollup["Rollup"]:::build
    click Rollup "https://github.com/favger/react-content-loader/blob/master/rollup.config.js"
    Babel["Babel (web)"]:::build
    click Babel "https://github.com/favger/react-content-loader/blob/master/babel.web.config.js"
    TSConfig["TypeScript Configs"]:::build
    click TSConfig "https://github.com/favger/react-content-loader/blob/master/tsconfig.json"
    click TSConfig "https://github.com/favger/react-content-loader/blob/master/tsconfig.base.json"
    click TSConfig "https://github.com/favger/react-content-loader/blob/master/tsconfig.test.json"

    WebImpl --> Shared
    NativeImpl --> Shared

    WebImpl --> Rollup
    NativeImpl --> Rollup
    Rollup -->|"bundle via Rollup"| Dist["dist/web & dist/native"]:::external

    Rollup --> Babel
    Rollup --> TSConfig

    %% Testing
    JestWeb["Jest (web)"]:::build
    JestNative["Jest (native)"]:::build
    click JestWeb "https://github.com/favger/react-content-loader/blob/master/jest.web.config.js"
    click JestNative "https://github.com/favger/react-content-loader/blob/master/jest.native.config.js"
    WebImpl --> JestWeb
    NativeImpl --> JestNative

    %% Documentation & Storybook
    subgraph "Docs & Storybook"
        direction TB
        Storybook["Storybook"]:::build
        click Storybook "https://github.com/favger/react-content-loader/blob/master/.storybook/config.js"
        click Storybook "https://github.com/favger/react-content-loader/blob/master/.storybook/webpack.config.js"
        click Storybook "https://github.com/favger/react-content-loader/blob/master/.storybook/addons.js"
        Docz["Docz Stories"]:::build
        click Docz "https://github.com/favger/react-content-loader/blob/master/docs/index.stories.tsx"
    end
    WebImpl --> Storybook
    WebImpl --> Docz

    %% CI/CD Orchestration
    CI -->|"run build"| Rollup
    CI -->|"run test"| JestWeb
    CI -->|"run test"| JestNative
    CI -->|"run docs"| Storybook
    CI -->|"publish on tag"| NPM

    %% Publishing & Consumers
    NPM["NPM Registry"]:::external
    CI --> NPM
    Dist --> NPM
    NPM --> Consumer["Consumer Apps"]:::external

    %% Styles
    classDef modules fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef build fill:#90EE90,stroke:#333,stroke-width:1px
    classDef ci fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:1px
```
