Skip to main content
Starting a project with the right structure saves countless hours of refactoring later. This guide shows you how to set up projects following the Scope Rule for each supported framework.

Framework-Specific Setup

Angular 20+ Setup

Set up a modern Angular project with standalone components, signals, and the Scope Rule architecture.
1

Install Angular and Dependencies

# Create new Angular project
npx @angular/cli@latest new my-project

# Select options:
# - TypeScript: Yes
# - Standalone components: Yes
# - SSR: Optional
# - Routing: Yes

cd my-project

# Install additional dependencies
npm install --save-dev vitest @vitest/ui prettier husky
2

Create Directory Structure

# Create feature-based structure
mkdir -p src/app/features/{auth,shop,profile}
mkdir -p src/app/features/shared/{components,services,guards,pipes,directives,signals}
mkdir -p src/app/core/{services,interceptors,guards}

# Create auth feature structure
mkdir -p src/app/features/auth/{login,register}
mkdir -p src/app/features/auth/{components,services,guards,models,signals}
mkdir -p src/app/features/auth/login/components
mkdir -p src/app/features/auth/register/components

# Create shop feature structure
mkdir -p src/app/features/shop/{products,cart,wishlist}
mkdir -p src/app/features/shop/{components,services,models,signals}
mkdir -p src/app/features/shop/products/components
mkdir -p src/app/features/shop/cart/components
3

Configure TypeScript Paths

Update tsconfig.json with path aliases:
{
  "compilerOptions": {
    "paths": {
      "@features/*": ["src/app/features/*"],
      "@shared/*": ["src/app/features/shared/*"],
      "@core/*": ["src/app/core/*"]
    }
  }
}
4

Create Standalone Component Template

Create your first feature component:
// src/app/features/shop/shop.ts
import {
  Component,
  ChangeDetectionStrategy,
  signal,
  computed,
  inject,
} from '@angular/core';
import { ShopService } from './services/shop';

@Component({
  selector: 'app-shop',
  imports: [/* dependencies */],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <div class="shop">
      @if (loading()) {
        <div>Loading products...</div>
      } @else {
        <h1>Shop</h1>
        @for (product of products(); track product.id) {
          <div>{{ product.name }}</div>
        }
      }
    </div>
  `,
})
export class ShopComponent {
  private readonly shopService = inject(ShopService);
  
  readonly loading = signal(false);
  readonly products = signal<Product[]>([]);
}
5

Set Up Routing

Configure routes with standalone components:
// src/app/routes.ts
import { Routes } from '@angular/router';

export const routes: Routes = [
  {
    path: 'shop',
    loadComponent: () => import('./features/shop/shop').then(m => m.ShopComponent),
  },
  {
    path: 'auth/login',
    loadComponent: () => import('./features/auth/login/login').then(m => m.LoginComponent),
  },
];

Key Angular Principles

  • No NgModules: All components are standalone by default in Angular 20
  • Use inject() function: Avoid constructor injection
  • Signals everywhere: Replace lifecycle hooks with signals and computed()
  • Modern control flow: Use @if, @for, @switch instead of structural directives
  • OnPush detection: Always use ChangeDetectionStrategy.OnPush

Directory Structure Result

src/
  app/
    features/
      auth/
        login/
          login.ts                # Main component
          components/             # Login-specific components
        register/
          register.ts
          components/
        components/               # Shared within auth
          social-login.ts
        services/
          auth.ts
        signals/
          auth-state.ts
        guards/
          auth.guard.ts
      shop/
        products/
          products.ts
          components/
        cart/
          cart.ts
          components/
        components/               # Shared within shop
        services/
          shop.ts
        signals/
          cart.signal.ts
      shared/                     # ONLY for 2+ feature usage
        components/
        services/
        signals/
    core/                         # Singleton services
      services/
        api.ts
      interceptors/
        auth.interceptor.ts
    main.ts
    app.ts
    routes.ts

Post-Setup Checklist

After setting up your project, verify:
  • Directory structure: Features are clearly organized
  • Path aliases: Import paths are clean and readable
  • Framework conventions: Using latest patterns and best practices
  • Scope Rule compliance: Clear separation between local and shared
  • Screaming architecture: Structure communicates functionality
  • Tooling: Linting, formatting, and testing are configured

Common Setup Mistakes

Avoid these common pitfalls:
  • Creating a single components/ folder for everything
  • Mixing framework-specific patterns (e.g., using NgModules in Angular 20)
  • Over-using shared directories before confirming 2+ feature usage
  • Ignoring framework-specific optimizations (Server Components, islands, etc.)
  • Not setting up path aliases (leads to messy relative imports)

Next Steps

Component Placement

Learn the decision framework for placing components correctly

Migration Guide

Already have a project? Learn how to migrate to the Scope Rule

Best Practices

Quality checks and patterns for maintaining clean architecture

Quick Start

Get started with the agents in minutes

Build docs developers (and LLMs) love