MCPcopy Index your code
hub / github.com/chartello/chartello

github.com/chartello/chartello @v0.6.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.6.0 ↗ · + Follow
85 symbols 130 edges 31 files 12 documented · 14%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Chartello

tests GitHub license

Chartello provides a simple UI for visualizing your data in your Laravel 10+ apps that use MySQL.

screenshot

Installation

Add the package to your project via composer:

composer require chartello/chartello

Publish the package resources:

php artisan chartello:install

Run new migrations:

php artisan migrate

Voilà! Open yourapp.test/chartello on your local machine. You should see the Chartello dashboard.

Configuration

Dashboard Authorization

Chartello dashboards allow users to write SQL queries against your database. This makes it important for you to ensure that they are protected behind appropriate permissions.

When you install Chartello, it adds a app\Http\Middleware\ProtectChartello middleware to your app. This, by default, limits the access to these dashboards only to your local environment. You should modify this middleware to define how access to these dashboards should be restricted in your production environment.

/**
 * Define the authorization logic for accessing Chartello.
 *
 * @param $request
 * @return bool
 */
protected function authorize($request)
{
    if (App::environment('local')) {
        return true;
    }

    return $request->user() && in_array($request->user()->email, [
        //
    ]);
}

Dashboard Routes

After installing Chartello, its configuration file will be located at config/chartello.php. This file allows you to customize the path to the Chartello dashboards and adjust HTTP middleware that should be used when serving them.

Usage

Writing Queries

Chartello currently supports two types of panels:

1. Trend Charts

A trend chart expects an x column with date/datetime values and a numeric y column.

To populate a trend chart, create a new panel in the UI and enter a query similar to this one:

SELECT DATE(created_at) AS x, COUNT(*) AS y
FROM users
WHERE created_at BETWEEN @start AND @end
GROUP BY x
ORDER BY x ASC

Including the BETWEEN @start AND @end filter ensures that your chart reflects the date range selection available in the UI.

2. Tables

Tables are flexible and accept almost any SELECT queries.

If you wish the data in your table to reflect the date selection from the UI, you should include the BETWEEN @start AND @end filter in your query.

Here is an example query for populating a table panel:

SELECT name, email, created_at
FROM users
WHERE created_at BETWEEN @start AND @end
ORDER BY created_at DESC
LIMIT 5

Upgrading

When upgrading to a new version of Chartello, you should re-publish its assets:

php artisan vendor:publish --tag=chartello-assets --force

Upgrading from v0.5.x

Chartello no longer depends on Inertia.js. If you have published the Chartello config file, remove the HandleInertiaRequests middleware from config/chartello.php:

 'middleware' => [
     'web',
     App\Http\Middleware\ProtectChartello::class,
-    Chartello\Http\Middleware\HandleInertiaRequests::class,
 ],

License

The MIT License (MIT). Please see License File for more information.

Extension points exported contracts — how you extend this code

Aggregator (Interface)
(no doc)
src/Aggregators/Aggregator.php

Core symbols most depended-on inside this repo

get
called by 4
src/Aggregators/Aggregator.php
panels
called by 4
src/Models/Dashboard.php
jsonHeaders
called by 3
resources/js/http.js
populate
called by 2
src/Models/Panel.php
csrfToken
called by 1
resources/js/http.js
registerRoutes
called by 1
src/ChartelloServiceProvider.php
registerMigrations
called by 1
src/ChartelloServiceProvider.php
registerConfig
called by 1
src/ChartelloServiceProvider.php

Shape

Method 51
Class 18
Function 15
Interface 1

Languages

PHP87%
TypeScript13%

Modules by API surface

src/Console/Commands/TestChartello.php11 symbols
src/ChartelloServiceProvider.php8 symbols
src/Http/Controllers/DashboardsController.php6 symbols
src/Models/Panel.php5 symbols
src/Database/Schema.php5 symbols
resources/js/useForm.js5 symbols
resources/js/store.js4 symbols
stubs/Tests/DashboardTest.php3 symbols
stubs/Middleware/ProtectChartello.php3 symbols
src/Models/Dashboard.php3 symbols
src/Http/Controllers/PanelsController.php3 symbols
src/Http/Controllers/HomeController.php3 symbols

For agents

$ claude mcp add chartello \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact