# cognizone/ng-cognizone architecture

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

- Interactive diagram: https://gitdiagram.com/cognizone/ng-cognizone
- Repository: https://github.com/cognizone/ng-cognizone

## Overview

##### Project Type and Purpose
- This is an Nx-powered monorepo hosting multiple Angular applications and libraries under the `@cognizone` namespace.
- Primary deliverables:
- “docs-app” – an Angular documentation site
- “docs” – a Docusaurus static site project
- “elastic-explorer-chrome-extension” – an Angular-based Chrome extension
- End-to-End test apps (Cypress) for each application
- A large set of reusable, publishable Angular libraries (in `libs/`) such as UI-kits, data models, domain services, CLI tooling, and core utilities.
- Development support: Storybook for UI components, Jest for unit tests, Cypress for E2E, Husky for git hooks, Prettier/ESLint for formatting & linting, and GitHub Actions for CI/CD.

##### Top-Level Architectural View
- Inside it, partition into zones:
- Applications (`apps/`)
- Libraries (`libs/`)
- Tooling & Scripts (`tools/`, `.github/workflows/`, Husky, Nx Cloud config)
- Documentation (`docs/`, Storybook config)

##### Main Components
a. Applications Layer (Blue)
- docs-app (Angular SPA)
- docs (Docusaurus site)
- elastic-explorer-chrome-extension (Angular Chrome extension)
- E2E test runners (Cypress projects under `apps/*-e2e`)
b. Libraries Layer (Green), grouped by domain:
- Angular CDK Helpers: `cdk`
- Data Models & Services: `json-model`, `json-model-graph`, `model-utils`, `elastic`, `json-ld-core`, `lod-core`, `shacl-core`
- Domain Profile: `application-profile`, `ng-application-profile`, `legi-cv`, `user-action`, `permissions`, `operation`, `seo`, `i18n`, `i18n-transloco`, `transloco-langstring`
- Tooling & CLI: `cli`, `eslint-config`, `prettier-config`, `tslint-config`, `html-diff`, `devtools`, `seo`
c. Tooling & Workflow (Orange)
- Nx CLI orchestrator & dependency graph (nx.json)
- Angular CLI integration
- Jest (unit tests)
- Cypress (E2E tests)
- Storybook (component library preview)
- Husky (git hooks), Prettier & ESLint
- GitHub Actions: CI build (`ci.yml`), docs deploy (`deploy-docs.yml`), release pipeline (`release.yml`)
- Nx Cloud (computation caching)
d. External Services (Purple)
- npm registry (publishing libs)
- GitHub (repo, Actions)
- Browsers (Chrome for extension)

##### Component Relationships & Data Flows
- Inter-library dependencies (e.g., `json-model` → `lod-core`; `json-ld-core` → `json-ld`; UI libs → CDK helpers).
- Nx CLI at center orchestrating build/test/lint tasks across apps and libs.
- From Developers’ IDE workstations point to Husky hooks and Nx CLI.

