A modern, robust TypeScript React frontend boilerplate built with SOLID principles, Clean Architecture, Dependency Injection, and a Use Case-driven approach.
This boilerplate implements industry best practices for frontend development:
- TypeScript with strict type checking
- SOLID Principles for maintainable code architecture
- Clean Architecture for separation of concerns
- Dependency Injection using InversifyJS
- Use Case Pattern for business logic orchestration
- Repository Pattern for data access abstraction
- Service Layer for business logic encapsulation
- Feature-Based Organization with vertical slicing
- Adapter Pattern for external services
- React Router for navigation
- React Redux for state management
The architecture follows a clean, layered approach with feature-based organization:
- Domain Layer: Core business entities and logic
- Application Layer: Use cases that orchestrate business operations
- Infrastructure Layer: Implementation details and external services
- Presentation Layer: UI components and state management
- Feature-Based Structure: Code is organized by features rather than technical layers
- Dependency Inversion: High-level modules don't depend on low-level modules
- Use Case Driven Design: Business operations are modeled as use cases
- Repository Abstraction: Data access is abstracted behind repositories
- Adapter Pattern: External services are wrapped in adapters
src/
├── app/ # App initialization
│ ├── App.tsx # Main App component
│ └── config/ # App configuration
│ ├── inversify.config.ts # DI container
│ └── types.ts # DI types/symbols
├── domain/ # Core business domain
│ ├── entities/ # Business objects
│ ├── valueObjects/ # Immutable value objects
│ └── events/ # Domain events
├── features/ # Feature modules
│ ├── auth/ # Authentication feature
│ │ ├── components/ # Presentation components
│ │ ├── containers/ # Container components
│ │ ├── useCases/ # Business logic orchestration
│ │ ├── services/ # Specific services
│ │ ├── repositories/ # Data access
│ │ ├── models/ # DTOs and types
│ │ ├── hooks/ # Custom hooks
│ │ ├── routes/ # Feature routes
│ │ └── store/ # Feature state
│ ├── users/ # User management
│ │ └── ...
│ └── products/ # Product management
│ └── ...
├── shared/ # Shared modules
│ ├── components/ # Common UI components
│ ├── hooks/ # Common hooks
│ ├── utils/ # Utility functions
│ ├── constants/ # Constants and enums
│ └── styles/ # Common styles
├── infrastructure/ # External interfaces
│ ├── http/ # HTTP client setup
│ ├── storage/ # Storage implementations
│ ├── logging/ # Logging service
│ └── analytics/ # Analytics implementation
├── adapters/ # Adapters for external services
│ ├── api/ # API adapters
│ ├── storage/ # Storage adapters
│ └── analytics/ # Analytics adapters
├── routes/ # Routing configuration
├── store/ # Global state (if needed)
├── errorBoundaries/ # Error handling
└── types/ # Global TypeScript types
- Node.js (v14 or higher recommended)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd react-frontend-boilerplate
-
Install dependencies
npm install
-
Start development server
npm run dev
npm run dev
- Start development servernpm run build
- Build for productionnpm run preview
- Preview production buildnpm run test
- Run testsnpm run lint
- Run linternpm run format
- Format code using Prettier
- Single Responsibility: Each class has one responsibility
- Open/Closed: Open for extension, closed for modification
- Liskov Substitution: Subtypes can be substituted for their base types
- Interface Segregation: Specific interfaces instead of general ones
- Dependency Inversion: Depend on abstractions, not implementations
The application follows clean architecture principles with:
- Domain as the center with no dependencies
- Use cases that depend only on domain
- Adapters that implement interfaces defined by use cases
- UI that depends on use cases
Each business operation is modeled as a use case:
- Use cases implement single responsibility principle
- Use cases orchestrate multiple services
- Use cases represent user intentions
- Create folder structure in
src/features/<feature-name>
- Define domain entities in
src/domain/entities
- Create DTOs in
src/features/<feature-name>/models
- Implement repository interfaces & implementations
- Implement service interfaces & implementations
- Create use cases for business operations
- Register dependencies in
src/app/config
- Implement UI components
This project is licensed under the MIT License.