# facebook/create-react-app architecture

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

- Interactive diagram: https://gitdiagram.com/facebook/create-react-app
- Repository: https://github.com/facebook/create-react-app

## Overview

##### Project type and purpose
- This is an open-source monorepo tool (Create React App) for bootstrapping React single-page applications with zero build configuration.
- It provides a CLI (`create-react-app`), a core runtime (`react-scripts`), templates (`cra-template`, `cra-template-typescript`), presets/plugins (Babel, ESLint), supporting libraries (dev-utils, error-overlay), documentation (Docusaurus), tests, and CI/CD workflows.

##### File structure
- Top level: Lerna config (`lerna.json`), monorepo governance, CI/CD configs (`.github/workflows`, `netlify.toml`), task scripts.
- `/packages`: dozens of self-contained packages:
- CLI (`create-react-app`)
- Templates (`cra-template*`)
- Core runtime (`react-scripts`) with subfolders for webpack/Babel/Jest configs and scripts (`start`, `build`, `test`, `eject`)
- Supporting libs (`react-dev-utils`, `react-error-overlay`, presets, polyfills, plugins, ESLint config)
- `/docusaurus`: docs site source & config.
- `/tasks`: shell/js scripts for publishing, e2e tests, local registry.
- `/test`: test fixtures and integration tests.

