DataRoom Documentation

repository·master·Indexed 21 days ago

https://github.com/gcpaas/dataroom

An open-source, full-stack solution for designing and deploying data dashboards and web pages. It features grid-based and absolute-positioning designers, AI-assisted creation via the MCP protocol, and connectivity to 20+ data sources including relational databases, NoSQL, real-time streams, and files. The system includes a Vue 3 and TypeScript-based frontend (data-room-front v3.4.0) with specialized components like DrAlarmImage for metric-based visual alerts.

Tokens
71.8K
Snippets
177
Records
220
Agent score
74%

What's inside DataRoom

  1. Overview of DataRoom capabilities

    master

    DataRoom is an open-source, all-in-one solution for designing, previewing, and publishing large screens (dashboards) and web pages. It provides a complete workflow: from connecting data sources and performing data cleaning to designing layouts and deploying them.

    Key features include:

    • Dual Design Modes: A Page Designer using a grid layout for low-code responsive web pages, and a Large Screen Designer using absolute positioning for flexible, high-fidelity dashboard layouts.
    • AI-Powered Creation: Supports creating screens and pages via conversational AI using the MCP (Model Context Protocol) and SKILL.
    • Extensive Data Support: Connects to 20+ data sources including traditional databases (MySQL, PostgreSQL, Oracle, etc.), NoSQL (MongoDB, ElasticSearch), real-time streams (MQTT, WebSocket), and file formats (Excel, CSV).
    • Dataset Management: Create custom datasets using JSON, SQL, HTTP, ES, Excel, or WebSocket.
    • Asset Management: A centralized library for images, videos, and 3D models with support for S3-compatible storage (MinIO, Ceph, etc.).
    • Security & Integration: Includes user/role/permission management, access logs, and support for Single Sign-On (SSO) with frameworks like RuoYi.
  2. Understand the origin of datav components

    master

    The components located in the dataRoomFront/src/dataRoom/datav directory are modified versions of the DataV-Vue3 library. They were copied and customized from the following repositories instead of being imported as a standard dependency to allow for future project-specific customizations:

  3. Use the Chart Data Transform Script

    master

    The transformChartData function allows designers to write custom JavaScript logic to process dataset data before it is rendered by a chart component. This is configured via the script property within the chart.dataset object.

    When a script is provided, it is executed within a specialized bep (Business Execution Platform) context. This context provides access to the chart configuration, the raw data, component parameters, and global variables.

    Key features of the bep context:

    • bep.data: The raw dataset received from the API.
    • bep.params: An object containing the current component parameters.
    • bep.globals: An interface to interact with global variables via .get(name) and .set(name, value).
    • bep.chart: The current ChartConfig.
    • bep.canvasInst: The canvas instance for low-level interactions.

    If the script is empty, the original data is returned. If the script fails or does not return a value, the function returns an empty array [] and logs a warning or error.

    // Example of a transformation script
    const region = bep.globals.get('region')
    return bep.data
      .filter(item => item.region === region)
      .map(item => ({
        time: item.month,
        value: Number(item.amount),
        year: bep.params.year,
      }))
  4. Data transformation pattern: transformProps

    master
    In the dataRoomFront design architecture, every component implements its own transformProps. This mechanism is used to convert raw data returned from a dataset into the specific props format required by the chart or visualization component.
  5. AI Generation via MCP Protocol

    master
    DataRoom supports AI-driven creation of dashboards and pages. It implements the MCP (Model Context Protocol), allowing you to connect external AI tools to DataRoom. Users can interact with the system via dialogue (e.g., "Use MCP to help me create a 618 monitoring dashboard") to automatically generate layouts and components.
  6. Use the `bep` context in data processing scripts

    master

    When executing a processing script, a single bep object is injected into the scope. This object provides access to the component's environment, similar to high-code component event interactions.

    bep Object Structure:

    • canvasInst: The current canvas instance.
    • chart: The current component configuration (including the script itself).
    • data: The dataset results.
      • In normal refresh scenarios, this is the normalized data from run4Chart.
      • In real-time subscription scenarios, this is the data pushed by the server before it reaches the component.
    • params: The parameters used for the current data request or subscription (retrieved via canvasInst.fillDatasetParams(chart)).
    • globals: An object for interacting with global variables:
      • get(name: string): unknown: Reads a global variable.
      • set(name: string, value: string): void: Updates a static global variable.
    {
      canvasInst,
      chart,
      data,
      params,
      globals: {
        get(name: string): unknown,
        set(name: string, value: string): void
      }
    }
  7. Convert flattened fields to a nested JSON tree

    master

    The tools getComponentConfig, getPageConfig, and getVisualScreenPageConfig return a flattened list of fields. To use these as component configurations, you must manually convert them into a nested JSON tree structure.

    Conversion Rule: Use the dot (.) in field names to represent nesting levels.

    Example: If a field name is style.color, it must be transformed into:

    { "style": { "color": "value" } }
    // Example transformation
    // Input: "style.color"
    // Output:
    {
      "style": {
        "color": "value"
      }
    }
  8. How data processing scripts integrate with data flows

    master

    Data processing scripts are executed at the component's data entry point, ensuring that the component's changeData method always receives the transformed output. This works across two main data flows:

    1. Normal Data Refresh

    Used for datasets like SQL, HTTP, JSON, Excel, and ES via /dataRoom/dataset/run. Flow: fillDatasetParams $\rightarrow$ datasetApi.run4Chart $\rightarrow$ transformChartData $\rightarrow$ changeData(transformedData).

    2. Real-time Subscription

    Used for streaming datasets like WebSocket or MQTT. Flow: fillDatasetParams $\rightarrow$ Establish/Update Subscription $\rightarrow$ Receive Pushed Data $\rightarrow$ transformChartData $\rightarrow$ changeData(transformedData).

    Note: Component-level scripts are executed on the frontend after receiving streaming results, separate from any backend Groovy processing.

  9. Write component data processing scripts

    master

    In the component configuration panel, you can use the 'Data Processing / Processing Script' (数据处理 / 处理脚本) field to perform secondary formatting on dataset results.

    Rules for writing scripts:

    • Scripts must be written as a JavaScript function body.
    • You must explicitly use the return keyword to return the processed data.
    • If the script is empty, the original data is returned.
    • If the script executes but does not return a value, it is treated as invalid and returns an empty array [].
    • If the script throws an error, it returns an empty array [] and displays an error message via Element Plus.
    const region = bep.globals.get('region')
    
    return bep.data
      .filter(item => !region || item.region === region)
      .map(item => ({
        time: item.month,
        value: Number(item.amount)
      }))
  10. Install and set up dataRoomFront

    master

    To set up the dataRoomFront development environment, configure your npm registry (optional but recommended for certain regions) and install dependencies using npm.

    # Set registry (optional)
    npm set registry https://registry.npmmirror.com/
    
    # Install dependencies
    npm install
    npm set  registry https://registry.npmmirror.com/ 
    
    npm install
  11. Integrate Chart Data Transformation with Realtime Datasets

    master

    To support realtime data updates that require chart-specific transformations, you must modify the use-realtime-dataset hook to track chart state (configuration and parameters) rather than just chart IDs. This allows the system to apply transformChartData to incoming realtime socket messages before scheduling updates.

    Implementation Steps

    1. Update Data Structures: Replace the datasetChartMap (which maps dataset codes to chart IDs) with datasetChartStateMap, which maps dataset codes to an array of DatasetChartState objects. Each DatasetChartState must contain the chart configuration and its specific paramMap.

    2. Update Subscription Logic: During the buildDatasetIndex and walkCharts process, ensure that for every chart associated with a dataset, both the chart config and the paramMap (generated via canvasInst.fillDatasetParams(chart)) are stored in the datasetChartStateMap.

    3. Transform Realtime Data: Modify the dispatchDatasetData function to be async. Instead of iterating over IDs, iterate over the DatasetChartState objects. For each state, call await transformChartData using the stored chart, canvasInst, normalizedData, and paramMap. Finally, call scheduleChartUpdate with the resulting transformedData.

    const dispatchDatasetData = async (datasetCode: string, data: unknown) => {
      const chartStates = datasetChartStateMap.get(datasetCode) || []
      const normalizedData = normalizeDatasetData(data)
    
      for (const chartState of chartStates) {
        const transformedData = await transformChartData({
          chart: chartState.chart,
          canvasInst,
          data: normalizedData,
          params: chartState.paramMap,
        })
        scheduleChartUpdate(chartState.chart.id, transformedData)
      }
    }