# 9elements/angular-workshop architecture

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

- Interactive diagram: https://gitdiagram.com/9elements/angular-workshop
- Repository: https://github.com/9elements/angular-workshop

## Overview

##### Main Components Layer
a) Basic Counter Component (self-managed state)
b) Service Counter Component (service-managed state)
c) NgRx Counter Component (Redux-style state)
- Standalone Service Counter as a variant of the Service Counter

##### State Management Layer
a) Component-level state (for basic counter)
b) Service-based state management (CounterService)
c) NgRx Store with:
- Actions (from /actions/counter.actions.ts)
- Reducers (from /reducers/counter.reducer.ts)
- Effects (from /effects/counter.effects.ts)
- Selectors (from /shared/selectors.ts)

##### Services Layer
- CounterApiService for backend communication
- CounterService for service-based state management
- Services to their respective components

##### Testing Infrastructure Layer
- Three testing approaches:
a) Unit Tests (*.spec.ts files)
b) Integration Tests (*.spectator.spec.ts files)
c) E2E Tests (Cypress tests in cypress/e2e/)

##### Data Flow
- HTTP interactions with the backend (assets/counter.json)

Specific Elements to Include:

**┌─────────────────┐**
- CounterComponent│
- ┘

##### State Management (Hexagons for NgRx elements)
**⬡ NgRx Store**
**⬡ Effects**
**⬡ Actions**

##### Services (Ovals)
**⭕ CounterService**
**⭕ CounterApiService**

**┌ ─ ─ ─ ─ ─ ─ ─ ┐**
- Testing Layer
- ┘

- Blue: Component-level elements
- Green: Service-level elements
- Orange: NgRx-related elements
- Purple: Testing infrastructure
- Gray: External systems/API

- → Direct communication
- ⇢ State updates
- ⇄ Two-way binding
- 📊 State storage
- 🧪 Test coverage

Important Notes:
##### Standalone nature of the StandaloneServiceCounter

- UI Components
- State Management
- Services
- Testing Infrastructure

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef component fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef ngrx fill:#e67e22,stroke:#d35400,color:white
    classDef testing fill:#9b59b6,stroke:#8e44ad,color:white
    classDef api fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef routing fill:#1abc9c,stroke:#16a085,color:white

    %% Main Components
    BC["Basic Counter"]:::component
    SC["Service Counter"]:::component
    NC["NgRx Counter"]:::component
    SSC["Standalone Service Counter"]:::component
    
    %% Services
    CS["Counter Service"]:::service
    CAS["Counter API Service"]:::service
    
    %% NgRx Components
    Store["NgRx Store"]:::ngrx
    Actions["Actions"]:::ngrx
    Reducers["Reducers"]:::ngrx
    Effects["Effects"]:::ngrx
    Selectors["Selectors"]:::ngrx
    AppState["App State"]:::ngrx
    
    %% Testing
    subgraph Testing
        UT["Unit Tests"]:::testing
        IT["Integration Tests"]:::testing
        E2E["E2E Tests"]:::testing
    end
    
    %% Backend
    BE["Backend Mock Data"]:::api
    
    %% Routing
    RM["Routing Module"]:::routing
    
    %% Relationships
    RM --> BC
    RM --> SC
    RM --> NC
    RM --> SSC
    
    SC --> CS
    SSC --> CS
    CS --> CAS
    CAS --> BE
    
    NC --> Store
    Store --> Actions
    Store --> Reducers
    Store --> Effects
    Store --> Selectors
    Store --> AppState
    Effects --> CAS
    
    UT --> BC
    UT --> SC
    UT --> NC
    IT --> BC
    IT --> SC
    IT --> NC
    E2E --> BC
    E2E --> SC
    E2E --> NC
    
    %% Click Events
    click BC "https://github.com/9elements/angular-workshop/tree/main/src/app/components/counter"
    click SC "https://github.com/9elements/angular-workshop/tree/main/src/app/components/service-counter"
    click NC "https://github.com/9elements/angular-workshop/tree/main/src/app/components/ngrx-counter"
    click SSC "https://github.com/9elements/angular-workshop/tree/main/src/app/components/standalone-service-counter"
    click Actions "https://github.com/9elements/angular-workshop/blob/main/src/app/actions/counter.actions.ts"
    click Reducers "https://github.com/9elements/angular-workshop/blob/main/src/app/reducers/counter.reducer.ts"
    click Effects "https://github.com/9elements/angular-workshop/blob/main/src/app/effects/counter.effects.ts"
    click Selectors "https://github.com/9elements/angular-workshop/blob/main/src/app/shared/selectors.ts"
    click AppState "https://github.com/9elements/angular-workshop/blob/main/src/app/shared/app-state.ts"
    click CS "https://github.com/9elements/angular-workshop/blob/main/src/app/services/counter.service.ts"
    click CAS "https://github.com/9elements/angular-workshop/blob/main/src/app/services/counter-api.service.ts"
    click UT "https://github.com/9elements/angular-workshop/blob/main/src/app/components/*/*.spec.ts"
    click IT "https://github.com/9elements/angular-workshop/blob/main/src/app/components/*/*.spectator.spec.ts"
    click E2E "https://github.com/9elements/angular-workshop/blob/main/cypress/e2e/counter.cy.ts"
    click RM "https://github.com/9elements/angular-workshop/blob/main/src/app/app.routing.module.ts"
    click BE "https://github.com/9elements/angular-workshop/blob/main/src/assets/counter.json"

    %% Legend
    subgraph Legend
        L1["Component"]:::component
        L2["Service"]:::service
        L3["NgRx"]:::ngrx
        L4["Testing"]:::testing
        L5["API/Backend"]:::api
        L6["Routing"]:::routing
    end
```
