# hpatoio/backstage-plugin-language-info architecture

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

- Interactive diagram: https://gitdiagram.com/hpatoio/backstage-plugin-language-info
- Repository: https://github.com/hpatoio/backstage-plugin-language-info

## Overview

- the Language Info Processor (located in packages/backstage-plugin-language-info-processor) which appears to contain the logic needed to process and read language information from different sources (JavaScript, PHP, etc.),
- and the Language Info Card (located in packages/backstage-plugin-language-info-card) which provides a UI component (likely a React-based card component) to display that information within Backstage.

##### Main Components
a. Monorepo Structure: Represent the overall monorepo which is managed by Lerna (noted by lerna.json) and Yarn. This is the container for both plugins.
b. Backstage Plugin – Language Info Processor:
- Main module (packages/backstage-plugin-language-info-processor/src/module.ts) that orchestrates internal functions.
- Lower-level libraries such as LanguageInfoJsReader, LanguageInfoPhpReader, and LanguageInfoProcessor (located under src/libs), which are the building blocks handling logic for processing code language information.
c. Backstage Plugin – Language Info Card:
- UI component (e.g., EntityLanguageInfoCard.tsx in packages/backstage-plugin-language-info-card/src/components) that displays language info.
- Entry points (packages/backstage-plugin-language-info-card/src/index.ts and dev index.tsx for the development setup) where the UI gets rendered and possibly integrated into Backstage.
d. Shared/Support Components:
- Test setups (setupTests.ts, plugin.test.ts, etc.) as proof of quality assurance.
- Configuration files (.eslintrc.js, tsconfig.json, .prettierignore, etc.) that govern code quality and TypeScript configurations.
- CI/CD components (GitHub workflows in .github/workflows) which automate build, test, and release processes.

##### Relationships and Interactions
b. Data Flow:
- How the Language Info Processor reads and processes language-specific source code data (e.g., JavaScript, PHP).
c. Build and Deployment:
- Incorporate how the GitHub workflows and Yarn (with release scripts) automate the testing and deployment of packages, ensuring that quality and integration are maintained.

##### Architectural Patterns or Design Principles
a. Modularization: The monorepo structure emphasizes separation of concerns. Each package (processor and card) is self-contained while cooperating within the Backstage plugin ecosystem.
b. Separation of Concerns: The processor is exclusively handling business logic/data processing, and the card is strictly the presentation layer.
c. Extensibility: The design allows for additional language readers or UI components to be added as new plugins or modules.

##### Relevant Technologies and Frameworks
a. TypeScript is used throughout, given tsconfig.json files and .ts/.tsx sources.
b. React (or an equivalent view library) is likely used in the Language Info Card for building UI components.
c. Lerna manages the monorepo, ensuring dependency and version consistency across packages.
d. GitHub Actions and Husky pre-commit hooks, along with ESLint and Prettier, indicate a strong focus on code quality and automation.

- A clear, labeled block for the overall monorepo/lerna structure.
- Two main blocks for the “Language Info Processor” and “Language Info Card” components.
- Internal subdivisions showing:
– For the Processor: a sub-block for each language reader (e.g., JavaScript and PHP readers) and the orchestrating module.
– For the Card: a sub-block for the main UI component (EntityLanguageInfoCard) and any associated helper modules.
– Data flow from the Processor to the Card.
– Interaction between shared tests/CI configurations and the code components.
- Annotations for technologies (TypeScript, React, Lerna, GitHub Actions) that play a key role in each segment.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Monorepo Structure
    subgraph "Monorepo Structure"
        subgraph "Lerna/Yarn Setup"
            Lerna["lerna.json"]:::config
            Package["package.json"]:::config
            YarnDir[".yarn"]:::config
            Yarnrc[".yarnrc.yml"]:::config
        end

        subgraph "Language Info Processor"
            ProcessorModule["Main Orchestrator Module"]:::logic
            subgraph "Language Reader Libraries"
                JSReader["LanguageInfoJsReader"]:::logic
                PHPReader["LanguageInfoPhpReader"]:::logic
                CoreProcessor["LanguageInfoProcessor Core"]:::logic
            end
            ProcessorTests["Processor Tests/Setup"]:::logic
        end

        subgraph "Language Info Card"
            EntityCard["Entity Language Info Card"]:::ui
            UIEntry["Main UI Entry"]:::ui
            DevUI["Development UI Entry"]:::ui
            CardTests["Card Tests/Setup"]:::ui
        end
    end

    %% Shared/Support Components
    subgraph "Shared/Support Components"
        ESLint["ESLint Config"]:::ci
        TSRoot["TypeScript Config (Root)"]:::ci
        TSCARD["TypeScript Config (Card)"]:::ci
        Prettier["Prettier Config"]:::ci
        WorkflowBuild["GitHub Workflow Build"]:::ci
        WorkflowRelease["GitHub Workflow Release"]:::ci
        HuskyCommit["Husky Commit-msg"]:::ci
        HuskyPre["Husky Pre-commit"]:::ci
    end

    %% Relationships and Data Flow
    JSReader -->|"calls"| ProcessorModule
    PHPReader -->|"calls"| ProcessorModule
    CoreProcessor -->|"processes"| ProcessorModule
    ProcessorModule -->|"providesData"| EntityCard
    UIEntry -->|"renders"| EntityCard
    DevUI -->|"renders"| EntityCard

    %% Integration with Shared Components
    ESLint --- ProcessorTests
    Prettier --- ProcessorTests
    WorkflowBuild --- ProcessorModule
    WorkflowRelease --- ProcessorModule
    HuskyCommit --- Package
    HuskyPre --- Package
    TSRoot --- ProcessorModule
    TSRoot --- TSCARD

    %% Click Events for Monorepo Structure (Lerna/Yarn Setup)
    click Lerna "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/lerna.json"
    click Package "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/package.json"
    click YarnDir "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/.yarn"
    click Yarnrc "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/.yarnrc.yml"

    %% Click Events for Language Info Processor
    click ProcessorModule "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-processor/src/module.ts"
    click JSReader "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-processor/src/libs/LanguageInfoJsReader.ts"
    click PHPReader "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-processor/src/libs/LanguageInfoPhpReader.ts"
    click CoreProcessor "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-processor/src/libs/LanguageInfoProcessor.ts"
    click ProcessorTests "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-processor/src/setupTests.ts"

    %% Click Events for Language Info Card
    click EntityCard "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-card/src/components/EntityLanguageInfoCard.tsx"
    click UIEntry "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-card/src/index.ts"
    click DevUI "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-card/dev/index.tsx"
    click CardTests "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-card/src/plugin.test.ts"

    %% Click Events for Shared/Support Components
    click ESLint "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/.eslintrc.js"
    click TSRoot "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/tsconfig.json"
    click TSCARD "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/packages/backstage-plugin-language-info-card/tsconfig.json"
    click Prettier "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/.prettierignore"
    click WorkflowBuild "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/.github/workflows/build.yml"
    click WorkflowRelease "https://github.com/hpatoio/backstage-plugin-language-info/blob/main/.github/workflows/release.yml"
    click HuskyCommit "https://github.com/hpatoio/backstage-plugin-language-info/tree/main/.husky/commit-msg"
    click HuskyPre "https://github.com/hpatoio/backstage-plugin-language-info/tree/main/.husky/pre-commit"

    %% Styles
    classDef config fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef logic fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef ui fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef ci fill:#FFA07A,stroke:#333,stroke-width:2px;
```