##### Architectural Patterns & Principles
- Monorepo modularity: clearly separate apps vs. libraries, share code via public API surfaces and `importPath="@cognizone/…”`.
- “Library-first” design: each feature or domain vector encapsulated as its own npm-publishable package.
- Layered architecture: UI components, core utilities, data models, domain-specific services.
- CI/CD as code: workflows live in `.github/workflows`, automatic docs deployment and library publishing.
- Dev feedback loops: Storybook, Jest, Cypress, Nx Dependency Graph for instant visibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Nx Workspace"
        direction TB

        subgraph "Applications" 
            direction TB
            docs_app["docs-app (Angular SPA)"]:::app
            docs["docs (Docusaurus site)"]:::app
            ext["elastic-explorer-chrome-extension"]:::app
            docs_app_e2e["docs-app-e2e (Cypress)"]:::app
            ext_e2e["elastic-explorer-chrome-extension-e2e"]:::app
            ui_kit_e2e["ui-kit-e2e"]:::app
        end

        subgraph "Libraries"
            direction TB
            ui_kit["ui-kit"]:::lib
            legi_shared["legi-shared"]:::lib
            legi_styles["legi-styles"]:::lib
            material_icons["material-icons"]:::lib
            cdk["cdk"]:::lib
            json_model["json-model"]:::lib
            json_model_graph["json-model-graph"]:::lib
            model_utils["model-utils"]:::lib
            elastic["elastic"]:::lib
            json_ld_core["json-ld-core"]:::lib
            lod_core["lod-core"]:::lib
            shacl_core["shacl-core"]:::lib
            application_profile["application-profile"]:::lib
            ng_application_profile["ng-application-profile"]:::lib
            legi_cv["legi-cv"]:::lib
            user_action["user-action"]:::lib
            permissions["permissions"]:::lib
            operation["operation"]:::lib
            seo_lib["seo (lib)"]:::lib
            i18n["i18n"]:::lib
            i18n_transloco["i18n-transloco"]:::lib
            transloco_langstring["transloco-langstring"]:::lib
            cli_tool["cli (codegen CLI)"]:::tool
            devtools["devtools"]:::tool
            html_diff["html-diff"]:::tool
            eslint_config["eslint-config"]:::tool
            prettier_config["prettier-config"]:::tool
            tslint_config["tslint-config"]:::tool
        end

        subgraph "Tooling & Scripts"
            direction TB
            nx_cli["Nx CLI (nx.json)"]:::tool
            decorate_cli["decorate-angular-cli.js"]:::tool
            executors["tools/executors"]:::tool
            husky[".husky"]:::tool
            gh_ci[".github/workflows/ci.yml"]:::tool
            gh_deploy[".github/workflows/deploy-docs.yml"]:::tool
            gh_release[".github/workflows/release.yml"]:::tool
            jest["Jest Config"]:::tool
            storybook["Storybook"]:::tool
        end

        subgraph "Documentation"
            direction TB
            docs_output["Docusaurus Build Output"]:::doc
            api_html["API HTML Docs"]:::doc
        end
    end

    subgraph "External Services"
        npm["npm Registry"]:::external
        github["GitHub & Actions"]:::external
        browser["Chrome Browser"]:::external
        ide["Developer IDE"]:::external
    end

    %% Dependencies Apps->Libs
    docs_app -->|imports| legi_shared
    docs_app -->|imports| model_utils
    ext -->|imports| elastic
    ext -->|imports| legi_shared

    %% Inter-library dependencies
    json_model -->|uses| lod_core
    json_ld_core -->|uses| json_ld_core

    %% E2E flows
    docs_app_e2e -->|tests| docs_app
    ext_e2e -->|tests| ext
    ui_kit_e2e -->|tests| ui_kit

    %% Storybook preview
    storybook -->|previews| ui_kit

    %% Tooling orchestration
    github -->|triggers| nx_cli
    ide -.->|hooks| husky
    nx_cli -->|runs| docs_app
    nx_cli -->|runs| ui_kit
    nx_cli -->|builds| docs
    nx_cli -->|tests| docs_app_e2e
    nx_cli -->|tests| ext_e2e

    %% Publishing
    nx_cli -->|publishes| npm

    %% Documentation output
    docs -->|outputs to| docs_output
    docs_app -->|generates API docs| api_html

    %% Click Events
    click docs_app "https://github.com/cognizone/ng-cognizone/tree/main/apps/docs-app"
    click docs "https://github.com/cognizone/ng-cognizone/tree/main/apps/docs"
    click ext "https://github.com/cognizone/ng-cognizone/tree/main/apps/elastic-explorer-chrome-extension"
    click docs_app_e2e "https://github.com/cognizone/ng-cognizone/tree/main/apps/docs-app-e2e"
    click ext_e2e "https://github.com/cognizone/ng-cognizone/tree/main/apps/elastic-explorer-chrome-extension-e2e"
    click ui_kit_e2e "https://github.com/cognizone/ng-cognizone/tree/main/apps/ui-kit-e2e"
    click ui_kit "https://github.com/cognizone/ng-cognizone/tree/main/libs/ui-kit"
    click legi_shared "https://github.com/cognizone/ng-cognizone/tree/main/libs/legi-shared"
    click legi_styles "https://github.com/cognizone/ng-cognizone/tree/main/libs/legi-styles"
    click material_icons "https://github.com/cognizone/ng-cognizone/tree/main/libs/material-icons"
    click cdk "https://github.com/cognizone/ng-cognizone/tree/main/libs/cdk"
    click json_model "https://github.com/cognizone/ng-cognizone/tree/main/libs/json-model"
    click json_model_graph "https://github.com/cognizone/ng-cognizone/tree/main/libs/json-model-graph"
    click model_utils "https://github.com/cognizone/ng-cognizone/tree/main/libs/model-utils"
    click elastic "https://github.com/cognizone/ng-cognizone/tree/main/libs/elastic"
    click json_ld_core "https://github.com/cognizone/ng-cognizone/tree/main/libs/json-ld-core"
    click lod_core "https://github.com/cognizone/ng-cognizone/tree/main/libs/lod-core"
    click shacl_core "https://github.com/cognizone/ng-cognizone/tree/main/libs/shacl-core"
    click application_profile "https://github.com/cognizone/ng-cognizone/tree/main/libs/application-profile"
    click ng_application_profile "https://github.com/cognizone/ng-cognizone/tree/main/libs/ng-application-profile"
    click legi_cv "https://github.com/cognizone/ng-cognizone/tree/main/libs/legi-cv"
    click user_action "https://github.com/cognizone/ng-cognizone/tree/main/libs/user-action"
    click permissions "https://github.com/cognizone/ng-cognizone/tree/main/libs/permissions"
    click operation "https://github.com/cognizone/ng-cognizone/tree/main/libs/operation"
    click seo_lib "https://github.com/cognizone/ng-cognizone/tree/main/libs/seo"
    click i18n "https://github.com/cognizone/ng-cognizone/tree/main/libs/i18n"
    click i18n_transloco "https://github.com/cognizone/ng-cognizone/tree/main/libs/i18n-transloco"
    click transloco_langstring "https://github.com/cognizone/ng-cognizone/tree/main/libs/transloco-langstring"
    click cli_tool "https://github.com/cognizone/ng-cognizone/tree/main/libs/cli"
    click devtools "https://github.com/cognizone/ng-cognizone/tree/main/libs/devtools"
    click html_diff "https://github.com/cognizone/ng-cognizone/tree/main/libs/html-diff"
    click eslint_config "https://github.com/cognizone/ng-cognizone/tree/main/libs/eslint-config"
    click prettier_config "https://github.com/cognizone/ng-cognizone/tree/main/libs/prettier-config"
    click tslint_config "https://github.com/cognizone/ng-cognizone/tree/main/libs/tslint-config"
    click nx_cli "https://github.com/cognizone/ng-cognizone/blob/main/nx.json"
    click decorate_cli "https://github.com/cognizone/ng-cognizone/blob/main/decorate-angular-cli.js"
    click executors "https://github.com/cognizone/ng-cognizone/tree/main/tools/executors"
    click husky "https://github.com/cognizone/ng-cognizone/blob/main/.husky"
    click gh_ci "https://github.com/cognizone/ng-cognizone/blob/main/.github/workflows/ci.yml"
    click gh_deploy "https://github.com/cognizone/ng-cognizone/blob/main/.github/workflows/deploy-docs.yml"
    click gh_release "https://github.com/cognizone/ng-cognizone/blob/main/.github/workflows/release.yml"
    click storybook "https://github.com/cognizone/ng-cognizone/blob/main/.storybook"

    classDef app fill:#D0E8FF,stroke:#005B96,stroke-width:2px
    classDef lib fill:#E4F7D2,stroke:#3A7D0B,stroke-width:2px
    classDef tool fill:#FFEFD5,stroke:#FF8C00,stroke-width:2px
    classDef external fill:#F0E6FF,stroke:#6A0DAD,stroke-width:2px
    classDef doc fill:#FFF5E6,stroke:#DAA520,stroke-width:2px
```
