# line/line-openapi architecture

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

- Interactive diagram: https://gitdiagram.com/line/line-openapi
- Repository: https://github.com/line/line-openapi

## Overview

##### Main Components

a. API Specification Files:
- These are the core of the repository and include the YAML files (channel-access-token.yml, insight.yml, liff.yml, manage-audience.yml, messaging-api.yml, module.yml, module-attach.yml, shop.yml, webhook.yml).
- Each file targets a specific LINE API endpoint and supports a particular OpenAPI version.

b. CI/CD & Workflow Automation:
- The .github directory holds the workflows (ci.yml, close-issue.yml, sdk-testing.yml) which automate tests, issue management, and SDK testing.
- The custom GitHub Action under .github/actions (specifically the post-comment-action) is a key component in automating developer interactions or notifications.

c. Custom Tooling:
- A collection of scripts under the tools directory (e.g., determine-change-type.mjs, generate-test.mjs, validate-all.mjs, etc.) provides functions for testing, validating changes, and reformatting.
- These tools support the automation and quality assurance parts of the project.

d. Configuration and Metadata Files:
- Files like package.json, package-lock.json, renovate.json5, .spectral.yaml, and others provide project metadata, dependency management, linting, and configuration guidelines.

##### Relationships and Interactions

- The various OpenAPI spec files serve as the primary functional components, defining the public APIs and their interactions with LINE's services.
- The CI/CD workflows interact with these spec files by triggering validations, tests, and formatting checks whenever changes occur or pull requests are raised.
- The custom tools in the tools directory support the workflows by automating tasks such as determining change types or validating request structures, and these tools are invoked through the CI/CD pipelines.
- The GitHub Action (post-comment-action) is designed to provide automated responses or notifications based on workflow outcomes, closing the loop between human operators and automated processes.

##### Architectural Patterns and Design Principles

- Modular Design: Each API spec is isolated in its own YAML file, making it easy to manage and extend.
- Automation and Continuous Integration: The integration of GitHub Actions and custom Node.js scripts showcases a strong emphasis on automation, continuous testing, and validation.
- Separation of Concerns: There is a clear separation between the core specifications (which define the API contracts) and the tooling/automation scripts (which ensure quality and consistency).

##### Technologies, Frameworks, and Tools

- GitHub Actions for workflow automation (CI/CD pipelines, SDK testing, issue management).
- Node.js for running the custom tooling scripts (observed by the usage of package.json and .mjs files).
- OpenAPI specification standards referenced in the YAML files, along with version numbers (3.0.0, 3.0.2, and 3.0.3).
- Additional configuration tools such as Spectral for linting the OpenAPI specs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "OpenAPI Specifications"
        CA["Channel Access Token API"]:::openapi
        IN["Insight API"]:::openapi
        LF["LIFF API"]:::openapi
        MA["Manage Audience API"]:::openapi
        MS["Messaging API"]:::openapi
        MO["Module API"]:::openapi
        MA2["Module Attach API"]:::openapi
        SH["Shop API"]:::openapi
        WH["Webhook API"]:::openapi
    end

    subgraph "CI/CD & Workflow Automation"
        GW["GitHub Workflows"]:::cicd
        CGA["Custom GitHub Action"]:::cicd
    end

    subgraph "Custom Tooling"
        DCT["Determine Change Type"]:::tooling
        GT["Generate Test"]:::tooling
        GPI["Get PR Info"]:::tooling
        RF["Reformat"]:::tooling
        VA["Validate All"]:::tooling
        VI["Validate Inheritance"]:::tooling
        VRS["Validate Request Suffix"]:::tooling
    end

    subgraph "Configuration and Metadata"
        PJ["Package.json"]:::config
        PLJ["Package-lock.json"]:::config
        REN["Renovate.json5"]:::config
        SPE[".spectral.yaml"]:::config
    end

    %% Data Flow Connections
    WH -->|"triggers"| GW
    GW -->|"invokes"| DCT
    GW -->|"invokes"| GT
    CGA -->|"notifies"| GT
    RF -->|"uses"| PJ
    VA -->|"refers"| PJ
    VI -->|"checks"| REN

    %% Click Events for API Specification Files
    click CA "https://github.com/line/line-openapi/blob/main/channel-access-token.yml"
    click IN "https://github.com/line/line-openapi/blob/main/insight.yml"
    click LF "https://github.com/line/line-openapi/blob/main/liff.yml"
    click MA "https://github.com/line/line-openapi/blob/main/manage-audience.yml"
    click MS "https://github.com/line/line-openapi/blob/main/messaging-api.yml"
    click MO "https://github.com/line/line-openapi/blob/main/module.yml"
    click MA2 "https://github.com/line/line-openapi/blob/main/module-attach.yml"
    click SH "https://github.com/line/line-openapi/blob/main/shop.yml"
    click WH "https://github.com/line/line-openapi/blob/main/webhook.yml"

    %% Click Events for CI/CD & Workflow Automation
    click GW "https://github.com/line/line-openapi/tree/main/.github/workflows"
    click CGA "https://github.com/line/line-openapi/tree/main/.github/actions/post-comment-action"

    %% Click Events for Custom Tooling
    click DCT "https://github.com/line/line-openapi/blob/main/tools/determine-change-type.mjs"
    click GT "https://github.com/line/line-openapi/blob/main/tools/generate-test.mjs"
    click GPI "https://github.com/line/line-openapi/blob/main/tools/get-pr-info.mjs"
    click RF "https://github.com/line/line-openapi/blob/main/tools/reformat.mjs"
    click VA "https://github.com/line/line-openapi/blob/main/tools/validate-all.mjs"
    click VI "https://github.com/line/line-openapi/blob/main/tools/validate-inheritance.mjs"
    click VRS "https://github.com/line/line-openapi/blob/main/tools/validate-request-suffix.mjs"

    %% Click Events for Configuration and Metadata Files
    click PJ "https://github.com/line/line-openapi/blob/main/package.json"
    click PLJ "https://github.com/line/line-openapi/blob/main/package-lock.json"
    click REN "https://github.com/line/line-openapi/blob/main/renovate.json5"
    click SPE "https://github.com/line/line-openapi/blob/main/.spectral.yaml"

    %% Styles
    classDef openapi fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef cicd fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef tooling fill:#A3E4D7,stroke:#16A085,stroke-width:2px;
    classDef config fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
