# kentcdodds/react-fundamentals architecture

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

- Interactive diagram: https://gitdiagram.com/kentcdodds/react-fundamentals
- Repository: https://github.com/kentcdodds/react-fundamentals

## Overview

##### Project Type & Purpose
- This is a front-end–only tutorial/workshop repository built with Create React App.
- It provides a set of React exercises (`src/exercise`) alongside their final solutions (`src/final`), tests (`src/__tests__`), and helper scripts to set up, build, test, and deploy the workshop.

##### File Structure Analysis
- Top‐level directories:
- public/ – static assets & HTML shell
- src/ – React source, tests, styles, exercises & final solutions
- scripts/ – custom Node scripts (setup, pre-commit, update-deps, etc.)
- Config files:
- Dockerfile & docker-compose.yml – containerization for dev/test
- craco.config.js & sandbox.config.json – tooling overrides
- .github/workflows/validate.yml – CI lint/test pipeline
- Tooling: ESLint, Prettier, Gitpod, GitHub Actions, Netlify deploy hints

##### Key Components
A. Developer Environment
- Code Editor / IDE
- Local Node.js & npm
- Git client
- Optional: Docker & docker-compose
- Optional: Gitpod / GitHub Codespaces
B. Repository & CI/CD
- GitHub repo + branches
- GitHub Actions workflow (“validate.yml”)
- Netlify (or any static-site host) for deployment
C. Build & Dev Server
- react-scripts (webpack dev server, bundler)
- craco for config overrides
- mockServiceWorker for local mocking
D. Application
- public/index.html → React mount point
- src/index.js → React root
- src/exercise vs src/final – code variants
E. Test Runner
- Jest (npm test) + React Testing Library
- src/__tests__ → test suites
F. Supporting Scripts
- scripts/setup.js → initial project setup (npm install/config)
- scripts/pre-commit.js & pre-push.js → lint/test hooks
- scripts/update-deps → dependency management

##### Relationships & Data Flows
- Developer edits code in IDE → local file system
- Local code → react-scripts dev server → browser UI
- Code changes → hot reload → browser reflects updates
- Running tests → Jest picks up src/__tests__ and exercise files
- Git commit → pre-commit hook runs ESLint & tests → pushed to GitHub
- Push to GitHub → GitHub Actions CI runs lint + tests → status badge updated
- Merge to main → Netlify auto-deploy of built static site

