Skip to content

Blueprints #2

@repl6669

Description

@repl6669

Blueprints

Blueprints should serve as well... blueprints of a certain flow. You can define your steps connected with DAG relations, belonging to some template.

Let' s take a simple example: Super simplified new web app production

Steps:

  1. go to nature and try to come up with an idea
  2. market research
  3. decide if it makes sense to continue
    • if yes: continue (step 5)
    • if not: archive the idea (step 4)
  4. archive the idea
  5. dev planning phase (continue with 8)
  6. design (opens 9 & 10 in parallel after finished)
  7. backend
  8. frontend
  9. launch (waits for 9 & 10 to be finished)
  10. done

super awesome diagram

Represented in Blueprint

class WebAppProduction extends Blueprint
{
    // For which model this blueprint is
    // Can be left empty (any model can have this flow then)
    public function model(): ?string
    {
        return Model::class;
    }

    // Template name (gets created with incremental versions)
    public function name(): string
    {
        return 'Super simplified new web app production';
    }

    // Creates nodes
    public function steps(): array
    {
        return [
            // Root node (step)
            GoToNature::class => [
                MarketResearch::class,
            ],
            // One by one 🐤
            MarketResearch::class => [
                ContinueOrNah::class,
            ],
            // Either Design or Archive after finish
            // Any step can alter the flow
            ContinueOrNah::class,
            // Early finish
            ArchiveIdea::class => [
                Finish::class,
            ],
            // Launch paralllel steps
            Design::class => [
                Backned::class,
                Frontend::class,
            ],
            // Finish, but only when Frontend and Backend are done
            Backned::class => [
                Launch::class,
            ],
            // Finish, but only when Frontend and Backend are done
            Frontend::class => [
                Launch::class,
            ],
            Launch::class => [
                Finish::class,
            ],
            Finish::class,
        ];
    }
}

Generating the template

Templates would be generated with come command, eg. php artisan flow:generate --class=WebAppProduction. It could automatically ask you which Blueprint you want to generate. If it already exists, you would have to decide if you want to create a new version of the Blueprint or regenerate the latest version you currently have. It could also take template name as an argument bla bla bla. Keep it MVP omg! 🤦

Under the hood

Shadow flow

Something like a shadow flow is generated, so the concrete Steps know when to be initialized and so on.

  • it creates Template (collection of nodes)
  • it creates Nodes (graph representation of the flow - this creates the structure)
  • it creates hierarchy among Nodes using Edges

Model belongs to Template which has Nodes (vertexes) which belong to many Edges. Nodes can belong to many Users (eg. responsible for the step), the same applies to Steps.

Nodes

Nodes are shadow Steps. Only used as hierarchy holders, structure makers.

Where is all the logic??? ❇️

Each Node is represented by a FlowHandler class which ultimately decides what is going to happen when.

Templates

Template is used for flow version control.

Ehm... disadvantages

How it works

This is getting super long.

  1. Blueprint generates node structure (up to you, you can create the structure manually)
  2. Template is attached to a model (up to you)
  3. Flow gets started when the model is created (up to you tho)
  4. Step is finished (through a single controller) and created descendant steps (or something completely else, up to you)
  5. That's it

Why blueprint?

Because it could be a nice, class based flow definition. Never gonna happen, but some day there could be full blueprint packages, which you could just require to your project and add functionality this way.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions