# gmboknat/ng5-tour-of-heroes architecture

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

- Interactive diagram: https://gitdiagram.com/gmboknat/ng5-tour-of-heroes
- Repository: https://github.com/gmboknat/ng5-tour-of-heroes

## Overview

##### Project type and purpose
- This is a single‐page front-end application built with Angular (version 1.6.2 of the Angular CLI).
- It’s a demonstration “Tour of Heroes” app that lets users view, search, and edit a list of heroes.
- There is no real back-end server—the InMemoryDataService simulates HTTP calls.

##### File structure
- Top-level files and folders:
- angular-cli.json, tsconfig.json, tslint.json, package.json, etc. — Angular build/config files
- e2e/ — end-to-end tests (Protractor)
- src/ — application source code
- Within src/:
- app/ — main application code
– app.module.ts & app-routing.module.ts — root module and router setup
– app.component.* — root component
– dashboard/, heroes/, hero-detail/, hero-search/, messages/ — feature components
– hero.service.ts, message.service.ts, in-memory-data.service.ts — services
– hero.ts, mock-heroes.ts — domain model & sample data
- assets/ — static files
- environments/ — dev/prod configuration
- main.ts, polyfills.ts, index.html, styles.css — Angular bootstrap and global assets
- Testing files:
- *.spec.ts in app/ for unit tests (Karma)
- e2e/ for integration tests

##### README for additional insights
- Confirms Angular CLI usage for scaffolding, serving, building, and testing.

