How punchbat/react-boilerplate-cra-template works
Project type & purpose
• This is a CRA template (npm package cra-template-rb) that bootstraps a React + TypeScript + Redux + Saga + i18n + styled-components project.
• It also contains internal scripts and Plop generators for quick scaffolding of components, routes, slices, sagas, tests, etc.
File structure
• internals/ – Node-based CLI scripts, Plop generators, message extraction pipeline, starter-template source.
• public/ + src/ – the “startingTemplate” (and what ends up in a user’s new app). Inside src:
– app/components, pages (Home, NotFound), features (RepoForm, ThemeSwitch, LanguageSwitch)
– store (Redux Toolkit + sagas)
– locales (i18n via i18next)
– styles (styled-components, ThemeProvider, globals)
– utils (loadable, message handling, redux-injectors, HTTP requests)
– tests co-located with code
• .github/workflows/ – CI (build, lint, test, release)
• Root scripts/configs – ESLint, Prettier, Husky, commitlint, TypeScript config, release tooling
Key insights from README
• best DX: hot reload, lint/format on-save, high test coverage
• Predictable state: Redux + redux-saga + Redux Toolkit + selectors
• Next-gen CSS: styled-components, theming, co-located styles
• Routing: react-router
• i18n: i18next + JSON translation files
• CLI scaffolding: yarn create react-app --template cra-template-rb + yarn cleanAndSetup
Main components & their relationships
a. Developer/Consumer
– invokes:
• create-react-app --template cra-template-rb
• internal scripts (cleanAndSetup, create-cra-app.script.ts, etc.)
b. Template Package (npm)
– contains internals/ and startingTemplate/
– on install: runs create-cra-app script → copies startingTemplate into new project → sets up configs, dependencies
c. Code-gen & Extraction Pipeline
– Plop Generators (component, slice)
– extractMessages (i18next scanner)
– scripts/ for changelog, publishing, verifying template
d. Generated Application
– public/ (index.html, manifest, robots.txt)
– src/:
• app (layout, NavBar, PageWrapper)
• pages (HomePage, NotFoundPage)
• features (Redux slices & sagas under pages)
• store (rootReducer, configureStore)
• locales (en/de JSON + i18n setup)
• styles (global, theme provider, constants)
• utils (code splitting, HTTP requests, redux injectors)
• tests (co-located Jest + React Testing Library)
e. CI/CD & Release
– GitHub Actions: build, lint, test, release
– NPM registry: template is published here
– optional deploy docs (AWS, Azure, Heroku, Netlify)
Architectural patterns & design principles
• Separation of concerns: internals/ vs. startingTemplate/; components vs. pages vs. store vs. styles vs. utils.
• Unidirectional data flow: Redux + Saga → selectors → React components.
• Modular code: Plop generators enforce slice/component conventions; co-located tests.
• Dynamic code-splitting: loadable.tsx for lazy loading pages/components.
• i18n pipeline: extractor → JSON files → i18n.ts loader.
• Theming: styled-components + context via ThemeProvider + slice for theme state.