Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Angular 20 Template

A production-ready Angular 20 template with modern best practices, comprehensive tooling, and enterprise-grade features.

Features

Core Features

  • βœ… Angular 20.3 with standalone components
  • βœ… Server-Side Rendering (SSR) with hydration
  • βœ… TypeScript Strict Mode for maximum type safety
  • βœ… Signals for reactive state management
  • βœ… OnPush Change Detection for optimal performance

UI & Styling

  • 🎨 PrimeNG 20.2 with Aura theme
  • 🎨 Tailwind CSS for utility-first styling
  • πŸŒ“ Dark Mode support with theme service
  • πŸ“± Responsive Design with mobile-first approach

Authentication & Security

  • πŸ” HttpOnly Cookie Authentication with XSRF protection
  • πŸ›‘οΈ Role-Based Access Control (RBAC)
  • πŸ”’ Route Guards (auth & role guards)
  • πŸ” HTTP Interceptors (auth, error, loading)
  • πŸ›‘οΈ Security Headers (CSP, HSTS, X-Frame-Options)

Developer Experience

  • πŸ§ͺ Testing Suite with Jasmine/Karma (example tests included)
  • πŸ“ ESLint & Prettier with pre-commit hooks via Husky
  • πŸ”„ Conventional Commits with commitlint
  • πŸ“¦ Path Aliases (@core, @shared, @features, @environments)
  • 🎯 Feature Flags for environment-specific behavior
  • πŸ“š Comprehensive Documentation

Performance

  • ⚑ Lazy Loading for all routes
  • ⚑ @defer examples for component lazy loading
  • ⚑ PreloadAllModules strategy
  • ⚑ OnPush change detection everywhere
  • ⚑ Bundle optimization with strict budgets

Architecture & Patterns

  • πŸ—οΈ Main App Layout with header/sidebar/footer
  • πŸ—οΈ Reusable Components (empty states, error boundaries, form errors)
  • πŸ—οΈ Base API Service with retry logic
  • πŸ—οΈ Meta Service for SEO optimization
  • πŸ—οΈ Utility Functions for common tasks

Quick Start

Prerequisites

  • Node.js 20.18.1 or higher (check .nvmrc)
  • npm 10+ or yarn

Installation

# Install dependencies
npm install

# Start development server
npm start

# Open browser
# Navigate to http://localhost:4200

Demo Credentials

Admin Account:

  • Email: admin@angular.com
  • Password: Angular2025!

User Account:

  • Email: user@angular.com
  • Password: Angular2025!

Available Scripts

npm start           # Start development server
npm run build       # Build for production
npm run test        # Run unit tests
npm run lint        # Lint code
npm run format      # Format code with Prettier
npm run format:check # Check code formatting

Project Structure

src/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ core/                     # Singleton services, guards, interceptors
β”‚   β”‚   β”œβ”€β”€ guards/              # Auth & role guards
β”‚   β”‚   β”œβ”€β”€ interceptors/        # HTTP interceptors
β”‚   β”‚   β”œβ”€β”€ models/              # Core data models
β”‚   β”‚   └── services/            # Core services
β”‚   β”‚       β”œβ”€β”€ api.service.ts   # Base HTTP service with retry
β”‚   β”‚       β”œβ”€β”€ auth.ts          # Authentication service
β”‚   β”‚       β”œβ”€β”€ error-handler.ts # Global error handler
β”‚   β”‚       β”œβ”€β”€ loading.ts       # Loading state service
β”‚   β”‚       β”œβ”€β”€ meta.service.ts  # SEO meta tags
β”‚   β”‚       └── theme.ts         # Theme/dark mode service
β”‚   β”œβ”€β”€ features/                # Feature modules
β”‚   β”‚   β”œβ”€β”€ admin/               # Admin panel
β”‚   β”‚   β”œβ”€β”€ auth/                # Login/Register
β”‚   β”‚   β”œβ”€β”€ dashboard/           # Dashboard
β”‚   β”‚   β”œβ”€β”€ examples/            # Example components (@defer, virtual scroll)
β”‚   β”‚   └── profile/             # User profile
β”‚   β”œβ”€β”€ shared/                  # Shared components, pipes, utilities
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ app-layout.ts    # Main app layout
β”‚   β”‚   β”‚   β”œβ”€β”€ auth-layout.ts   # Auth pages layout
β”‚   β”‚   β”‚   β”œβ”€β”€ empty-state.ts   # Empty state component
β”‚   β”‚   β”‚   β”œβ”€β”€ error-boundary.ts # Error display component
β”‚   β”‚   β”‚   └── form-error.ts    # Form validation errors
β”‚   β”‚   β”œβ”€β”€ pipes/               # Custom pipes
β”‚   β”‚   └── utils/               # Utility functions
β”‚   β”œβ”€β”€ app.config.ts            # App configuration
β”‚   └── app.routes.ts            # Route definitions
β”œβ”€β”€ environments/                # Environment configurations
β”‚   β”œβ”€β”€ environment.ts           # Production
β”‚   β”œβ”€β”€ environment.development.ts # Development
β”‚   └── environment.staging.ts   # Staging
└── assets/                      # Static assets

