Skip to main content

An opinionated YAML-driven analytics dashboarding library. Define a config, get a beautiful dashboard.

Project description

Lens

PyPI version License: MIT Python 3.10+

An opinionated YAML-driven analytics dashboarding library. Define a config, get a beautiful dashboard. Built by Mindcase.

pip install mindcase-lens

Quick Start

1. Create a YAML config:

app:
  title: "My Dashboard"
  database:
    connection: "postgresql://user:pass@localhost:5432/mydb"
  pages:
    - id: sales
      name: Sales
      icon: bar-chart
      rows:
        - height: small
          items:
            - type: kpi
              title: Total Revenue
              query: "SELECT SUM(amount) as current_value FROM sales"
              prefix: "$"
              compact: true

2. Serve it:

lens serve dashboard.yaml

That's it. You get a full React dashboard with KPIs, charts, tables, filters, theming, and more -- all from YAML.

Features

  • KPIs with trend indicators, formatting, and compact numbers
  • Charts -- bar, line, area, pie, donut, horizontal bar, combo (via ApexCharts)
  • Data Tables -- pagination, sorting, conditional formatting, CSV export
  • Filters -- dropdown (single/multi), date range, date, text search, number range, toggle
  • Theming -- light/dark mode, color themes, font selector, border radius
  • Sidebar -- auto-generated from pages, collapsible, supports logos
  • Hot Reload -- edit YAML, dashboard updates instantly (debug mode)
  • Security -- read-only queries, parameterized SQL, no raw SQL on the client

YAML Config

app:
  title: "Dashboard Title"
  theme: system              # light | dark | system
  port: 8080
  debug: true                # enables hot reload
  database:
    connection: "postgresql://..."
    pool_size: 10
    query_timeout: 30
  sidebar:
    logo: "/logo.png"
    logo_dark: "/logo-dark.png"
    title: "My App"
    sections:
      - label: Analytics
        pages: [sales, customers]
    footer: "Powered by Lens"
  pages:
    - id: sales
      name: Sales
      icon: bar-chart
      default: true
      filters:
        - id: region
          type: dropdown
          label: Region
          query: "SELECT DISTINCT region FROM sales"
          all: true
      tabs:
        - name: Overview
          rows:
            - height: small
              items:
                - type: kpi
                  title: Revenue
                  query: "SELECT SUM(amount) as current_value FROM sales WHERE (:region = 'ALL' OR region = :region)"
                  prefix: "$"
                  compact: true

Widget Types

KPI

- type: kpi
  title: Total Revenue
  query: "SELECT SUM(amount) as current_value, SUM(prev_amount) as previous_value FROM sales"
  prefix: "$"
  suffix: ""
  decimals: 0
  compact: true

Chart

- type: chart
  chart_type: bar          # bar | line | area | pie | donut | horizontal_bar | combo
  title: Revenue by Month
  query: "SELECT month, SUM(amount) as revenue FROM sales GROUP BY month"
  x: month
  y: revenue
  y_format: currency       # currency | number | percentage | compact
  stacked: false
  data_labels: false

Table

- type: table
  title: Recent Orders
  query: "SELECT id, customer, amount, date FROM orders ORDER BY date DESC"
  page_size: 25
  default_sort:
    column: date
    direction: desc
  columns:
    - id: amount
      label: Amount
      format: currency
      conditional:
        rule: threshold
        threshold: 1000

Filter Types

Type Config SQL Params
dropdown query or options, multi, all :filter_id
daterange presets, min_date, max_date :filter_id_start, :filter_id_end
date -- :filter_id
text placeholder :filter_id
number_range min, max, step :filter_id_min, :filter_id_max
toggle on_label, off_label :filter_id

CLI

lens serve dashboard.yaml              # start dashboard
lens serve dashboard.yaml --port 3000  # custom port
lens serve dashboard.yaml --no-browser # don't open browser
lens validate dashboard.yaml           # validate config

Python API

from lens import Lens

app = Lens("dashboard.yaml")
app.serve(port=8080)

Development

# Install
pip install -e .
cd frontend && npm install

# Frontend dev (hot reload)
cd frontend && npm run dev

# Build
make build

# Run
lens serve examples/northwind_dashboard.yaml

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mindcase_lens-0.2.0.tar.gz (689.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mindcase_lens-0.2.0-py3-none-any.whl (470.6 kB view details)

Uploaded Python 3

File details

Details for the file mindcase_lens-0.2.0.tar.gz.

File metadata

  • Download URL: mindcase_lens-0.2.0.tar.gz
  • Upload date:
  • Size: 689.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mindcase_lens-0.2.0.tar.gz
Algorithm Hash digest
SHA256 e8278a68704fa39a70637e1bcb2f97a69c3c6f47d37c3f146c3d80838935b249
MD5 3efc88f82848d7aade205711e34ebaea
BLAKE2b-256 b7c969f7ec325dded79aa091b38f7ec7e455158cdee77555499f797b7be0f5ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for mindcase_lens-0.2.0.tar.gz:

Publisher: publish.yml on mindcase-co/lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mindcase_lens-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: mindcase_lens-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 470.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mindcase_lens-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b14e1d92d8e756d1b5e311fe9618db646abbcbc2c4ad577558206d1defce50be
MD5 307d2032b77df4a720f3178ab6765a66
BLAKE2b-256 59cb20f8484f192b1fd762c7c4fe825dcf7bfbb8aa20da3ddfcd51c33f62fa72

See more details on using hashes here.

Provenance

The following attestation bundles were made for mindcase_lens-0.2.0-py3-none-any.whl:

Publisher: publish.yml on mindcase-co/lens

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page