Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blueprints #2

Open
repl6669 opened this issue Jun 15, 2023 · 0 comments
Open

Blueprints #2

repl6669 opened this issue Jun 15, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@repl6669
Copy link
Contributor

repl6669 commented Jun 15, 2023

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.

@repl6669 repl6669 added the enhancement New feature or request label Jun 15, 2023
@repl6669 repl6669 added this to the v1 milestone Jun 15, 2023
@repl6669 repl6669 self-assigned this Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant