Convert Figma logo to code with AI

cube-js logocube

📊 Cube — Universal semantic layer platform for AI, BI, spreadsheets, and embedded analytics

18,386
1,821
18,386
856

Top Related Projects

65,934

Apache Superset is a Data Visualization and Data Exploration Platform

41,759

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

27,243

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.

63,369

Apache ECharts is a powerful, interactive charting and data visualization library for browser

67,141

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

Quick Overview

Cube.js is an open-source analytics API platform designed to build internal business intelligence tools or add customer-facing analytics to existing applications. It provides a robust framework for data modeling, caching, and API generation, allowing developers to create scalable and performant analytics solutions.

Pros

  • Flexible data modeling with support for various data sources
  • Automatic caching and query optimization for improved performance
  • Pre-aggregations for handling large datasets efficiently
  • Extensive API support for integration with various frontend frameworks

Cons

  • Steep learning curve for beginners
  • Limited visualization capabilities out of the box
  • Requires additional setup for authentication and authorization
  • May be overkill for simple analytics needs

Code Examples

  1. Defining a cube (data model):
cube(`Orders`, {
  sql: `SELECT * FROM orders`,
  
  measures: {
    count: {
      type: `count`
    },
    totalAmount: {
      sql: `amount`,
      type: `sum`
    }
  },
  
  dimensions: {
    status: {
      sql: `status`,
      type: `string`
    },
    createdAt: {
      sql: `created_at`,
      type: `time`
    }
  }
});
  1. Querying data using Cube.js API:
const cubejsApi = cubejs(
  'CUBEJS-API-TOKEN',
  { apiUrl: 'http://localhost:4000/cubejs-api/v1' }
);

const query = {
  measures: ['Orders.count', 'Orders.totalAmount'],
  timeDimensions: [{
    dimension: 'Orders.createdAt',
    dateRange: ['2021-01-01', '2021-12-31'],
    granularity: 'month'
  }],
  filters: [{
    member: 'Orders.status',
    operator: 'equals',
    values: ['completed']
  }]
};

cubejsApi.load(query).then(resultSet => {
  console.log(resultSet.chartPivot());
});
  1. Setting up pre-aggregations:
cube(`Orders`, {
  // ... other cube definitions

  preAggregations: {
    main: {
      measures: [Orders.count, Orders.totalAmount],
      dimensions: [Orders.status],
      timeDimension: Orders.createdAt,
      granularity: 'month'
    }
  }
});

Getting Started

  1. Install Cube.js CLI:

    npm install -g cubejs-cli
    
  2. Create a new Cube.js project:

    cubejs create my-analytics-app -d postgres
    
  3. Navigate to the project directory and start the development server:

    cd my-analytics-app
    npm run dev
    
  4. Open http://localhost:4000 in your browser to access the Cube.js Developer Playground and start building your analytics application.

Competitor Comparisons

65,934

Apache Superset is a Data Visualization and Data Exploration Platform

Pros of Superset

  • More comprehensive visualization capabilities with a wide range of chart types
  • Built-in SQL Lab for direct querying and exploration of data sources
  • Larger community and ecosystem, being an Apache project

Cons of Superset

  • Steeper learning curve due to its extensive features and configurations
  • Less flexible for custom data modeling compared to Cube's semantic layer
  • May require more server resources for deployment and operation

Code Comparison

Superset (Python):

from superset import db
from superset.models import SqlaTable

table = SqlaTable(
    table_name='my_table',
    schema='my_schema',
    database_id=1,
    sql='SELECT * FROM my_table'
)
db.session.add(table)
db.session.commit()

Cube (JavaScript):

cube(`MyTable`, {
  sql: `SELECT * FROM my_schema.my_table`,
  measures: {
    count: {
      type: `count`
    }
  },
  dimensions: {
    id: {
      sql: `id`,
      type: `number`,
      primaryKey: true
    }
  }
});

