# formidablelabs/victory-native-xl architecture

> Architecture diagram of the GitHub repository formidablelabs/victory-native-xl, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/formidablelabs/victory-native-xl
- Repository: https://github.com/formidablelabs/victory-native-xl

## Overview

Based on our analysis of the file tree and README, this project is a React Native charting library called “victory-native.” It is focused on providing high-performance charts by leveraging D3 for data visualization logic, Skia for graphics rendering, and React Native Reanimated for animations. The project is structured to serve as a reusable library with clear separations between core chart components (Cartesian, pie, and polar), shared utilities, hooks, and context providers. In addition, an example application demonstrates its usage, and a documentation/website folder (built with Docusaurus, as suggested by the website folder’s structure) provides user guidance.

##### Main Components
- Core Library (lib):
- This is where the main source code lives. It includes submodules:
▪ Cartesian Charts: Contains components (e.g., CartesianChart, Axis, Line, Bar, Area, etc.), contexts, hooks (e.g., useBarPath, useLinePath), and utility functions (scaling, transformations, etc.).
▪ Pie Charts: Includes components like PieChart, PieSlice, PieLabel, and supporting contexts and hooks.
▪ Polar Charts: Contains components such as PolarChart and its context.
▪ Shared and Utility Modules: Contains common hooks (e.g., useFunctionRef, useAnimatedPath) and utility functions (e.g., data transformation, path creation) that are used by the chart components.
- Example App:
- A demonstrative application that shows how the library can be integrated into a React Native project. It includes real usage of various charts, guide pages, and supplementary components like Buttons, Text, and form inputs.
- Website/Documentation:
- A documentation site built (likely with Docusaurus based on the file names) that includes docs for different chart types, guides, and example assets. This section shows how the library should be integrated and used.
- Build, CI, and Config:
- Directories like .github, changeset, and configuration files (babel, eslint, tsconfig) represent the project’s tooling. They ensure code quality, manage releases, and define build processes.
- External Dependencies and Peer Libraries:
- The README indicates required peer dependencies: React Native Reanimated, React Native Gesture Handler, and @shopify/react-native-skia. These external libraries are essential to the animation and rendering aspects of the charts.

##### Relationships and Interactions
- The core library (lib) is the heart of the project. Its submodules interact to produce the complete charting components. For example, the Cartesian module often interacts with shared hooks and utilities.
- The Example app is built on top of the core library, importing various components to demonstrate use cases.
- The Website/Documentation module explains how to use the library and might reference both source code components and guide examples.
- External dependencies (Reanimated, Skia, Gesture Handler) provide the lower-level functionality for animations and rendering that the chart components rely on.
- Build and CI components (GitHub workflows, changeset, etc.) manage testing, linting, and release management, indirectly supporting the architecture.

##### Architectural Patterns and Design Principles
- Modularization: The library is clearly divided into separate modules (Cartesian, pie, polar) to promote reusability and separation of concerns.
- Context Providers and Hooks: Use of React contexts and custom hooks indicates adherence to modern React principles such as composition and declarative state management.
- Separation of Core vs. Presentation: The design differentiates between raw chart logic (in lib) and presentation (demonstrated in the example app).
- High Performance: Integration with Skia and Reanimated underlines an emphasis on performance and smooth user interactions in React Native.

##### Additional Notes for the Principal Software Engineer
- Interplay between performance (via Skia and Reanimated) and the modular chart components, as this is the unique selling point of the library.
- Remember to capture the CI/build pipeline briefly, as it is vital for a maintainable, high-quality codebase even if it doesn’t directly affect runtime behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build, CI & Config
    A["Build, CI & Config"]:::ci

    %% Core Library Subgraph
    subgraph "Core Library (lib)"
        B1["Cartesian Charts"]:::core
        B2["Pie Charts"]:::core
        B3["Polar Charts"]:::core
        B4["Shared & Utilities"]:::core
    end

    %% Consumer / Documentation Layers
    C["Example App"]:::app
    D["Website/Documentation"]:::doc

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        E1["React Native Reanimated"]:::ext
        E2["React Native Gesture Handler"]:::ext
        E3["@shopify/react-native-skia"]:::ext
        E4["D3"]:::ext
    end

    %% Relationships
    A -->|"supports"| B4
    C -->|"uses"| B1
    D -->|"documents"| B1
    B1 -->|"uses"| B4
    B2 -->|"uses"| B4
    B3 -->|"uses"| B4
    B1 -->|"integrates"| E1
    B1 -->|"integrates"| E2
    B1 -->|"integrates"| E3
    B1 -->|"integrates"| E4

    %% Styles
    classDef core fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef app fill:#ABEBC6,stroke:#196F3D,stroke-width:2px;
    classDef doc fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef ci fill:#D5D8DC,stroke:#566573,stroke-width:2px;
    classDef ext fill:#F5CBA7,stroke:#D35400,stroke-width:2px;

    %% Click Events
    click A "https://github.com/formidablelabs/victory-native-xl/blob/main/.github"
    click B1 "https://github.com/formidablelabs/victory-native-xl/tree/main/lib/src/cartesian"
    click B2 "https://github.com/formidablelabs/victory-native-xl/tree/main/lib/src/pie"
    click B3 "https://github.com/formidablelabs/victory-native-xl/tree/main/lib/src/polar"
    click B4 "https://github.com/formidablelabs/victory-native-xl/tree/main/lib/src/shared"
    click C "https://github.com/formidablelabs/victory-native-xl/tree/main/example"
    click D "https://github.com/formidablelabs/victory-native-xl/tree/main/website"
```