##### README
- Explains purpose: hide build tools behind a single dependency (`react-scripts`), provide one-line project creation, support dev server, tests, build.
- Highlights “eject” feature to extract hidden configs.
- Outlines philosophies: one dependency, no config, no lock-in.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Monorepo & CI/CD Layer
    subgraph "Orchestration & CI/CD"
        direction TB
        Lerna["Lerna Monorepo\n(lerna.json)"]:::orchestration
        GHAC["GitHub Actions\n(.github/workflows)"]:::cicd
        Netlify["Netlify Deploy\n(netlify.toml)"]:::cicd
        Tasks["Custom Tasks\n(tasks)"]:::cicd
    end

    %% CLI Layer
    CreateReactApp["CLI: create-react-app"]:::orchestration

    %% Template Layer
    subgraph "Templates" 
        direction TB
        JS_Template["Template: cra-template"]:::generation
        TS_Template["Template: cra-template-typescript"]:::generation
    end

    %% Generated App
    GeneratedApp["Generated App\nUser Project"]:::runtime

    %% Core Runtime Layer
    subgraph "Core Runtime: react-scripts"
        direction TB
        ScriptsBin["Bin: react-scripts.js"]:::runtime
        Config["Config Folder"]:::runtime
        Scripts["Scripts (start/build/test/eject)"]:::runtime
        DefaultTemplate["Default App Template"]:::runtime
    end

    %% Support Libraries
    subgraph "Support Libraries"
        direction TB
        DevUtils["react-dev-utils"]:::runtime
        ErrorOverlay["react-error-overlay"]:::runtime
        BabelPreset["babel-preset-react-app"]:::runtime
        ESLintConfig["eslint-config-react-app"]:::runtime
        Polyfills["react-app-polyfill"]:::runtime
        AssetPlugin["babel-plugin-named-asset-import"]:::runtime
        BrowserGlobals["confusing-browser-globals"]:::runtime
    end

    %% Docs & Tests
    subgraph "Documentation & Testing"
        direction TB
        DocsSite["Docusaurus Site\ndocusaurus"]:::docs
        DocsConfig["Docs Config\n(website)"]:::docs
        TestHarness["Test Harness\ntest"]:::docs
    end

    %% Relationships
    Lerna -->|orchestrates| CreateReactApp
    Lerna -->|manages| JS_Template
    Lerna -->|manages| TS_Template
    Lerna -->|manages| Config
    Lerna -->|manages| ScriptsBin
    Lerna -->|manages| DevUtils
    Lerna -->|manages| ErrorOverlay
    Lerna -->|manages| BabelPreset
    Lerna -->|manages| ESLintConfig
    Lerna -->|manages| Polyfills
    Lerna -->|manages| AssetPlugin
    Lerna -->|manages| BrowserGlobals
    Lerna -->|manages| DocsSite
    Lerna -->|manages| Tasks

    GHAC -->|runs tests| TestHarness
    GHAC -->|builds docs| DocsSite
    Netlify -->|deploys docs| DocsSite
    Tasks -->|e2e & publish| TestHarness

    CreateReactApp -->|reads| JS_Template
    CreateReactApp -->|reads| TS_Template
    JS_Template -->|generates| GeneratedApp
    TS_Template -->|generates| GeneratedApp

    GeneratedApp -->|depends on| ScriptsBin
    GeneratedApp -->|runs| Scripts

    Scripts -->|loads configs| Config
    Scripts -->|uses| DevUtils
    Scripts -->|uses| ErrorOverlay
    Scripts -->|applies| BabelPreset
    Scripts -->|applies| ESLintConfig
    Scripts -->|includes| Polyfills
    Scripts -->|uses| AssetPlugin
    Scripts -->|ignores| BrowserGlobals

    Config -->|provides webpack/babel/jest| Scripts

    Scripts -->|ejects configs| DefaultTemplate

    DocsSite -->|configured by| DocsConfig

    TestHarness -->|tests| GeneratedApp

    %% Click Events
    click Lerna "https://github.com/facebook/create-react-app/blob/main/lerna.json"
    click CreateReactApp "https://github.com/facebook/create-react-app/tree/main/packages/create-react-app"
    click JS_Template "https://github.com/facebook/create-react-app/tree/main/packages/cra-template"
    click TS_Template "https://github.com/facebook/create-react-app/tree/main/packages/cra-template-typescript"
    click ScriptsBin "https://github.com/facebook/create-react-app/blob/main/packages/react-scripts/bin/react-scripts.js"
    click Config "https://github.com/facebook/create-react-app/tree/main/packages/react-scripts/config"
    click Scripts "https://github.com/facebook/create-react-app/tree/main/packages/react-scripts/scripts"
    click DefaultTemplate "https://github.com/facebook/create-react-app/tree/main/packages/react-scripts/template"
    click DevUtils "https://github.com/facebook/create-react-app/tree/main/packages/react-dev-utils"
    click ErrorOverlay "https://github.com/facebook/create-react-app/tree/main/packages/react-error-overlay"
    click BabelPreset "https://github.com/facebook/create-react-app/tree/main/packages/babel-preset-react-app"
    click ESLintConfig "https://github.com/facebook/create-react-app/tree/main/packages/eslint-config-react-app"
    click Polyfills "https://github.com/facebook/create-react-app/tree/main/packages/react-app-polyfill"
    click AssetPlugin "https://github.com/facebook/create-react-app/tree/main/packages/babel-plugin-named-asset-import"
    click BrowserGlobals "https://github.com/facebook/create-react-app/tree/main/packages/confusing-browser-globals"
    click DocsSite "https://github.com/facebook/create-react-app/tree/main/docusaurus"
    click DocsConfig "https://github.com/facebook/create-react-app/tree/main/docusaurus/website"
    click GHAC "https://github.com/facebook/create-react-app/tree/main/.github/workflows"
    click Netlify "https://github.com/facebook/create-react-app/blob/main/netlify.toml"
    click Tasks "https://github.com/facebook/create-react-app/tree/main/tasks"
    click TestHarness "https://github.com/facebook/create-react-app/tree/main/test"

    %% Styles
    classDef orchestration fill:#f6c,stroke:#333,stroke-width:1px;
    classDef generation fill:#6f6,stroke:#333,stroke-width:1px;
    classDef runtime fill:#6cf,stroke:#333,stroke-width:1px;
    classDef docs fill:#ccc,stroke:#333,stroke-width:1px;
    classDef cicd fill:#c6f,stroke:#333,stroke-width:1px;
```
