# other-blowsnow/n8n-nodes-feishu-lite architecture

> Architecture diagram of the GitHub repository other-blowsnow/n8n-nodes-feishu-lite, 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/other-blowsnow/n8n-nodes-feishu-lite
- Repository: https://github.com/other-blowsnow/n8n-nodes-feishu-lite

## Overview

##### Main Components
- n8n Core Integration: Represented by files such as index.js and the various node definitions (nodes/FeishuNode).
- Feishu Node Module: The heart of the integration is the “FeishuNode” folder. This contains the main node file (FeishuNode.node.ts) which acts as the entry point.
- Resource Layer: Under the “resource” folder are sub-folders (e.g. auth, bitable, calendar, doc, message, space, spreadsheet, task, user, wiki_spaces) that implement different operations. Each resource folder contains multiple operation “classes” (e.g., AuthGetAccessToken, CalendarEventCreateOperate, BitableTableRecrodUpdateOperate, etc.) which map directly to specific API calls to Feishu services.
- Helper and Builder Utilities: In the “nodes/help” directory are resources like ResourceBuilder.ts, ResourceFactory.ts, and utilities for module loading, node utilities, and request utilities. These components help dynamically build and load the available resources.
- Credentials Handling: There is a “credentials” folder that holds the Feishu credentials API integration configuration.

##### Relationships and Interactions
- At a high level, the n8n framework loads the custom node (FeishuNode). Within the node, when a specific Feishu API action is selected via the UI, the corresponding resource class (from one of the resource subdirectories) is dynamically loaded and executed.
- The ResourceFactory and ResourceBuilder in the “nodes/help” folder are responsible for mapping requests from the node into actual API call operations. They determine which resource implementation to invoke based on the user’s configuration or the workflow context.
- The credentials resources tie in, supplying authentication tokens (e.g., via AuthResource and AuthGetAccessToken) which are prerequisites for all API interactions.
- Each resource class is designed to encapsulate one specific action (e.g., creating a calendar event, sending a message, updating a task) and they are potentially grouped/organized based on service type.

##### Architectural Patterns & Design Principles
- Modular Structure: The project is divided into discrete modules by service type. Each service (calendar, doc, message, etc.) has its operations encapsulated in separate files, allowing easy extension and maintainability.
- Factory/Builder Pattern: The use of a ResourceFactory and ResourceBuilder suggests the application is employing these design patterns to instantiate different resource operations dynamically.
- Clear Separation of Concerns: The node definition encapsulates general behavior while each resource class handles its own API operation, along with helper utilities managing shared functionality.
- Naming Convention: By having clearly named files and folders, the project follows a convention that correlates specific functionality with its location in the file tree (e.g., “calendar” related operations in calendar subfolder).

- Use clear labels: “n8n Feishu Integration Node”, “Resource: Calendar Operations”, “Resource: Doc Operations”, etc.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Workflow Engine
    workflow("N8N Workflow Engine"):::external

    %% n8n Core Integration Subgraph
    subgraph "n8n Core Integration"
        core1("index.js"):::core
        core2("FeishuNode.node.ts"):::core
    end

    %% Feishu Node Module Subgraph
    subgraph "Feishu Node Module"
        feishuModule("Feishu Node Module"):::core
    end

    %% Resource Layer Subgraph
    subgraph "Resource Layer"
        authRes("AuthResource"):::resource
        authToken("AuthGetAccessToken"):::resource
        bitableRes("BitableResource"):::resource
        calendarRes("CalendarResource"):::resource
        docRes("DocResource"):::resource
        messageRes("MessageResource"):::resource
        spaceRes("SpaceResource"):::resource
        spreadsheetRes("SpreadsheetResource"):::resource
        taskRes("TaskResource"):::resource
        userRes("UserResource"):::resource
        wikiRes("WikiSpacesResource"):::resource
    end

    %% Helper and Builder Utilities Subgraph
    subgraph "Helper and Builder Utilities"
        resourceBuilder("ResourceBuilder"):::helper
        resourceFactory("ResourceFactory"):::helper
        moduleLoad("ModuleLoadUtils"):::helper
        nodeUtils("NodeUtils"):::helper
        requestUtils("RequestUtils"):::helper
        iresource("IResource"):::helper
    end

    %% Credentials Handling Subgraph
    subgraph "Credentials Handling"
        credentials("Feishu Credentials API"):::cred
    end

    %% External Feishu API Endpoints
    feishuAPI("Feishu API Endpoints"):::external

    %% Connections
    workflow --> core1
    workflow --> core2
    core1 --> feishuModule
    core2 --> feishuModule

    feishuModule --> resourceFactory
    feishuModule --> resourceBuilder

    resourceFactory --> authRes
    resourceFactory --> bitableRes
    resourceFactory --> calendarRes
    resourceFactory --> docRes
    resourceFactory --> messageRes
    resourceFactory --> spaceRes
    resourceFactory --> spreadsheetRes
    resourceFactory --> taskRes
    resourceFactory --> userRes
    resourceFactory --> wikiRes

    authRes --> authToken
    credentials --> authRes

    authRes --> feishuAPI
    authToken --> feishuAPI
    bitableRes --> feishuAPI
    calendarRes --> feishuAPI
    docRes --> feishuAPI
    messageRes --> feishuAPI
    spaceRes --> feishuAPI
    spreadsheetRes --> feishuAPI
    taskRes --> feishuAPI
    userRes --> feishuAPI
    wikiRes --> feishuAPI

    %% Click Events for n8n Core Integration
    click core1 "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/index.js"
    click core2 "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/FeishuNode.node.ts"

    %% Click Events for Feishu Node Module
    click feishuModule "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/tree/master/nodes/FeishuNode"

    %% Click Events for Resource Layer
    click authRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/AuthResource.ts"
    click authToken "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/auth/AuthGetAccessToken.ts"
    click bitableRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/BitableResource.ts"
    click calendarRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/CalendarResource.ts"
    click docRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/DocResource.ts"
    click messageRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/MessageResource.ts"
    click spaceRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/SpaceResource.ts"
    click spreadsheetRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/SpreadsheetResource.ts"
    click taskRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/TaskResource.ts"
    click userRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/UserResource.ts"
    click wikiRes "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/FeishuNode/resource/WikiSpacesResource.ts"

    %% Click Events for Helper and Builder Utilities
    click resourceBuilder "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/help/builder/ResourceBuilder.ts"
    click resourceFactory "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/help/builder/ResourceFactory.ts"
    click moduleLoad "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/help/utils/ModuleLoadUtils.ts"
    click nodeUtils "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/help/utils/NodeUtils.ts"
    click requestUtils "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/help/utils/RequestUtils.ts"
    click iresource "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/nodes/help/type/IResource.ts"

    %% Click Event for Credentials Handling
    click credentials "https://github.com/other-blowsnow/n8n-nodes-feishu-lite/blob/master/credentials/FeishuCredentialsApi.credentials.ts"

    %% Styles
    classDef core fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef resource fill:#99CCFF,stroke:#333,stroke-width:2px;
    classDef helper fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef cred fill:#FF9999,stroke:#333,stroke-width:2px;
    classDef external fill:#CCCCCC,stroke:#333,stroke-width:2px;
```
