Node-RED creates code from a flow. Is there a way to generate flow from code? This would help me convert a teensy 3.1 routine to tennsy 4.0
Node red doesn't create code at all, node red is code.
I don't see how node red is related to the teensey boards at all.
Not sure if I understood your question, but in my understanding you want to generate a flow automatically. This for sure can be done, since a flow is basically a json file so, all you have to do is to generate this json file from a different software.
(btw, we do this for all our industrial applications)