Both Superset and Cube offer powerful data analytics and visualization capabilities, but they cater to different use cases. Superset excels in providing a comprehensive BI platform with rich visualizations, while Cube focuses on building a flexible semantic layer for data modeling and API generation.

41,759

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Pros of Metabase

  • User-friendly interface with drag-and-drop query builder
  • Built-in visualization tools and dashboard creation
  • Supports multiple databases out of the box

Cons of Metabase

  • Less flexible for complex data modeling scenarios
  • Limited customization options for advanced users
  • Steeper learning curve for non-technical users

Code Comparison

Metabase (SQL query):

SELECT product_name, SUM(sales_amount) AS total_sales
FROM sales
GROUP BY product_name
ORDER BY total_sales DESC
LIMIT 10

Cube (data schema):

cube(`Sales`, {
  sql: `SELECT * FROM sales`,
  measures: {
    totalSales: {
      sql: `sales_amount`,
      type: `sum`
    }
  },
  dimensions: {
    productName: {
      sql: `product_name`,
      type: `string`
    }
  }
});

Both Metabase and Cube offer solutions for data analytics and business intelligence, but they approach the problem differently. Metabase provides a more complete out-of-the-box solution with a user-friendly interface, while Cube focuses on providing a flexible data modeling layer that can be integrated with various frontend tools. The code comparison shows how Metabase uses SQL queries directly, while Cube uses a JavaScript-based schema definition to model data and create reusable metrics and dimensions.

27,243

Make Your Company Data Driven. Connect to any data source, easily visualize, dashboard and share your data.

Pros of Redash

  • More mature project with a larger community and extensive documentation
  • Supports a wider range of data sources out-of-the-box
  • Offers a user-friendly interface for non-technical users to create visualizations

Cons of Redash

  • Less flexible for complex data modeling scenarios
  • Limited customization options for advanced users
  • Slower query performance for large datasets compared to Cube's pre-aggregations

Code Comparison

Redash query example:

SELECT date_trunc('day', created_at) AS day, COUNT(*) AS count
FROM events
WHERE created_at > current_date - interval '7 days'
GROUP BY 1
ORDER BY 1

Cube query example:

cube(`Events`, {
  sql: `SELECT * FROM events`,
  measures: {
    count: {
      type: `count`
    }
  },
  dimensions: {
    createdAt: {
      sql: `created_at`,
      type: `time`
    }
  }
});

Both projects aim to simplify data analysis and visualization, but they take different approaches. Redash focuses on providing a complete solution with a user-friendly interface, while Cube offers more flexibility and performance optimization for developers building data applications.

63,369

Apache ECharts is a powerful, interactive charting and data visualization library for browser

Pros of ECharts

  • Extensive charting library with a wide variety of chart types and customization options
  • Lightweight and high-performance rendering, suitable for large datasets
  • Strong community support and regular updates

Cons of ECharts

  • Steeper learning curve due to its extensive API and configuration options
  • Primarily focused on data visualization, lacking built-in data processing capabilities
  • May require additional libraries for complex data transformations

Code Comparison

ECharts:

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [{
    data: [120, 200, 150, 80, 70, 110, 130],
    type: 'bar'
  }]
};

Cube:

cube(`Orders`, {
  sql: `SELECT * FROM orders`,
  measures: {
    count: {
      type: `count`
    },
    totalAmount: {
      sql: `amount`,
      type: `sum`
    }
  },
  dimensions: {
    status: {
      sql: `status`,
      type: `string`
    }
  }
});

While ECharts focuses on rendering charts with predefined data, Cube is designed for data modeling and analytics, providing a foundation for building data applications. ECharts excels in visualization flexibility, while Cube offers robust data processing capabilities.

67,141

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

Pros of Grafana

  • More mature and widely adopted visualization platform
  • Supports a broader range of data sources out-of-the-box
  • Offers a rich set of pre-built dashboards and plugins

Cons of Grafana

  • Steeper learning curve for complex visualizations
  • Less flexibility in data modeling and transformation
  • Limited support for real-time analytics without additional tools

Code Comparison

Grafana (Dashboard JSON):

{
  "panels": [
    {
      "type": "graph",
      "title": "CPU Usage",
      "datasource": "Prometheus",
      "targets": [
        { "expr": "node_cpu_usage" }
      ]
    }
  ]
}

Cube (Data Schema):

cube(`CPUUsage`, {
  sql: `SELECT * FROM node_cpu_usage`,
  measures: {
    average: {
      type: `avg`,
      sql: `usage_percent`
    }
  },
  dimensions: {
    timestamp: {
      type: `time`,
      sql: `timestamp`
    }
  }
});

While Grafana focuses on visualization configuration, Cube emphasizes data modeling and schema definition. Grafana's approach is more suitable for quick dashboard creation, while Cube provides greater flexibility in data preparation and analysis.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Cube — Semantic Layer for Data Applications


Website • Getting Started • Docs • Examples • Blog • Slack • Twitter

npm version GitHub Actions FOSSA Status

Cube is the semantic layer for building data applications. It helps data engineers and application developers access data from modern data stores, organize it into consistent definitions, and deliver it to every application.

Learn more about connecting Cube to data sources and analytics & visualization tools.

Cube was designed to work with all SQL-enabled data sources, including cloud data warehouses like Snowflake or Google BigQuery, query engines like Presto or Amazon Athena, and application databases like Postgres. Cube has a built-in relational caching engine to provide sub-second latency and high concurrency for API requests.

For more details, see the introduction page in our documentation.

Why Cube?

If you are building a data application—such as a business intelligence tool or a customer-facing analytics feature—you’ll probably face the following problems:

  1. SQL code organization. Sooner or later, modeling even a dozen metrics with a dozen dimensions using pure SQL queries becomes a maintenance nightmare, which leads to building a modeling framework.
  2. Performance. Most of the time and effort in modern analytics software development is spent providing adequate time to insight. In a world where every company’s data is big data, writing just SQL queries to get insight isn’t enough anymore.
  3. Access Control. It is important to secure and govern access to data for all downstream data consuming applications.

Cube has the necessary infrastructure and features to implement efficient data modeling, access control, and performance optimizations so that every application—like embedded analytics, dashboarding and reporting tools, data notebooks, and other tools—can access consistent data via REST, SQL, and GraphQL APIs.

Getting Started 🚀

Cube Cloud

Cube Cloud is the fastest way to get started with Cube. It provides managed infrastructure as well as an instant and free access for development projects and proofs of concept.

Get started now

For a step-by-step guide on Cube Cloud, see the docs.

Docker

Alternatively, you can get started with Cube locally or self-host it with Docker.

Once Docker is installed, in a new folder for your project, run the following command:

docker run -p 4000:4000 \
  -p 15432:15432 \
  -v ${PWD}:/cube/conf \
  -e CUBEJS_DEV_MODE=true \
  cubejs/cube

Then, open http://localhost:4000 in your browser to continue setup.

For a step-by-step guide on Docker, see the docs.

Resources

Contributing

There are many ways you can contribute to Cube! Here are a few possibilities:

  • Star this repo and follow us on Twitter.
  • Add Cube to your stack on Stackshare.
  • Upvote issues with 👍 reaction so we know what's the demand for particular issue to prioritize it within road map.
  • Create issues every time you feel something is missing or goes wrong.
  • Ask questions on Stack Overflow with cube.js tag if others can have these questions as well.
  • Provide pull requests for all open issues and especially for those with help wanted and good first issue labels.

All sort of contributions are welcome and extremely helpful 🙌 Please refer to the contribution guide for more information.

License

Cube Client is MIT licensed.

Cube Backend is Apache 2.0 licensed.

FOSSA Status

NPM DownloadsLast 30 Days