-
Notifications
You must be signed in to change notification settings - Fork 0
Blueprints #2
Description
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:
- go to nature and try to come up with an idea
- market research
- decide if it makes sense to continue
- if yes: continue (step 5)
- if not: archive the idea (step 4)
- archive the idea
- dev planning phase (continue with 8)
- design (opens 9 & 10 in parallel after finished)
- backend
- frontend
- launch (waits for 9 & 10 to be finished)
- done
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
NodesusingEdges
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
- many tables (
templates,nodes,node edges,node users,steps,step edges,step users), but the user tables are not necessary, maybe its a good idea to get rid of them.
How it works
This is getting super long.
- Blueprint generates node structure (up to you, you can create the structure manually)
- Template is attached to a model (up to you)
- Flow gets started when the model is created (up to you tho)
- Step is finished (through a single controller) and created descendant steps (or something completely else, up to you)
- 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.
