Feature-sliced design (FSD). must-know frontend architecture
Feature-Sliced Design (FSD) is architectural methodology for frontend applications. Simply put, it's set of rules and conventions for code organization. Main goal of methodology is to make project understandable and structured, in conditions of regular business requirement changes.
Core FSD Concepts
- Layer Separation (slices)
- App: application settings, global providers, routing.
- Pages: application pages with specific UI, routes and containers.
- Features: individual user features (e.g., "add product to cart", "authentication").
- Entities: modules describing and containing logic of domain "entities" (User, Product, Order, etc.).
- Shared: common libraries, utilities, reusable components (buttons, icons, validation functions).
- Code Grouping by Features
Instead of storing all components in one components/ folder, all styles in styles/, etc., FSD suggests storing all code related to functionality (UI components, logic, styles, tests) in one feature. This increases cohesion (integrity) and simplifies finding needed files.
3. Clear Responsibility Boundaries
Each layer is responsible for its set of tasks. For example, changes in feature usually don't affect other features, since common tools live in shared/, and global settings β in app/.
FSD Advantages
- Scalability
When new features or business scenarios appear in application, they're added as separate directories and modules, without affecting structure of other parts. 2. Simplified Maintenance
If you need to understand specific feature or make edits, developer sees all feature logic β from components to styles β in one place. 3. Modularity
Easy to connect or disconnect specific features, move them to another project or make them separate package. 4. Minimized Team Conflicts
Developers can work in parallel on different features without interfering with each other.
Structure Example
[Example 1]
[Example 2]
**[Example 3]**app
pages
features
entities
shared
home
add-to-cart
auth
user
product
ui
lib
config
In these examples:
- app/ contains global application initialization and configuration.
- pages/ β separate pages (routes).
- features/ β set of features (each feature contains everything needed for its work: UI, business logic, etc.).
- entities/ β description of models (User, Product, etc.) and their behavior.
- shared/ β reusable components, utilities and configurations.
Application Recommendations
- Start small: don't need to immediately force all layers if you have small application. Add layers as project grows.
- Clearly define feature boundaries: feature should solve one specific task (e.g., "user profile management" or "add product to cart").
- Use naming: if project structure becomes complex, follow unified rules for directory and file naming to avoid confusion.
- Follow DRY, YAGNI and KISS principles: FSD is just code organization scheme. It doesn't cancel basic principles of writing clean code and thoughtful architecture.
Source
Read more about Feature-Sliced Design here.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.