# tldraw/make-real architecture

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

- Interactive diagram: https://gitdiagram.com/tldraw/make-real
- Repository: https://github.com/tldraw/make-real

## Overview

##### Main Components

A. Frontend Layer:
- Root Next.js Application
- Core UI Components (/app/components)
- Slides Feature (/app/Slides)
- Custom Hooks (/app/hooks)

B. API Layer:
- Multiple AI Service Integrations:
- OpenAI Integration (/api/openai)
- Anthropic Integration (/api/anthropic)
- Replit Integration (/api/replit)

C. Utility Layer:
- Helper Functions (/app/lib)
- Configuration Files

- [Client Layer] → [API Layer] → [External Services Layer]

##### Component Relationships to Highlight

- How the MakeRealButton component connects to the useMakeReal hook
- Flow from user input through the AI services
- Demonstrate the relationship between Slides and PreviewShape components
- How the link sharing functionality works across different routes

##### Core application container
- [Next.js Application Container]

##### Main frontend components
- [Components]
- MakeRealButton
- SettingsDialog
- Links
- Dropdown

##### Feature modules
- [Slides Feature]
- [PreviewShape Feature]

##### API layer
- [API Routes]
- /api/anthropic
- /api/openai
- /api/replit

##### Utility services
- [Utilities]
- Text Processing
- SVG Handling
- File Operations

##### Additional Elements

- Version information or compatibility notes
- Entry points for different user flows
- Error handling paths
- Data flow directions

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        NextApp["Next.js Application"]
        Components["Core UI Components"]
        SlidesFeature["Slides Feature"]
        PreviewFeature["Preview Shape Feature"]
        CustomHooks["Custom Hooks"]

        subgraph CoreComponents
            MakeReal["MakeRealButton"]:::component
            Settings["Settings Dialog"]:::component
            Links["Links"]:::component
            Dropdown["Dropdown"]:::component
        end

        subgraph SlidesComponents
            SlidesPanel["Slides Panel"]:::component
            ShapeTool["Shape Tool"]:::component
            SlidesHook["Slides Hook"]:::component
            SlideStyles["Slides Styling"]:::component
        end

        PreviewShape["Preview Shape"]:::component
        MakeRealHook["Make Real Hook"]:::component
    end

    subgraph APILayer
        OpenAI["OpenAI Integration"]:::api
        Anthropic["Anthropic Integration"]:::api
        Replit["Replit Integration"]:::api
    end

    subgraph UtilityLayer
        SVGProc["SVG Processing"]:::util
        TextProc["Text Processing"]:::util
        FileOps["File Operations"]:::util
        Config["Configuration"]:::util
        ThirdParty["Third-party Integration"]:::util
    end

    subgraph LinkSharing
        LinkComp["Link Component"]:::link
        URLButton["URL Button"]:::link
        LinkRoutes["Link Routes"]:::link
    end

    Components --> CoreComponents
    SlidesFeature --> SlidesComponents
    PreviewFeature --> PreviewShape
    CustomHooks --> MakeRealHook

    MakeReal --> MakeRealHook
    MakeRealHook --> APILayer
    PreviewShape --> SVGProc
    SlidesPanel --> TextProc
    LinkComp --> FileOps
    Settings --> Config

    classDef component fill:#3498db
    classDef api fill:#2ecc71
    classDef util fill:#95a5a6
    classDef link fill:#e67e22

    click MakeReal "https://github.com/tldraw/make-real/blob/main/app/components/MakeRealButton.tsx"
    click Settings "https://github.com/tldraw/make-real/blob/main/app/components/SettingsDialog.tsx"
    click Links "https://github.com/tldraw/make-real/blob/main/app/components/Links.tsx"
    click Dropdown "https://github.com/tldraw/make-real/blob/main/app/components/Dropdown.tsx"
    click SlidesPanel "https://github.com/tldraw/make-real/blob/main/app/Slides/SlidesPanel.tsx"
    click ShapeTool "https://github.com/tldraw/make-real/blob/main/app/Slides/SlideShapeTool.tsx"
    click SlidesHook "https://github.com/tldraw/make-real/blob/main/app/Slides/useSlides.tsx"
    click SlideStyles "https://github.com/tldraw/make-real/blob/main/app/Slides/slides.css"
    click PreviewShape "https://github.com/tldraw/make-real/blob/main/app/PreviewShape/PreviewShape.tsx"
    click MakeRealHook "https://github.com/tldraw/make-real/blob/main/app/hooks/useMakeReal.ts"
    click OpenAI "https://github.com/tldraw/make-real/blob/main/app/makereal.tldraw.com/api/openai/route.ts"
    click Anthropic "https://github.com/tldraw/make-real/blob/main/app/makereal.tldraw.com/api/anthropic/route.ts"
    click Replit "https://github.com/tldraw/make-real/blob/main/app/makereal.tldraw.com/api/replit/route.ts"
    click SVGProc "https://github.com/tldraw/make-real/blob/main/app/lib/addGridToSvg.ts"
    click TextProc "https://github.com/tldraw/make-real/blob/main/app/lib/getTextFromSelectedShapes.ts"
    click FileOps "https://github.com/tldraw/make-real/blob/main/app/lib/downloadDataUrlAsFile.ts"
    click Config "https://github.com/tldraw/make-real/blob/main/app/lib/settings.tsx"
    click ThirdParty "https://github.com/tldraw/make-real/blob/main/app/lib/third-parties.ts"
    click LinkComp "https://github.com/tldraw/make-real/blob/main/app/components/LinkComponent.tsx"
    click URLButton "https://github.com/tldraw/make-real/blob/main/app/components/UrlLinkButton.tsx"
    click LinkRoutes "https://github.com/tldraw/make-real/blob/main/app/makereal.tldraw.com/link/[id]/page.tsx"
```
