# notionx/react-notion-x architecture

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

- Interactive diagram: https://gitdiagram.com/notionx/react-notion-x
- Repository: https://github.com/notionx/react-notion-x

## Overview

##### Main Components Structure

a) Core Packages Layer:
- notion-types (core TypeScript types)
- notion-utils (utility functions)
- notion-client (API client)
- react-notion-x (main renderer)

b) Integration Layer:
- This in the middle, showing how external frameworks connect:
- Next.js integration
- CRA (Create React App) integration
- Generic React integration

c) Optional Components Layer:
- As modular additions at the top:
- Code block renderer
- Collection views
- Equation renderer
- PDF viewer
- Modal system

##### Data Flow Representation

- API data flow from Notion's servers through notion-client
- Data transformation through notion-utils
- Rendering pipeline through react-notion-x
- Integration with framework-specific features

##### Component Relationships

Key interactions:
**Notion API → notion-client**
**↓**
**notion-types (shared types)**
**↓**
**notion-utils (data processing)**
**↓**
**react-notion-x (rendering)**
**↓**
**Framework Integration Layer**
**↓**
**Final Rendered Output**

##### Technical Details

Specifications:
- TypeScript integration points
- SSR capability markers
- Bundle size optimization points
- Third-party dependency connections
- API endpoints and interfaces

##### Implementation Notes

- Use standard UML notation where appropriate
- Clear boundaries between server-side and client-side components
- Performance optimization points
- Lazy-loaded boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Optional Components"
        CodeBlock["Code Block Renderer"]:::optional
        Collections["Collection Views"]:::optional
        Equation["Equation Renderer"]:::optional
        PDF["PDF Viewer"]:::optional
        Modal["Modal System"]:::optional
        
        subgraph "Collection Views"
            Board["Board View"]:::collection
            Gallery["Gallery View"]:::collection
            List["List View"]:::collection
            Table["Table View"]:::collection
        end
    end

    subgraph "Framework Integration"
        NextJS["Next.js Integration"]:::framework
        CRA["CRA Integration"]:::framework
        React["React Integration"]:::framework
    end

    subgraph "Core Rendering"
        BlockRenderer["Block Renderer"]:::core
        MainRenderer["Main Renderer"]:::core
        ContextProvider["Context Provider"]:::core
    end

    subgraph "Core Packages"
        Types["Core TypeScript Types"]:::core
        Utils["Utility Functions"]:::core
        Client["API Client"]:::core
        ReactNotion["react-notion-x"]:::core
    end

    NotionAPI["Notion API"]:::external

    NotionAPI --> Client
    Client --> Types
    Types --> Utils
    Utils --> ReactNotion
    ReactNotion --> BlockRenderer
    ReactNotion --> MainRenderer
    ReactNotion --> ContextProvider

    BlockRenderer --> NextJS
    BlockRenderer --> CRA
    BlockRenderer --> React

    MainRenderer --> CodeBlock
    MainRenderer --> Collections
    MainRenderer --> Equation
    MainRenderer --> PDF
    MainRenderer --> Modal

    Collections --> Board
    Collections --> Gallery
    Collections --> List
    Collections --> Table

    %% Click Events
    click Types "https://github.com/NotionX/react-notion-x/tree/master/packages/notion-types/src"
    click Utils "https://github.com/NotionX/react-notion-x/tree/master/packages/notion-utils/src"
    click Client "https://github.com/NotionX/react-notion-x/tree/master/packages/notion-client/src"
    click ReactNotion "https://github.com/NotionX/react-notion-x/tree/master/packages/react-notion-x/src"
    click NextJS "https://github.com/NotionX/react-notion-x/tree/master/examples/full"
    click CRA "https://github.com/NotionX/react-notion-x/tree/master/examples/cra"
    click React "https://github.com/NotionX/react-notion-x/tree/master/examples/minimal"
    click CodeBlock "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/code.tsx"
    click Collections "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/collection-view.tsx"
    click Equation "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/equation.tsx"
    click PDF "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/pdf.tsx"
    click Modal "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/modal.tsx"
    click Board "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/collection-view-board.tsx"
    click Gallery "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/collection-view-gallery.tsx"
    click List "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/collection-view-list.tsx"
    click Table "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/third-party/collection-view-table.tsx"
    click BlockRenderer "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/block.tsx"
    click MainRenderer "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/renderer.tsx"
    click ContextProvider "https://github.com/NotionX/react-notion-x/blob/master/packages/react-notion-x/src/context.tsx"

    %% Styling
    classDef core fill:#2196F3,color:white
    classDef framework fill:#4CAF50,color:white
    classDef optional fill:#FF9800,color:white
    classDef external fill:#9E9E9E,color:white
    classDef collection fill:#E91E63,color:white

    %% Legend
    subgraph Legend
        CoreLegend["Core Components"]:::core
        FrameworkLegend["Framework Integration"]:::framework
        OptionalLegend["Optional Components"]:::optional
        ExternalLegend["External Services"]:::external
        CollectionLegend["Collection Components"]:::collection
    end
```
