Tutorials or Blog posts on adding phoenix to an existing application

I am looking for resources on adding phoenix to an existing application.
We have a service that was previously only an API but now has some dashboards. It is currently built without Phoenix but we will probably add it. We have enough existing code that using generators will probably not be helpful.

I’ve heard several people say that it is best to have a decoupled application then add phoenix as needed. For example in this Elixir fountain episode, around 10 minutes in.

Paraphrasing:

  1. Start with business logic, just modules and functions
  2. Add that into a genserver to get parallelism and concurrency.
  3. When you want to make it available on the web as phoenix as a web layer.

So yes any resources that concretely discuss step 3 is what I am after. thanks.

1 Like

Check out PragDave’s course:

He starts by building the app, a cli, then adds TWO Phoenix layers (one as a standard web app and another for a SPA).

Not sure if it’s what you want but I highly recommend it :023:

1 Like

I don’t know if there’s a better way, but here’s a hacky approach I used a couple of months ago for a toy project to Phoenixize an existing OTP app without resorting to umbrella. Let’s say we have a project named foobar and the code is committed to the repo. I did the following steps:

  1. cd /tmp
  2. mix phx.new foobar
  3. copy the entire contents of /tmp/foobar to /working/copy/of/foobar
  4. add all the new files
  5. carefully comb through modified files and reconcile with the latest state in the foobar repo

It’s not perfect, but it wasn’t all that difficult either. IIRC it took me some 20 minutes, and I got it right in the first attempt :slight_smile:

I’m curious to learn if there’s a more automated way.

3 Likes

using generators?

Well no one has suggested one. I though that is what I was going to end up doing. Indeed 20 minutes is not too much time but it feels very unsatisfactory as a solution.