# danwahlin/angular-architecture architecture

> Architecture diagram of the GitHub repository danwahlin/angular-architecture, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danwahlin/angular-architecture
- Repository: https://github.com/danwahlin/angular-architecture

## Overview

##### Project Type and Purpose
- This is a front-end Angular “monorepo” (single workspace) hosting multiple self-contained sample/demo applications plus one shared library.
- Its purpose is educational: demonstrating Angular architecture patterns and best practices (core/shared/feature modules, state mgmt, view-models, component communication, routing, standalone components, etc.).

##### Top-Level Structure (Monorepo)
- Workspace root
- angular.json (workspace configuration listing all projects)
- package.json (shared dev-dependencies, scripts)
- tsconfig.json
- folders:
– demos (primary sample app with many feature modules)
– cloning, input-output-demo (smaller isolated apps)
– labs (bite-size guided “begin” & “end” exercises)
– state-management (DIY store, NgRx, ngrx-data, Observable Store)
– shared-library-abc-logging (Angular library project + demo app)

##### Main Components (high level)
- Angular CLI (ng serve, ng build)
- Build System (webpack under the hood via Angular CLI)
- Each Angular App project:
- src/app/app.module.ts (root module)
- CoreModule: singleton services (e.g., ClonerService, in-memory data services, interceptors, guards, logger)
- SharedModule: common directives, pipes, components, interfaces
- Feature Modules: e.g., customer, heroes, orders, communication, view-models, routing modules, state modules
- AppRoutingModule (routes.ts)
- Main at src/main.ts → bootstrap(AppModule)
- Assets & environments (static JSON, env configs)
- Shared Library project:
- browser-logger library (ng-packagr output)
- exported as a normal NPM package within the workspace

##### Relationships and Data Flow
- Developer invokes Angular CLI → builds requested project → passes through
→ RootModule → loads CoreModule & SharedModule → lazily or eagerly loads Feature Modules
- Components ← dependency injection ← Services from CoreModule/feature modules
- Services may call:
- HttpClient → real or in-memory-web-api back end (JSON files under assets or db.json)
- RxJS streams/Subjects → propagate data to components or other services
- State-management: components dispatch actions → NgRx Store/Effects or custom observable store → selectors → components

##### Key Architectural Patterns
- Monorepo with Angular CLI multi-project workspace
- Modularization: separation of concerns via Core, Shared, Feature modules
- Lazy loading (feature routes) vs eager loading
- Dependency Injection for services, interceptors, guards
- State management patterns: DIY store, Subject-based store, NgRx, NgRx-Data, Observable Store
- View-model pattern: container vs presentational components with CustomerVM, OrderVM, entity cache
- Standalone components (in standalone labs)

