# tldraw/nextjs-template architecture

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

- Interactive diagram: https://gitdiagram.com/tldraw/nextjs-template
- Repository: https://github.com/tldraw/nextjs-template

## Overview

##### Project type and purpose
- This is a front‑end template project built with Next.js that demonstrates how to integrate the tldraw SDK into a modern React/Next.js application. It provides a minimal starting point for developers who want to embed a collaborative drawing canvas (tldraw) into a Next.js page.

##### File structure
- Top‑level files:
- package.json – dependency list (including @tldraw/tldraw, next, react, typescript)
- next.config.cjs – Next.js custom configuration
- tsconfig.json – TypeScript compiler settings
- eslint.config.mjs – linting rules
- README.md, LICENSE.md, .gitignore
- src/app directory (the new Next.js App Router):
- layout.tsx – root layout component
- page.tsx – the main page that mounts the tldraw canvas
- globals.css – shared CSS
- No separate backend directory; all code lives in the Next.js front‑end.

##### README for additional insights
- Confirms local development commands (`yarn dev`) and that the app runs on localhost:3000.
- Clarifies this is purely a front‑end integration and is delivered under MIT.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Developer["Developer"]:::external
    NPM["NPM Registry"]:::external
    BuildTool["Build Toolchain"]:::code
    Bundled["Bundled App"]:::code
    HOST["Hosting Platform"]:::external

    subgraph "Build & Config"
        TS["tsconfig.json"]:::config
        ESL["eslint.config.mjs"]:::config
        NEXTCFG["next.config.cjs"]:::config
        PKG["package.json"]:::config
        README["README.md"]:::config
        LICENSE["LICENSE.md"]:::config
    end

    subgraph "Runtime"
        NEXTJS["Next.js Server/Runtime"]:::framework
        subgraph "React UI"
            LAYOUT["layout.tsx"]:::code
            PAGE["page.tsx"]:::code
            STYLE["globals.css"]:::code
        end
    end

    TL["tldraw SDK"]:::framework

    Developer -->|installs deps from| NPM
    Developer -->|runs build via| BuildTool
    NPM -->|provides packages| BuildTool
    TS -->|configures build| BuildTool
    ESL -->|configures linting| BuildTool
    NEXTCFG -->|overrides defaults| BuildTool
    PKG -->|lists dependencies| BuildTool
    README -->|documents project| BuildTool
    LICENSE -->|licenses code| BuildTool
    BuildTool -->|produces| Bundled
    Bundled -->|deployed to| HOST
    HOST -->|serves| NEXTJS
    NEXTJS -->|renders| LAYOUT
    LAYOUT -->|wraps| PAGE
    LAYOUT -->|injects| STYLE
    PAGE -->|mounts| TL

    click NEXTJS "https://github.com/tldraw/nextjs-template/tree/main/src/app"
    click LAYOUT "https://github.com/tldraw/nextjs-template/blob/main/src/app/layout.tsx"
    click PAGE "https://github.com/tldraw/nextjs-template/blob/main/src/app/page.tsx"
    click STYLE "https://github.com/tldraw/nextjs-template/blob/main/src/app/globals.css"
    click TS "https://github.com/tldraw/nextjs-template/blob/main/tsconfig.json"
    click ESL "https://github.com/tldraw/nextjs-template/blob/main/eslint.config.mjs"
    click NEXTCFG "https://github.com/tldraw/nextjs-template/blob/main/next.config.cjs"
    click PKG "https://github.com/tldraw/nextjs-template/blob/main/package.json"
    click README "https://github.com/tldraw/nextjs-template/blob/main/README.md"
    click LICENSE "https://github.com/tldraw/nextjs-template/blob/main/LICENSE.md"

    classDef external fill:#9fdfbf,stroke:#333,stroke-width:1px
    classDef config   fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef code     fill:#afdafb,stroke:#333,stroke-width:1px
    classDef framework fill:#fdbf6f,stroke:#333,stroke-width:1px
```
