This project serves as a template for quickly starting an Angular application using the Feature-Sliced Design (FSD) methodology. It includes:
- Schematics for generating entities quickly
- Pre-configured ESLint rules for enforcing architecture constraints
- A demo project showcasing real-world usage
Clone the repository and install dependencies:
git clone <repo-url>
cd angular-fsd-starter
npm install
npm run clean-demo # to DELETE a demo projectnpm startThis will start the demo application.
/fsd/ - Contains schematics, ESLint rules
/src/ - Main application structure following FSD principles
├── app/ - Root module, global providers
├── pages/ - Full-fledged pages (routed components)
├── widgets/ - Large reusable UI components (e.g., header, sidebar)
├── features/ - Business logic units (e.g., user authentication)
├── entities/ - Core domain models (e.g., user, post, comment)
├── shared/ - Common utilities, UI components, and helpers
"format": "prettier --write \"src/**/*.{ts,html,scss}\"",
"lint": "ng lint",
"schema:i": "cd fsd && npm i",
"schema:b": "cd fsd && npm run build"
"clean-demo": "node ./clean-demo-project.js"format– Formats the code using Prettierlint– Runs ESLint with FSD-specific rulesschema:i– Installs dependencies for custom schematicsschema:b– Builds the schematicsclean-demo– Clean demo project
Before using schematics, install and build them:
npm run schema:i
npm run schema:bThen, generate FSD entities using:
ng g fsd:page pageName
ng g fsd:widget widgetName
ng g fsd:feature featureName
ng g fsd:entity entityNameSchematics are located in:
/fsd/src/
Description: Prevents imports from upper layers in the FSD hierarchy.
Purpose: Ensures that lower layers (e.g., widgets) cannot import from higher layers (e.g., app).
Example:
// ❌ Forbidden: Importing from an upper layer
import { something } from '@/app';
// ✅ Allowed: Importing from the lower layer
import { something } from '@/widgets';Description: Prevents cross-imports within the same layer.
Purpose: Ensures that entities within the same layer (e.g., two features) cannot import from each other directly.
Example:
// ❌ Forbidden: Cross-import within the same layer
import { something } from '@/features/FeatureA';
// ✅ Allowed: Importing from the lower layer
import { something } from '@/entity/entityA';Description: Enforces imports only through the public API (index.ts).
Purpose: Ensures that modules expose only their public API and hide internal implementation details.
Exceptions: The app and shared layers are exempt from this rule.
Example:
// ❌ Forbidden: Direct import of internal module
import { something } from '@/features/FeatureA/utils/internal';
// ✅ Allowed: Importing through the public API
import { something } from '@/features/FeatureA';The included demo project is an Angular frontend template built on FSD principles. It uses JSONPlaceholder as a fake API and includes:
- A layout system with a header and sidebar
- User list and individual user profiles
- Sidebar navigation for user-related content
- Dynamic content switching with Angular routing
- Entity-specific features:
- ✅ Users – List of users and user details
- ✅ Posts – User posts and individual post view
- ✅ Comments – User comments section
- ✅ Albums – User albums and a separate "All Albums" view
This serves as a reference implementation for building real-world Angular apps using the FSD methodology.
- Angular 19
- TypeScript
- ESLint (Custom FSD Rules)
- Prettier
- Schematics
- JSONPlaceholder API