Apologizes @anandpotukuchi but I don’t think I missed the idea. In addition to writing Elixir School I’ve partnered up with a few other sites to write the Elixir side of their full stack lessons. You may want to take a peek at https://www.learnphoenix.io. While paid they do provide free courses on Phoenix + React.
I’d encourage you to reach out to Sam @ learnphoenix.io. I helped write a number of their Elixir lessons, he’s a super nice guy, and I’m sure he’d be happy to share some of the insights he’s learned in the last two years running Learn Phoenix
If you want true interactivity then you may be underestimating the role sandboxing would play in this. There’s good reason why there aren’t existing solutions whereas there are numerous ones for Node, Ruby, and even Java. The nature of the runtime presents some unique challenges due to some super cool features like hot code reloading.
You can demonstrate the need for a sandbox pretty easily with a simple Plug.Router example. We’ll accept a POST
and evaluate a string in the JSON payload:
defmodule SandboxEx do
use Plug.Router
plug :match
plug Plug.Parsers, parsers: [:urlencoded, :json], pass: ["text/*"], json_decoder: Poison
plug :dispatch
post "/result" do
result =
conn.params
|> Map.get("code")
|> Code.eval_string()
send_resp(conn, 200, inspect(result))
end
match _ do
send_resp(conn, 404, "Not Found")
end
end
Submit a request that creates a new module like this:
{"code": "defmodule NoSandbox do
def hello, do: \"Hello World!\"
end"
}
Now from a second computer, browser, or device fire off a new request but this time let’s try to use the module from the last request:
{"code": "NoSandbox.hello()"}
Our HTTP response: {"Hello World!", []}
The code from our first request was evaluated and is now part of the runtime, available to all subsequent requests. Without sandboxing you run into the potential for redefinition of user submitted code or worse a malicious user has a field day. That’s a pretty simple example but it highlights why this is so difficult.
Over at Elixir School we’re rolling out a blog in the next week or two and with it a series that’ll cover planning, designing, and building full fledged applications in Elixir albeit it without the frontend components and requiring the user compile code locally. Feel free to jump into any of the existing conversations taking place over there, we always welcome new thoughts