# web-slate/react-chef architecture

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

- Interactive diagram: https://gitdiagram.com/web-slate/react-chef
- Repository: https://github.com/web-slate/react-chef

## Overview

##### Project Type & Purpose
- This is an open-source Node.js CLI tool (npm module) that scaffolds React boilerplates (“react-chef”).
- It prescribes best practices by shipping multiple “recipes” (basic, slim, twixtui)—each containing config, snippet templates, and install logic—and generates a ready-to-run React app.

##### File Structure Analysis
- Top-level entry:
- index.js – the CLI entrypoint
- recipes/ – recipe definitions (config.js, snippets folder)
- utils.js, moduleMatrix.js, install.js – shared utilities for file operations, recipe dispatch, and dependency installation
- .circleci/, package.json, .gitignore, README.md – CI, metadata, docs
- Under each recipe:
- config.js – description of prompts, ports, dependency lists
- snippets/ – raw template files (JSX sources, webpack configs, env files, etc.)

##### Core Components
a. CLI Frontend
- index.js (parses CLI args, selects recipe)
- moduleMatrix.js (maps projectType → recipe module)
b. Recipe Modules
- recipes/basic, recipes/slim, recipes/twixtui
- each exposes: config, snippet directory, install logic
c. Template Engine / File Generator
- utils.js & install.js orchestrate copying snippet files into a new project folder, applying file renames, running any text interpolation
d. Dependency Installer
- uses Node’s child_process (npm install) to fetch dependencies/devDependencies listed in config.js
e. External Services & Resources
- npm registry (for react, webpack, loaders, etc.)
- File system of the user’s machine (writes scaffolding code)

##### Relationships & Data Flow
1. User invokes `npx react-chef <project-name> --type slim`
2. index.js
–→ reads moduleMatrix to resolve the “slim” recipe
3. Recipe Module
–→ reads config.js (port, deps)
–→ points to snippet folder
4. File Generator
–→ scans snippets, copies files into new project tree under `<project-name>`
–→ writes boilerplate (src/, public/, webpack.config.js, env files)
5. Installer
–→ spawns `npm install` for runtime + devDependencies from recipe config
6. End result
–→ directory structure with React app, ready for `npm run dev`

##### Architectural Patterns & Principles
- Plugin-like recipe modules: easy to add/override recipes
- Single-responsibility: index.js (CLI parsing), moduleMatrix (lookup), utils.js (FS ops), install.js (dependency management)
- Convention over configuration: snippet folder structure dictates final app layout

##### Relevant Technologies & Libraries
- Node.js core: fs, path, child_process
- npm / npx for execution & package install
- Webpack + Babel (in generated apps, not the CLI itself)
- json files (.babelrc, .eslintrc, webpack.config.js) live in snippets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Invocation
    User["User"]:::external
    User -->|"npx react-chef <project> --type"| CLI

    %% CLI Layer
    subgraph "CLI Layer"
        CLI["CLI Entrypoint\nindex.js"]:::core
        MM["Recipe Resolver\nmoduleMatrix.js"]:::core
        RIndex["Recipe Registry\nrecipes/index.js"]:::core
    end

    CLI -->|parses args| MM
    MM -->|resolves recipe| RIndex

    %% Recipe Modules
    subgraph "Recipe Modules"
        subgraph basic
            BasicCfg["Config\nbasic/config.js"]:::recipe
            BasicSnip["Snippets\nbasic/snippets/"]:::recipe
        end
        subgraph slim
            SlimCfg["Config\nslim/config.js"]:::recipe
            SlimSnip["Snippets\nslim/snippets/"]:::recipe
        end
        subgraph twixtui
            TwixtCfg["Config\ntwixtui/config.js"]:::recipe
            TwixtSnip["Snippets\ntwixtui/snippets/"]:::recipe
        end
    end

    RIndex -->|loads module| BasicCfg
    RIndex -->|loads module| SlimCfg
    RIndex -->|loads module| TwixtCfg

    BasicCfg -->|points to| BasicSnip
    SlimCfg -->|points to| SlimSnip
    TwixtCfg -->|points to| TwixtSnip

    %% Generator and Installer
    subgraph "Engine"
        Utils["Template Engine\nutils.js"]:::core
        Install["Dependency Installer\ninstall.js"]:::core
    end

    RIndex -->|provides config & snippets| Utils
    BasicSnip --> Utils
    SlimSnip --> Utils
    TwixtSnip --> Utils

    Utils -->|writes files| FS["File System"]:::fs
    Utils --> Install
    Install -->|npm install deps| NPM["npm Registry"]:::external

    %% CI and Docs
    subgraph "Project Metadata"
        CI["CI Config\n.circleci/config.yml"]:::fs
        PKG["package.json"]:::fs
        README["README.md"]:::fs
    end

    %% Styling
    classDef core fill:#D6E4FF,stroke:#1E40AF
    classDef recipe fill:#D1FAE5,stroke:#065F46
    classDef fs fill:#F3F4F6,stroke:#4B5563
    classDef external fill:#FFEDD5,stroke:#C2410C

    %% Click Events
    click CLI "https://github.com/web-slate/react-chef/blob/main/index.js"
    click MM "https://github.com/web-slate/react-chef/blob/main/recipes/moduleMatrix.js"
    click RIndex "https://github.com/web-slate/react-chef/blob/main/recipes/index.js"
    click BasicCfg "https://github.com/web-slate/react-chef/blob/main/recipes/basic/config.js"
    click BasicSnip "https://github.com/web-slate/react-chef/tree/main/recipes/basic/snippets/"
    click SlimCfg "https://github.com/web-slate/react-chef/blob/main/recipes/slim/config.js"
    click SlimSnip "https://github.com/web-slate/react-chef/tree/main/recipes/slim/snippets/"
    click TwixtCfg "https://github.com/web-slate/react-chef/blob/main/recipes/twixtui/config.js"
    click TwixtSnip "https://github.com/web-slate/react-chef/tree/main/recipes/twixtui/snippets/"
    click Utils "https://github.com/web-slate/react-chef/blob/main/utils.js"
    click Install "https://github.com/web-slate/react-chef/blob/main/recipes/install.js"
    click CI "https://github.com/web-slate/react-chef/blob/main/.circleci/config.yml"
    click PKG "https://github.com/web-slate/react-chef/blob/main/package.json"
    click README "https://github.com/web-slate/react-chef/blob/main/README.md"
```
