Skip to content

nejcdev/data-story

 
 

Repository files navigation

DataStory

⚡ Visual coding ⚡ Process builder ⚡ Data driven design ⚡ ETL ⚡ Laravel + React ⚡ Alpha in development ⚡

tests version

What the heck is this 😄

DataStory provides a workbench for designing data processes. A flow of nodes defines operations such as Read - Create - Transform - Inspect - Write. Some use cases include:

  • Allow non coders to visually design data flows in context of your Laravel application. The flow can be executed and saved for future use.
  • Quickly query, filter and transform models and view them in separated tables.

More features/use cases to be announced shortly.

Installation

In your Laravel app, run

composer require ajthinking/data-story
php artisan vendor:publish --provider="DataStory\DataStoryServiceProvider"

That's it! Go to the workbench at /datastory.

Screencast

https://www.youtube.com/watch?v=IAV39TRr1gk

Configuration

You may edit settings in config/data-story.php as needed. This is the contents of the published config file:

<?php

return [
    /*
    |--------------------------------------------------------------------------
    | Custom nodes
    |--------------------------------------------------------------------------
    |
    | Nodes created with php artisan story:node NAME will be put here
    |
    */    
    'custom-nodes-dir'       => 'app/DataStory/Nodes',
    'custom-nodes-namespace' => 'App\DataStory\Nodes',

    /*
    |--------------------------------------------------------------------------
    | Scan custom nodes dir?
    |--------------------------------------------------------------------------
    |
    | Automatically scan for custom nodes
    |
    */
    'custom-nodes-scan-dir' => true,

    /*
    |--------------------------------------------------------------------------
    | Stories dir
    |--------------------------------------------------------------------------
    |
    | Saved stories will be placed here
    |
    */    
    'stories-dir' => base_path('app/DataStory/stories'),

    /*
    |--------------------------------------------------------------------------
    | Dev mode
    |--------------------------------------------------------------------------
    |
    | Indicate if you are currently developing on the package
    |
    */
    'dev-mode' => env('DATASTORY_DEV_MODE', false),

    /*
    |--------------------------------------------------------------------------
    | Default Nodes
    |--------------------------------------------------------------------------
    |
    | These nodes will be available in the story workbench
    |
    */    
    'nodes' => [
        // the default nodes ...
    ],
];

Create custom node

Run the command

php artisan story:node NewEpicNode

To generate a node boilerplate:

<?php

namespace App\DataStory\Nodes;

use DataStory\NodeModel;

class NewEpicNode extends NodeModel
{
    public function run()
    {
        $items = $this->input();
        
        // your code goes here

        $this->output($items);
    }
}

After refreshing the page the NewEpicNode node is available in the story workbench.

Contributing

Clone this repo

git clone git@github.com:ajthinking/data-story.git data-story

In the same level as data-story dir, create a host/container app

laravel new dsh1

Now we have something like:

~/Code
+---data-story
+---dsh1

Add this to the host apps composer.json

    "repositories": [
        {
            "type": "path",
            "url": "/PATH/TO/YOUR/CODE/data-story"
        }
    ], 

Install data-story in host app with dev flag:

composer require ajthinking/data-story @dev

Optionally, in data-story root create a .env and set DATASTORY_DEV_MODE=true. This will tell webpack/mix to to copy assets into the host app so you dont have to republish when touching JS. Currently, this only works if you named the host app dsh1. If you skip this step manually publish assets with command:

php artisan vendor:publish --provider="DataStory\DataStoryServiceProvider"

Then, in data-story, run

yarn && yarn watch

Run testsuite in data-story

composer install
./vendor/bin/phpunit tests

Go to dsh1.test/datastory to test out your changes 🚀

License

MIT

About

A visual process builder for Laravel

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 62.6%
  • PHP 36.4%
  • Other 1.0%