Environment Configuration

The template includes three environments with feature flags:

Development

  • Debug tools enabled
  • Longer token expiry
  • Verbose console logging
  • API: http://localhost:3000

Staging

  • Debug tools enabled for testing
  • Error reporting enabled
  • API: https://api-staging.example.com

Production

  • Debug tools disabled
  • Analytics enabled
  • Minimal logging
  • API: https://api.example.com

Feature Flags

Control features per environment in src/environments/environment.ts:

features: {
  enableDebugTools: false,      // Debug buttons in auth layout
  enableRegistration: true,     // Allow new user registration
  enableSocialLogin: false,     // Social auth providers
  enableDarkMode: true,         // Theme switching
  enableAnalytics: true,        // Analytics tracking
  enableErrorReporting: true,   // Error reporting service
}

Key Components

AppLayout

Main application layout with:

  • Responsive header with user menu
  • Collapsible sidebar navigation
  • Theme toggle
  • Footer

EmptyState

Display friendly empty states:

<app-empty-state
  icon="pi pi-inbox"
  title="No items found"
  message="Create your first item to get started"
  actionLabel="Create Item"
  (action)="createItem()"
/>

ErrorBoundary

Handle errors gracefully:

<app-error-boundary
  title="Something went wrong"
  [message]="errorMessage"
  [showRetry]="true"
  (retry)="retryOperation()"
/>

FormError

Display form validation errors:

<input formControlName="email" /> <app-form-error [control]="form.controls.email" />

API Service

Base HTTP service with built-in:

  • Retry logic with exponential backoff
  • Error transformation
  • Request timeout handling
  • Environment-based configuration
@Injectable({ providedIn: 'root' })
export class UserService extends ApiService {
  getUsers() {
    return this.get<User[]>('/users');
  }

  createUser(user: User) {
    return this.post<User>('/users', user);
  }
}

Testing

Example tests are included for:

  • Services - src/app/core/services/auth.spec.ts
  • Guards - src/app/core/guards/auth-guard.spec.ts
  • Interceptors - src/app/core/interceptors/auth-interceptor.spec.ts
  • Components - src/app/features/dashboard/dashboard.spec.ts

Run tests:

npm test

Documentation

  • Architecture - docs/ARCHITECTURE.md
  • Changelog - CHANGELOG.md
  • Code Guide - .claude/CLAUDE.md

Security

Production Checklist

  • Replace demo auth with real backend
  • Use HttpOnly cookies for tokens (not sessionStorage)
  • Implement server-side token validation
  • Update CSP headers in src/server.ts
  • Enable HTTPS only
  • Set up proper CORS configuration
  • Implement rate limiting
  • Add input sanitization
  • Enable audit logging

Security Headers

The template includes production-ready security headers:

  • Content Security Policy (CSP)
  • X-Frame-Options (clickjacking protection)
  • X-Content-Type-Options (MIME sniffing protection)
  • Strict-Transport-Security (HTTPS enforcement)
  • Referrer-Policy
  • Permissions-Policy

Browser Support

  • Chrome (latest)
  • Firefox (latest)
  • Safari (latest)
  • Edge (latest)

Contributing

  1. Follow the existing code structure
  2. Write tests for new features
  3. Run linting before committing
  4. Use conventional commits
  5. Update documentation

License

MIT

Resources


Built with ❀️ using Angular 20

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages