Skip to content

Latest commit

Β 

History

History
97 lines (81 loc) Β· 4.07 KB

File metadata and controls

97 lines (81 loc) Β· 4.07 KB

πŸ“‚ Folder Structure

Project based on principle Feature-based Architecture: each feature owns its UI, routes, models, mappers, services, and store when needed. Shared and core code live outside features.

πŸ“¦ src/
 β”œβ”€β”€ πŸ“‚ app/
 β”‚   β”œβ”€β”€ πŸ“‚ features/                    # Feature modules
 β”‚   β”‚   └── πŸ“‚ feature-name/
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ components/          # Feature UI pieces
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ pages/               # Route-level pages (when used)
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ models/              # Feature-local *.model.ts types
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ mappers/             # Feature API ↔ domain mappers
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ services/            # Feature HTTP / facade services
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ store/               # Feature NGXS state (actions, model, state, selectors)
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ enums/               # Feature enums
 β”‚   β”‚       β”œβ”€β”€ πŸ“‚ constants/           # Feature constants
 β”‚   β”‚       β”œβ”€β”€ feature.routes.ts       # Feature routes
 β”‚   β”‚       └── feature.component.ts    # Feature shell / entry component
 β”‚   β”‚
 β”‚   β”œβ”€β”€ πŸ“‚ core/                        # App-wide infrastructure
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ components/              # Shell UI (header, banners, …)
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ services/                # Global services
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ store/                   # Core NGXS state (user, emails, …)
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ models/                  # Core config / routing types
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ guards/
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ interceptors/
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ helpers/
 β”‚   β”‚   └── πŸ“‚ provider/
 β”‚   β”‚
 β”‚   β”œβ”€β”€ πŸ“‚ shared/                      # Cross-feature reusable code
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ components/              # Shared UI
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ directives/
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ pipes/
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ services/                # Shared HTTP / helpers
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ stores/                  # Shared NGXS domains
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ models/                  # Shared domain + JSON:API models
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ mappers/                 # Shared mappers
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ enums/
 β”‚   β”‚   β”œβ”€β”€ πŸ“‚ guards/
 β”‚   β”‚   └── πŸ“‚ helpers/
 β”‚   β”‚
 β”‚   β”œβ”€β”€ app.component.ts
 β”‚   β”œβ”€β”€ app.config.ts
 β”‚   β”œβ”€β”€ app.config.server.ts            # SSR app config
 β”‚   β”œβ”€β”€ app.routes.ts
 β”‚   └── app.routes.server.ts            # SSR routes
 β”‚
 β”œβ”€β”€ πŸ“‚ assets/
 β”œβ”€β”€ πŸ“‚ environments/
 β”œβ”€β”€ πŸ“‚ styles/
 β”œβ”€β”€ πŸ“‚ testing/                         # Test helpers, mocks, builders (@testing/*)
 β”œβ”€β”€ main.ts                             # Browser bootstrap
 β”œβ”€β”€ main.server.ts                      # SSR bootstrap
 β”œβ”€β”€ server.ts                           # Express / SSR server entry
 └── index.html

πŸ“‹ Models and mappers

  • Types live in *.model.ts files (interfaces/types, not classes).
  • Shared catalog: shared/models/<domain>/ with optional *-json-api.model.ts twins.
  • Feature-local types: features/<feature>/models/.
  • Mappers convert JSON:API ↔ domain at the service boundary.

See Models Conventions.


πŸ—ƒοΈ State

  • Shared domains: shared/stores/<domain>/
  • Feature domains: features/<feature>/store/
  • Core domains: core/store/

See NGXS State Management.


πŸš€ Dynamic File Generation (Schematics)

Use Angular CLI for scaffolding:

ng generate component feature-name/components/new-component

πŸ“Œ Other Schematics:

Entity Command
πŸ“Œ Service ng g s feature-name/services/new-service
πŸ” Guard ng g g feature-name/guards/auth-guard
πŸ”„ Pipe ng g p shared/pipes/currency-format
✨ Directive ng g d shared/directives/highlight