Genie modularize @app logic

Is there a way to programmatically initialize @in and @out vars in GenieFramework.jl ?

I would like to call a type of constructor from a module sever logic using namespaces , :tree, :ghost, to not have to initialize everything explicitly inside the main App function :

@app begin

  @in  ghostname = "Genie"
  @in  ghostmessage = "nothing to report"
  @out ghostage = 9878

  @in  treename = "Oak"
  @in  treemessage = "nothing to report"
  @out treeage = 234
end

Eqivalent to an UI constructor that creates identical input cards with name-spaced variables:

function ui_elem(ns::String, name::String="name", age::String = "age", message::String = "message")

    name_ns,age_ns,message_ns = Symbol.(Symbol(ns),[name,age,message])

      row([
      cell(class="st-module",[

        h4("Module of :$ns"),
        textfield("Enter your name $ns", name_ns,filled = String(name_ns)),
        p("Your age is {{age_ns}} ; $age_ns"), # how to display outvars?
        textfield("Enter your concern", message_ns, filled =String(message_ns)),
      ])
    ])
end

called inside main UI in App.jl:

function ui()
  [
    h1("modularized app"),
    [ui_elem(i) for i in ["ghost","tree"] ]...,
    p("A Ghost of the name {{ghostname}} and age {{ghostage}} years thinks: {{ghostmessage}}"),
    p("A tree of the name {{treename}} and age {{treeage}} thinks {{treemessage}}"),

  ]
end

How would an compaignon constructor for @in and @out reactive vars look like?

Can the code be boundled in a generic module /lib/Being.jl?

In Rshiny the design pattern of shiny-modules allows to boundle “server” and “ui” logic in a namespaced module, I tried to achieve a similar thing in GenieFramework.jl and modules in /lib/ but its unclear to me how/where to initialize/scope/pass variables?

./lib/Being.jl
module Being
using GenieFramework
@genietools
export name            # how to IO reactives ?
name = "testname"


# have a sub server function define the routing here ...
# or define a constructor method.
# create name spaced- ui  vars
# available in App.jl @app available (containment ie MyNS.var ?)
@app begin
  @in  name = "Name of arbitrary Being Module"
  @out age = 1
  @in  message = "Message of arbitrary Being"
  @out info = hcat(name,age,message)
  @onchange message begin
      info = hcat(name,age,message)
      age += 1
  end 
end

function ui_being(name::Symbol,age::Symbol,message::Symbol)
    row([
      cell(class="st-module",[
        h4("Module of ?"),
        textfield("Enter your name", name,ref="n",filled =  "Name of arbitrary Being"),
        p("Your age is {{age}}"),
        textfield("Enter your concern", message,ref="nm", filled ="Message of arbitrary Being"
        ),
      ])
    ])
end
end

./App.jl
module App
using Main.Being
using GenieFramework
@genietools


@app begin

  ## i would like to call a type of constructor for the modules sever logic...
  # using three namespaces :being , :ghost , :tree
  @in ghostname = "Genie"
  @in ghostmessage = "nothing to report"
  @out ghostage = 9878

  @in treename = "Oak"
  @in treemessage = "nothing to report"
  @out treeage = 234

  @in beingname ="APP Name of arbitrary Being"
  @in beingmessage = "APP Message of arbitrary Being"
  @out beingage = 99


  ### ""Main" APP logic"
  @in refresh = false
  @out report = "no new messages"
  @onchange refresh begin
      report = "$(ghostmessage), $(treemessage), $(beingmessage)"
      treeage += 1
      ghostage += 1
      beingage +=1
  end
end
  ## How to namespace if needed? (Modules // Scope)


function ui_elem(ns::String, name::String="name", age::String = "age", message::String = "message")
    name_ns,age_ns,message_ns = Symbol.(Symbol(ns),[name,age,message])
      row([
      cell(class="st-module",[
        h4("Module of :$ns"),
        textfield("Enter your name $ns", name_ns,filled = String(name_ns)),
        p("Your age is {{age_ns}} ; $age_ns"), # how to display outvars?
        textfield("Enter your concern", message_ns, filled =String(message_ns)),
      ])
    ])
end

function ui_contor()
    row([
    cell(class="st-module",[
        p("------------------------------"),
        p("An aritrary module ? named {{beingname}} of age {{beingage}} thinks {{beingmessage}}"),
        p("A Ghost of the name {{ghostname}} and age {{ghostage}} years thinks: {{ghostmessage}}"),
        p("A tree of the name {{treename}} and age {{treeage}} thinks {{treemessage}}"),
        p("------------------------------"),
        p("----  REPORT on Update -------"),
        p("{{ghostname}} and {{treename}} report: {{report}}. {{beingname}} says: {{beingmessage}} "),
        p("Modlue export var:: {{name}} exsist?"),
        button("collect reports", @click("refresh = !refresh")),
      ])
    ])
end

function ui()
  [
    h1("modularized app"),
    [ui_elem(i) for i in ["ghost","tree"] ]...,
    Being.ui_being(:beingname,:beingage,:beingmessage), # A = Being(ns ="A"); A.name, A.age, A.message ??
    ui_contor()
  ]
end


include("./lib/Being.jl")
@page("/", ui)
end