a. Main components
- UI layer (Components & Modules)
- Application module & router
- Services layer (HeroService, MessageService, InMemoryDataService)
- Angular core & platform (BrowserModule, HttpClientModule)
- In-memory web API (simulated data store)
- Environment configs
- Testing frameworks (Karma, Jasmine, Protractor)
b. Relationships and interactions
- User → AppComponent → FeatureComponents (Dashboard, Heroes, HeroDetail, HeroSearch, Messages)
- FeatureComponents inject HeroService or MessageService → HttpClient → InMemoryDataService
- AppRoutingModule directs navigation among feature components
- InMemoryDataService intercepts HTTP calls → returns Observable<Hero[]>
c. Architectural patterns and design principles
- Component-based UI (presentation layer)
- Dependency injection for services
- Separation of concerns: presentation vs data access
- Modular routing (AppRoutingModule)
- Simulated backend via in-memory-web-api for testing/development
d. Key technologies
- Angular CLI, TypeScript, RxJS (Observables)
- @angular/core, @angular/router, @angular/common/http
- angular-in-memory-web-api
- Karma + Jasmine for unit tests, Protractor for e2e tests

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% UI Layer
    subgraph "UI Layer" 
        direction TB
        AppComponent["AppComponent"]:::ui
        DashboardComponent["DashboardComponent"]:::ui
        HeroesComponent["HeroesComponent"]:::ui
        HeroDetailComponent["HeroDetailComponent"]:::ui
        HeroSearchComponent["HeroSearchComponent"]:::ui
        MessagesComponent["MessagesComponent"]:::ui
    end

    %% Modules Layer
    subgraph "Core Modules" 
        direction TB
        AppModule["AppModule"]:::mod
        AppRoutingModule["AppRoutingModule"]:::mod
        BrowserModule["BrowserModule"]:::mod
        HttpClientModule["HttpClientModule"]:::mod
        FormsModule["FormsModule"]:::mod
        HttpClientInMemoryWebApiModule["HttpClientInMemoryWebApiModule"]:::mod
    end

    %% Services and Data
    subgraph "Services & Data" 
        direction TB
        HeroService["HeroService"]:::svc
        MessageService["MessageService"]:::svc
        InMemoryDataService["InMemoryDataService"]:::data
    end

    %% Configuration & Bootstrap
    subgraph "Configuration & Bootstrap"
        direction TB
        EnvironmentDev["environment.ts"]:::config
        EnvironmentProd["environment.prod.ts"]:::config
        MainTS["main.ts"]:::config
        Polyfills["polyfills.ts"]:::config
        IndexHTML["index.html"]:::config
        StylesCSS["styles.css"]:::config
        Assets["assets/"]:::config
    end

    %% Testing Setup
    subgraph "Testing" 
        direction TB
        TestHarness["test.ts"]:::test
        KarmaConfig["karma.conf.js"]:::test
        SpecTsConfig["tsconfig.spec.json"]:::test
        ProtractorConfig["protractor.conf.js"]:::test
        E2EAppSpec["e2e/app.e2e-spec.ts"]:::test
        E2EAppPo["e2e/app.po.ts"]:::test
        E2ETsConfig["e2e/tsconfig.e2e.json"]:::test
    end

    %% Domain & Mock Data
    subgraph "Domain & Mock Data"
        direction TB
        HeroModel["hero.ts"]:::data
        MockHeroes["mock-heroes.ts"]:::data
    end

    %% Angular CLI & Build Configs
    subgraph "Build & CLI"
        direction TB
        AngularCLI["angular-cli.json"]:::config
        TSConfig["tsconfig.json"]:::config
        TSLint["tslint.json"]:::config
        PackageJSON["package.json"]:::config
        PackageLock["package-lock.json"]:::config
    end

    %% Connections
    AppModule -->|imports| BrowserModule
    AppModule -->|imports| HttpClientModule
    AppModule -->|imports| FormsModule
    AppModule -->|imports| HttpClientInMemoryWebApiModule
    AppModule -->|imports| AppRoutingModule
    AppModule --> AppComponent
    AppModule --> DashboardComponent
    AppModule --> HeroesComponent
    AppModule --> HeroDetailComponent
    AppModule --> HeroSearchComponent
    AppModule --> MessagesComponent

    AppRoutingModule --> DashboardComponent
    AppRoutingModule --> HeroesComponent
    AppRoutingModule --> HeroDetailComponent
    AppRoutingModule --> HeroSearchComponent
    AppRoutingModule --> MessagesComponent

    AppComponent -->|navigates| DashboardComponent
    AppComponent -->|navigates| HeroesComponent

    DashboardComponent --> HeroService
    HeroesComponent --> HeroService
    HeroDetailComponent --> HeroService
    HeroSearchComponent --> HeroService
    MessagesComponent --> MessageService

    HeroService -->|HTTP calls| HttpClientModule
    MessageService -->|HTTP calls| HttpClientModule
    HttpClientInMemoryWebApiModule --> InMemoryDataService
    HeroService --> InMemoryDataService
    MessageService --> InMemoryDataService

    %% Configuration flow
    MainTS --> AppModule
    Polyfills --> AppModule
    EnvironmentDev -->|build| AppModule
    EnvironmentProd -->|build| AppModule
    IndexHTML --> AppComponent
    StylesCSS --> AppComponent
    Assets --> AppComponent

    %% Testing flow
    TestHarness -->|unit tests| HeroService
    TestHarness -->|unit tests| MessageService
    KarmaConfig --> TestHarness
    SpecTsConfig --> TestHarness
    ProtractorConfig --> E2EAppSpec
    E2EAppPo --> E2EAppSpec
    E2ETsConfig --> E2EAppSpec

    %% Domain data
    HeroModel --> HeroService
    MockHeroes --> InMemoryDataService

    %% CLI & build
    AngularCLI -->|scaffold/serve| AppModule
    TSConfig -->|compile| AppModule
    TSLint -->|lint| AppModule
    PackageJSON -->|deps| AppModule
    PackageLock -->|lock| AppModule

    %% Click Events
    click AppModule "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/app.module.ts"
    click AppRoutingModule "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/app-routing.module.ts"
    click AppComponent "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/app.component.ts"
    click DashboardComponent "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/dashboard/dashboard.component.ts"
    click HeroesComponent "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/heroes/heroes.component.ts"
    click HeroDetailComponent "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/hero-detail/hero-detail.component.ts"
    click HeroSearchComponent "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/hero-search/hero-search.component.ts"
    click MessagesComponent "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/messages/messages.component.ts"
    click HeroService "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/hero.service.ts"
    click MessageService "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/message.service.ts"
    click InMemoryDataService "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/in-memory-data.service.ts"
    click HeroModel "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/hero.ts"
    click MockHeroes "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/app/mock-heroes.ts"
    click EnvironmentDev "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/environments/environment.ts"
    click EnvironmentProd "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/environments/environment.prod.ts"
    click MainTS "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/main.ts"
    click Polyfills "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/polyfills.ts"
    click IndexHTML "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/index.html"
    click StylesCSS "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/styles.css"
    click Assets "https://github.com/gmboknat/ng5-tour-of-heroes/tree/master/src/assets/"
    click TestHarness "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/test.ts"
    click KarmaConfig "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/karma.conf.js"
    click SpecTsConfig "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/src/tsconfig.spec.json"
    click ProtractorConfig "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/protractor.conf.js"
    click E2EAppSpec "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/e2e/app.e2e-spec.ts"
    click E2EAppPo "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/e2e/app.po.ts"
    click E2ETsConfig "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/e2e/tsconfig.e2e.json"
    click AngularCLI "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/angular-cli.json"
    click TSConfig "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/tsconfig.json"
    click TSLint "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/tslint.json"
    click PackageJSON "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/package.json"
    click PackageLock "https://github.com/gmboknat/ng5-tour-of-heroes/blob/master/package-lock.json"

    %% Styles
    classDef ui fill:#bbdefb,stroke:#1e88e5,color:#0d47a1,stroke-width:1px
    classDef mod fill:#cfd8dc,stroke:#455a64,color:#263238,stroke-width:1px
    classDef svc fill:#c8e6c9,stroke:#388e3c,color:#1b5e20,stroke-width:1px
    classDef data fill:#dcedc8,stroke:#689f38,color:#33691e,stroke-width:1px
    classDef config fill:#eceff1,stroke:#607d8b,color:#37474f,stroke-width:1px
    classDef test fill:#ffe0b2,stroke:#fb8c00,color:#e65100,stroke-width:1px
```
