An open API service indexing awesome lists of open source software.

https://github.com/luciancaetano/startercraft

An opinionated boilerplate designed to accelerate the development of modern, scalable React applications with TypeScript.
https://github.com/luciancaetano/startercraft

boilerplate hooks react react-hooks react-router typescript

Last synced: 3 months ago
JSON representation

An opinionated boilerplate designed to accelerate the development of modern, scalable React applications with TypeScript.

Awesome Lists containing this project

README

          


Startercraft Logo

# โšก๏ธ Fast and Scalable React Project

[![License](https://img.shields.io/github/license/luciancaetano/startercraft?color=blue)](./LICENCE.md)
[![Contributors](https://img.shields.io/github/contributors/luciancaetano/startercraft)](https://github.com/luciancaetano/startercraft/graphs/contributors)
[![Last Commit](https://img.shields.io/github/last-commit/luciancaetano/startercraft?logo=git)](https://github.com/luciancaetano/startercraft/commits/main)

An **opinionated boilerplate** designed to accelerate the development of modern, scalable React applications with TypeScript.
This template is especially suited for projects that require high scalability and complexity, promoting a clean architecture, modularity, and conventions that make maintenance easier, improve code quality, and enhance overall codebase understanding across the team.

## ๐Ÿš€ Create a New Project

To quickly start a new project using this template, run the following command:

```bash
npx create-startercraft my-awesome-scalable-project
```

Replace `my-awesome-scalable-project` with your desired project name. This command will set up a new project with all the configurations and best practices included in this template.

---

## ๐Ÿ“– Index

- [๐Ÿ“‚ Component Organization](./docs/component-organization.md)
- [๐Ÿ›๏ธ Domain Layer](./docs/domain-layer.md)
- [โš™๏ธ Code Generation](./docs/code-generation.md)
- [๐Ÿงฉ What is a Feature?](./docs/feature-definition.md)
- [โš–๏ธ License](./LICENCE.md)
- [๐Ÿš€ Features](#-features)
- [๐Ÿ“‹ Prerequisites](#-prerequisites)
- [๐Ÿ“ฆ Installation](#-installation)
- [๐Ÿ› ๏ธ Scripts](#%EF%B8%8F-scripts)
- [๐Ÿงญ Path Aliases](#-path-aliases)
- [โš™๏ธ Code Generation](#%EF%B8%8F-code-generation)
- [๐Ÿงฉ Why This Structure?](#-why-this-structure)
- [๐Ÿ“š Examples of Use](#-examples-of-use)
- [๐Ÿงช Testing Guide](./docs/testing-guide.md)
- [๐Ÿ”„ GitHub Workflows](./docs/workflows-deps.md)
- [โ“ FAQ](#-faq)
- [๐Ÿค Contributing](#-contributing)
- [๐Ÿ“œ License](#-license)
- [๐ŸŒŸ Acknowledgements](#-acknowledgements)
- [๐Ÿ”— Useful Links](#-useful-links)

---

## ๐Ÿš€ Features

[๐Ÿ” Back to Index](#-index)

This starter ships with everything you need to build production-grade React apps:

- **Core**
- [React](https://reactjs.org/) โ€“ UI library
- [TypeScript](https://www.typescriptlang.org/) โ€“ static typing
- [React Router](https://reactrouter.com/) โ€“ routing
- [web-vitals](https://web.dev/vitals/) โ€“ performance monitoring

- **Styling & UI**
- [Tailwind CSS](https://tailwindcss.com/) โ€“ utility-first styling

- **Testing & Quality**
- [Vitest](https://vitest.dev/) โ€“ unit testing
- [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/) โ€“ testing React components
- [ESLint](https://eslint.org/) โ€“ linting

- **Developer Experience**
- Code generation (components & features)
- Path aliases for cleaner imports
- Pre-configured validation pipeline (`type-check + lint + test`)

---

## ๐Ÿ“‹ Prerequisites

[๐Ÿ” Back to Index](#-index)

Before you begin, ensure you have the following installed:

- [Node.js](https://nodejs.org/) (version 18 or higher)
- [npm](https://www.npmjs.com/)

---

## ๐Ÿ“ฆ Installation

[๐Ÿ” Back to Index](#-index)

```bash
git clone https://github.com/luciancaetano/startercraft.git
cd startercraft
npm install
```

---

## ๐Ÿ› ๏ธ Scripts

[๐Ÿ” Back to Index](#-index)

Commonly used commands from `package.json`:

| Command | Description |
| ------------------ | ---------------------------------------------- |
| `npm start` | Start the development server |
| `npm run build` | Compile the application for production |
| `npm run preview` | Preview the production build |
| `npm run test` | Run all tests with coverage |
| `npm run lint` | Run ESLint |
| `npm run generate` | Run the code generator for components/features |
| `npm run validate` | Type-check, lint, and run tests |

---

## ๐Ÿงญ Path Aliases

[๐Ÿ” Back to Index](#-index)

To avoid messy relative imports, this starter uses TypeScript path aliases:

| Alias | Path | Description |
| --------------- | ------------------------ | ------------------------------------ |
| `@features/*` | `./src/app/features/*` | Feature modules |
| `@components/*` | `./src/app/components/*` | Reusable UI components |
| `@config/*` | `./src/app/config/*` | Configurations |
| `@domain/*` | `./src/app/domain/*` | Domain models, types & services |
| `@hooks/*` | `./src/app/hooks/*` | Custom React hooks |
| `@utils/*` | `./src/app/utils/*` | Utility functions |
| `@assets/*` | `./src/assets/*` | Static assets (images, icons, fonts) |

---

## โš™๏ธ Code Generation

[๐Ÿ” Back to Index](#-index)

Easily scaffold new components or features with:

```bash
npm run generate
```

### ๐Ÿ“‚ Component Structure

```bash
src/app/components/[type]/[name]/
โ”‚โ”€โ”€ [name].tsx # Component view
โ”‚โ”€โ”€ [name].spec.tsx # Unit test
โ”‚โ”€โ”€ [name].module.scss # Styles (scoped)
โ”‚โ”€โ”€ [name].types.ts # Types & interfaces
โ”‚โ”€โ”€ [name].view-model.ts # View-model / logic
โ”‚โ”€โ”€ index.ts # Public exports
```

- **\[type]** โ†’ `elements`, `providers`, `pages`, or `layouts`
- **\[name]** โ†’ The component name

### ๐Ÿ“‚ Feature Structure

```bash
src/app/features/[name]/
โ”‚โ”€โ”€ [name].routes.tsx # Feature route definitions
```

> Features are lightweight by default. Add `components/`, `hooks/`, `types/`, `utils/`, and `config/` subdirectories as needed.

### ๐Ÿ“‚ Scoped Component Structure

For components that are exclusively scoped to a parent component, nest them inside a `components/` folder:

```bash
src/app/components/[type]/[parent-name]/components/[child-name]/
โ”‚โ”€โ”€ [name].tsx # Scoped child component view
โ”‚โ”€โ”€ [name].spec.tsx # Unit test
โ”‚โ”€โ”€ [name].module.scss # Styles (scoped)
โ”‚โ”€โ”€ [name].types.ts # Types & interfaces
โ”‚โ”€โ”€ [name].view-model.ts # View-model / logic
โ”‚โ”€โ”€ index.ts # Public exports
```

---

## ๐Ÿงฉ Why This Structure?

[๐Ÿ” Back to Index](#-index)

- โœ… **Modularity** โ€“ clean separation of concerns
- โœ… **Scalability** โ€“ easy to extend features
- โœ… **Reusability** โ€“ atomic components & shared utils
- โœ… **Maintainability** โ€“ consistent architecture & conventions
- โœ… **DX Friendly** โ€“ generation tools, linting & validation pipeline

---

## ๐Ÿ“š Examples of Use

[๐Ÿ” Back to Index](#-index)

### Running the Development Server

```bash
npm start
```

### Running Tests

```bash
npm test
```

### Building for Production

```bash
npm run build
```

---

## โ“ FAQ

[๐Ÿ” Back to Index](#-index)

### What is the minimum Node.js version required?

Node.js version 18 or higher is required. Using the latest LTS version is recommended for better stability and support.

### How do I add a new feature or component?

Use the code generation tool by running:

```bash
npm run generate
```

Follow the prompts to scaffold the desired feature or component.

### How do I configure environment variables?

Create a `.env` file in the root directory and define your variables there. Use the `example.env` file as a reference.

### How do I update dependencies?

Run the following command to update all dependencies:

```bash
npm update
```

For major version updates, review the changelogs of the respective packages to ensure compatibility.

### How do I report a bug or request a feature?

Open an issue on the [GitHub repository](https://github.com/luciancaetano/startercraft/issues) with detailed information about the bug or feature request.

---

## ๐Ÿค Contributing

[๐Ÿ” Back to Index](#-index)

1. Fork the repository
2. Create a new branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m "feat: add amazing feature"`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request

---

## ๐Ÿ“œ License

[๐Ÿ” Back to Index](#-index)

This project is licensed under the [CC0](./LICENCE.md).

---

## ๐ŸŒŸ Acknowledgements

[๐Ÿ” Back to Index](#-index)

This starter was inspired by best practices and setups from the React community, with the goal of helping teams build robust and maintainable apps faster.

---

## ๐Ÿ”— Useful Links

[๐Ÿ” Back to Index](#-index)

- [React Documentation](https://reactjs.org/docs/getting-started.html)
- [TypeScript Documentation](https://www.typescriptlang.org/docs/)
- [React Router Documentation](https://reactrouter.com/)
- [Tailwind CSS Documentation](https://tailwindcss.com/docs)
- [Vitest Documentation](https://vitest.dev/guide/)
- [Web Vitals](https://web.dev/vitals/)