##### Essential Elements
- Labels for Workspace, Projects, Modules, Components, Services
- Annotation of lazy vs eager loaded feature modules

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Workspace and Projects
    subgraph "Workspace"
        subgraph "Projects"
            DemosApp["demos"]:::app
            CloningApp["cloning"]:::app
            IOApp["input-output-demo"]:::app
            LabsApp["labs"]:::app
            StateApp["state-management"]:::app
            SharedLibPRJ["shared-library-abc-logging"]:::lib
        end
    end

    %% CLI and Build Pipeline
    CLI["Angular CLI"]:::cli
    Build["Build System (Webpack)"]:::build
    Browser["Browser"]:::external

    CLI --> Build
    Build --> DemosApp
    Build --> CloningApp
    Build --> IOApp
    Build --> LabsApp
    Build --> StateApp
    Build --> SharedLibPRJ
    DemosApp --> Browser

    %% Demos App Internal Structure
    subgraph "demos App"
        direction TB
        Main["main.ts"]:::file
        AppModule["AppModule"]:::module
        CoreModule["CoreModule"]:::core
        SharedModule["SharedModule"]:::core
        AppRouting["AppRoutingModule"]:::routing
        subgraph "Feature Modules"
            direction TB
            Shell["FeaturesModulesModule"]:::feature
            Customers["CustomersModule"]:::feature
            Orders["OrdersModule"]:::feature
        end
        subgraph "Core Services"
            direction TB
            ClonerService["ClonerService"]:::service
            DataService["DataService"]:::service
            EventBusService["EventBusService"]:::service
            HttpClientRxJSService["HttpClientRxJSService"]:::service
            SubjectService["SubjectService"]:::service
            AuthInterceptor["AuthInterceptor"]:::service
        end
        subgraph "Assets & Env" 
            direction TB
            JSON["people.json / planets.json"]:::assets
            Env["environment.ts"]:::assets
        end
    end

    %% Internal Connections
    Main --> AppModule
    AppModule --> CoreModule
    AppModule --> SharedModule
    AppModule --> AppRouting
    AppModule --> Shell
    Shell --> Customers
    Shell --> Orders
    CoreModule --> ClonerService
    CoreModule --> DataService
    CoreModule --> EventBusService
    CoreModule --> HttpClientRxJSService
    CoreModule --> SubjectService
    CoreModule --> AuthInterceptor
    HttpClientRxJSService --> JSON
    DataService --> JSON

    %% Feature Component Example
    subgraph "Customers Feature"
        direction TB
        CustomerList["CustomerListComponent"]:::component
        CustomerService["CustomerService"]:::service
    end
    Customers --> CustomerList
    CustomerList --> CustomerService
    CustomerService --> HttpClientRxJSService

    %% Shared Library
    subgraph "Browser Logger Library"
        direction TB
        SharedLibMod["BrowserLoggerModule"]:::lib
        SharedLibServ["BrowserLoggerService"]:::service
    end
    SharedLibPRJ --> SharedLibMod
    SharedLibMod --> SharedLibServ
    CoreModule --> SharedLibServ

    %% Cloning App
    subgraph "cloning App"
        direction TB
        CloneCore["CoreModule"]:::core
        CloneService["ClonerService"]:::service
    end
    CloningApp --> CloneCore
    CloneCore --> CloneService

    %% Input-Output-Demo App
    subgraph "input-output-demo App"
        direction TB
        IOAppModule["AppModule"]:::module
        IOCustomerMod["CustomerModule"]:::feature
        CustomerListIO["CustomerListComponent"]:::component
    end
    IOApp --> IOAppModule
    IOAppModule --> IOCustomerMod
    IOCustomerMod --> CustomerListIO

    %% Labs Observable Service Example
    subgraph "labs Shared Lib"
        direction TB
        LabsSharedMod["SharedLibModule"]:::lib
        CartService["ShoppingCartService"]:::service
    end
    LabsApp --> LabsSharedMod
    LabsSharedMod --> CartService

    %% Click Events
    click AppModule "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/app.module.ts"
    click Main "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/main.ts"
    click CoreModule "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/core.module.ts"
    click ClonerService "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/services/cloner.service.ts"
    click DataService "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/services/data.service.ts"
    click EventBusService "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/services/event-bus.service.ts"
    click HttpClientRxJSService "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/services/httpClientRxJS.service.ts"
    click SubjectService "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/services/subject.service.ts"
    click AuthInterceptor "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/core/interceptors/auth.interceptor.ts"
    click SharedModule "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/shared/shared.module.ts"
    click Customers "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/features-modules/customers/customers.module.ts"
    click Orders "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/features-modules/orders/orders.module.ts"
    click Shell "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/features-modules/features-modules.module.ts"
    click AppRouting "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/app/routes.ts"
    click JSON "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/assets/people.json"
    click Env "https://github.com/danwahlin/angular-architecture/blob/main/demos/src/environments/environment.ts"
    click SharedLibMod "https://github.com/danwahlin/angular-architecture/blob/main/shared-library-abc-logging/projects/browser-logger/src/lib/browser-logger.module.ts"
    click SharedLibServ "https://github.com/danwahlin/angular-architecture/blob/main/shared-library-abc-logging/projects/browser-logger/src/lib/browser-logger.service.ts"
    click CloneCore "https://github.com/danwahlin/angular-architecture/blob/main/cloning/src/app/core/core.module.ts"
    click CloneService "https://github.com/danwahlin/angular-architecture/blob/main/cloning/src/app/core/cloner.service.ts"
    click IOAppModule "https://github.com/danwahlin/angular-architecture/blob/main/input-output-demo/src/app/app.module.ts"
    click IOCustomerMod "https://github.com/danwahlin/angular-architecture/blob/main/input-output-demo/src/app/customer/customer.module.ts"
    click CustomerListIO "https://github.com/danwahlin/angular-architecture/blob/main/input-output-demo/src/app/customer/customer-list/customer-list.component.ts"
    click LabsSharedMod "https://github.com/danwahlin/angular-architecture/blob/main/labs/shared-project/projects/shared-lib/src/lib/shared-lib.module.ts"
    click CartService "https://github.com/danwahlin/angular-architecture/blob/main/labs/creating-an-observable-service/src/app/core/shopping-cart.service.ts"

    %% Styles
    classDef cli fill:#f9f,stroke:#333,stroke-width:1px
    classDef build fill:#fad,stroke:#333,stroke-width:1px
    classDef app fill:#bbf,stroke:#333,stroke-width:1px
    classDef lib fill:#bfb,stroke:#333,stroke-width:1px
    classDef module fill:#ccf,stroke:#333,stroke-width:1px
    classDef core fill:#88f,stroke:#333,stroke-width:1px
    classDef feature fill:#8f8,stroke:#333,stroke-width:1px
    classDef routing fill:#c8f,stroke:#333,stroke-width:1px
    classDef service fill:#fea,stroke:#333,stroke-width:1px
    classDef component fill:#f96,stroke:#333,stroke-width:1px
    classDef assets fill:#ccc,stroke:#333,stroke-width:1px
    classDef file fill:#eee,stroke:#333,stroke-width:1px
```
