# vaagnavanesyan/onyx architecture

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

- Interactive diagram: https://gitdiagram.com/vaagnavanesyan/onyx
- Repository: https://github.com/vaagnavanesyan/onyx

## Overview

##### Main Components
- Nx Workspace/Build System: At the highest level, represent Nx as the “orchestrator” that ties all projects together. Mention that it manages task execution, dependency graphing, and caching.
- Applications (Menu):
- “americano”, “latte”, “tea”: Each of these is generated as an application (with their corresponding e2e projects for end-to-end testing) that forms part of the “menu”. They are likely the entry points that users interact with.
- Libraries (Kitchen):
- “water”, “tea-leaves”, “espresso”: Standard libraries for internal use.
- “roasted-beans”, “ground-coffee”: These libraries are marked as publishable and bundled with tsc, indicating they might be consumed externally as well as by the applications.
- Testing Components: Include both unit (Jest-based library tests inside each project) and end-to-end tests (e2e projects found in the “menu” folder).

##### Relationships and Interactions
- That the applications (from the menu directory) depend on one or more libraries from the kitchen. For example, the “americano” app might rely on shared functionalities provided by these libraries.
- Testing environment separately by drawing connections from each application to its corresponding e2e test project.
- How Nx acts as the central tool that runs tasks across these projects (command-line generators, build tasks, and tests).
- Grouping or modular boundaries: the “menu” (apps) and the “kitchen” (libraries) are logically separate, with clearly defined communication contracts (via API calls or shared functions).

##### Architectural Patterns and Design Principles
- Monorepo Modular Architecture: Emphasize the separation of concerns between applications and libraries, following the modular monorepo approach.
- Generation and Consistency: The Nx CLI commands (as shown in the README) indicate a pattern where new applications and libraries are created with a standardized structure.
- Reusability and Publishability: Note that some libraries (“roasted-beans” and “ground-coffee”) are configured for publishing, suggesting a design that supports code reuse across projects.

##### Incorporate Technologies and Tools
- Nx Build System: Mention that Nx (with its caching, task orchestration, and remote caching potential) is central to how the system is built and maintained.
- Jest: All projects include Jest configuration files, so testing (both unit tests and e2e tests) is a critical component.
- ESLint and Prettier: The presence of these configuration files indicates a focus on code quality and styling across the monorepo.
- TypeScript: The tsconfig files in each project emphasize that the entire workspace is developed using TypeScript.

##### Overall Approach
- “menu” on one side (or as a separate layer) listing the Node applications, and “kitchen” on the other side listing the libraries.
- Applications to their underlying libraries, and also include test components.
- Boundaries where code generation, CI/CD configurations, and repository-level tools (like ESLint, Prettier, and Nx caching) are applied.

## Diagram (Mermaid)

```mermaid
flowchart TD
    NX["Nx (Orchestrator)"]:::nxFill
    JEST["Jest Configurations"]:::configFill

    subgraph "Menu (Applications)"
        AMERO["americano"]:::appFill
        AMERO_E2E["americano-e2e"]:::testFill
        LATTE["latte"]:::appFill
        LATTE_E2E["latte-e2e"]:::testFill
        TEA["tea"]:::appFill
        TEA_E2E["tea-e2e"]:::testFill
    end

    subgraph "Kitchen (Libraries)"
        WATER["water"]:::libFill
        TEA_LEAVES["tea-leaves"]:::libFill
        ESPRESSO["espresso"]:::libFill
        ROASTED_BEANS["roasted-beans"]:::libFill
        GROUND_COFFEE["ground-coffee"]:::libFill
    end

    %% Nx orchestrates tasks for all components
    NX --> AMERO
    NX --> LATTE
    NX --> TEA
    NX --> WATER
    NX --> TEA_LEAVES
    NX --> ESPRESSO
    NX --> ROASTED_BEANS
    NX --> GROUND_COFFEE
    NX --> JEST

    %% Applications connected to their end-to-end tests
    AMERO -->|"e2e"| AMERO_E2E
    LATTE -->|"e2e"| LATTE_E2E
    TEA   -->|"e2e"| TEA_E2E

    %% Sample dependencies from applications to libraries
    AMERO -->|"uses"| ESPRESSO
    LATTE -->|"uses"| WATER
    TEA   -->|"uses"| TEA_LEAVES

    %% Styles and Classes
    classDef nxFill fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef appFill fill:#90EE90,stroke:#000,stroke-width:2px,rx:10,ry:10;
    classDef libFill fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef testFill fill:#FFFFE0,stroke:#000,stroke-width:2px,stroke-dasharray: 5,5;
    classDef configFill fill:#D3D3D3,stroke:#000,stroke-width:2px;

    %% Click Events for Nx Workspace/Build System
    click NX "https://github.com/vaagnavanesyan/onyx/blob/main/nx.json"
    click NX "https://github.com/vaagnavanesyan/onyx/blob/main/package.json"
    click NX "https://github.com/vaagnavanesyan/onyx/blob/main/project.json"
    click NX "https://github.com/vaagnavanesyan/onyx/blob/main/tsconfig.base.json"

    %% Click Events for Applications and their e2e tests
    click AMERO "https://github.com/vaagnavanesyan/onyx/tree/main/menu/americano"
    click AMERO_E2E "https://github.com/vaagnavanesyan/onyx/tree/main/menu/americano-e2e"
    click LATTE "https://github.com/vaagnavanesyan/onyx/tree/main/menu/latte"
    click LATTE_E2E "https://github.com/vaagnavanesyan/onyx/tree/main/menu/latte-e2e"
    click TEA "https://github.com/vaagnavanesyan/onyx/tree/main/menu/tea"
    click TEA_E2E "https://github.com/vaagnavanesyan/onyx/tree/main/menu/tea-e2e"

    %% Click Events for Libraries in the Kitchen
    click WATER "https://github.com/vaagnavanesyan/onyx/tree/main/kitchen/water"
    click TEA_LEAVES "https://github.com/vaagnavanesyan/onyx/tree/main/kitchen/tea-leaves"
    click ESPRESSO "https://github.com/vaagnavanesyan/onyx/tree/main/kitchen/espresso"
    click ROASTED_BEANS "https://github.com/vaagnavanesyan/onyx/tree/main/kitchen/roasted-beans"
    click GROUND_COFFEE "https://github.com/vaagnavanesyan/onyx/tree/main/kitchen/ground-coffee"

    %% Click Events for Jest Testing Configuration
    click JEST "https://github.com/vaagnavanesyan/onyx/blob/main/jest.config.ts"
    click JEST "https://github.com/vaagnavanesyan/onyx/blob/main/jest.preset.js"
```