##### Architectural Patterns & Principles
- Single‐Page Application (SPA)
- Convention over configuration (CRA defaults overridden by craco)
- GitOps for CI/CD (GitHub Actions + Netlify)
- Containerized dev environment (Docker + Gitpod)
- Modular exercise vs final solution separation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer Environment
    subgraph "Developer Environment"
        Developer["Developer"]:::devEnv
        IDE["IDE / Editor"]:::devEnv
        LocalNode["Local Node.js & npm"]:::devEnv
        GitClient["Git Client"]:::devEnv
        Docker["Docker & docker-compose"]:::devEnv
        Gitpod["Gitpod / Codespaces"]:::devEnv
        ScriptsSetup["scripts/setup.js"]:::devEnv
        HookPre["scripts/pre-commit.js & pre-push.js"]:::devEnv
        UpdateDeps["scripts/update-deps"]:::devEnv
        Fixers["scripts/fix-links & scripts/diff.js"]:::devEnv
    end

    %% Build & Dev Server
    subgraph "Build & Dev Server"
        ReactScripts["react-scripts (webpack dev server)"]:::runtime
        Craco["craco.config.js"]:::runtime
        MSW["public/mockServiceWorker.js"]:::runtime
        Browser["Browser UI"]:::runtime
    end

    %% Application Runtime
    subgraph "Application"
        HTML["public/index.html"]:::runtime
        Root["src/index.js"]:::runtime
        Styles["src/styles.css / box-styles.css"]:::runtime
        Exercises["src/exercise/*"]:::runtime
        Finals["src/final/*"]:::runtime
    end

    %% Test Runner
    subgraph "Test Runner"
        TestsSetup["src/setupTests.js"]:::runtime
        Tests["src/__tests__/*"]:::runtime
    end

    %% CI/CD
    subgraph "CI/CD & Hosting"
        GitHub["GitHub Repository"]:::ci
        Actions[".github/workflows/validate.yml"]:::ci
        ESLintConfig[".eslintrc, .prettierrc, .eslintignore, .prettierignore"]:::ci
        Redirects["public/_redirects"]:::ci
        Netlify["Netlify (Static Host)"]:::ci
    end

    %% Flows
    Developer --> IDE
    IDE --> LocalNode
    LocalNode --> ReactScripts
    LocalNode --> Tests
    IDE --> ReactScripts
    ReactScripts --> Browser
    ReactScripts --> HTML
    HTML --> Root
    Root --> Styles
    Root --> Exercises
    Root --> Finals

    IDE --> TestsSetup
    TestsSetup --> Tests

    Developer --> GitClient
    GitClient --> HookPre
    HookPre --> ESLintConfig
    HookPre --> Tests
    GitClient --> GitHub

    LocalNode -->|npm start| ReactScripts
    LocalNode -->|npm test| Tests

    GitHub --> Actions
    Actions --> ESLintConfig
    Actions --> Tests
    Actions -->|deploy| Netlify

    Developer --> Docker
    Developer --> Gitpod

    %% Click Events
    click Docker "https://github.com/kentcdodds/react-fundamentals/tree/main/Dockerfile"
    click Gitpod "https://github.com/kentcdodds/react-fundamentals/blob/main/.gitpod.yml"
    click Gitpod "https://github.com/kentcdodds/react-fundamentals/blob/main/sandbox.config.json"
    click Craco "https://github.com/kentcdodds/react-fundamentals/blob/main/craco.config.js"
    click MSW "https://github.com/kentcdodds/react-fundamentals/blob/main/public/mockServiceWorker.js"
    click HTML "https://github.com/kentcdodds/react-fundamentals/blob/main/public/index.html"
    click Root "https://github.com/kentcdodds/react-fundamentals/blob/main/src/index.js"
    click Styles "https://github.com/kentcdodds/react-fundamentals/blob/main/src/styles.css"
    click Styles "https://github.com/kentcdodds/react-fundamentals/blob/main/src/box-styles.css"
    click Exercises "https://github.com/kentcdodds/react-fundamentals/tree/main/src/exercise"
    click Finals "https://github.com/kentcdodds/react-fundamentals/tree/main/src/final"
    click TestsSetup "https://github.com/kentcdodds/react-fundamentals/blob/main/src/setupTests.js"
    click Tests "https://github.com/kentcdodds/react-fundamentals/tree/main/src/__tests__"
    click Actions "https://github.com/kentcdodds/react-fundamentals/blob/main/.github/workflows/validate.yml"
    click ESLintConfig "https://github.com/kentcdodds/react-fundamentals/blob/main/.eslintrc"
    click Redirects "https://github.com/kentcdodds/react-fundamentals/tree/main/public/_redirects"
    click ScriptsSetup "https://github.com/kentcdodds/react-fundamentals/blob/main/scripts/setup.js"
    click HookPre "https://github.com/kentcdodds/react-fundamentals/blob/main/scripts/pre-commit.js"
    click HookPre "https://github.com/kentcdodds/react-fundamentals/blob/main/scripts/pre-push.js"
    click UpdateDeps "https://github.com/kentcdodds/react-fundamentals/tree/main/scripts/update-deps"
    click Fixers "https://github.com/kentcdodds/react-fundamentals/tree/main/scripts/fix-links"
    click Fixers "https://github.com/kentcdodds/react-fundamentals/blob/main/scripts/diff.js"

    %% Styles
    classDef devEnv fill:#e0f7e9,stroke:#2e7d32,color:#2e7d32;
    classDef ci fill:#e3f2fd,stroke:#1976d2,color:#1976d2;
    classDef runtime fill:#fff3e0,stroke:#ef6c00,color:#ef6c00;
```
