How to replicate a multi-domain Rails app?

Hey!

First poster here …

I have been building Rails applications while doing professional server management for the last ten years. Combining these two topics, I authored Efficient Rails DevOps, a book which is popular among Rails developers who want to provision their own servers to serve their Rails apps.

While in no way abandoning the Ruby/Rails world, I have been interested in functional programming (and especially Elixir) for some time and finally took the leap. I have been programming in various languages for the last 20 years but I still have not managed to fully wrap my head around functional programming in general — so I have decided to replicate my main Rails application (which powers my bootstrapped business) to learn Phoenix, learning Elixir in parallel.

My Rails app powers two domains (relativkreativ.at and efficientrailsdevops.com) because they share a lot of common functionality (mainly subscriber/customer management). When starting out, I had a separate API backend which managed subscribers and customers while two other apps (one for each domain) talked to this API via a gem which wrapped the API’s functionality. I abandoned this approach because it slowed development down and was quite a pain to manage.

Having a monlithic, everything-under-one-roof works surprisingly well for me as a single developer — I use router constraints based on the request’s host to decide what get rendered, having a separate relativkreativ/pages_controller and efficientrails/pages_controller. All of them use the same models (subscriber, customer, visitor).

I do not want to replicate my Rails app in Phoenix but do it the Phoenix/Elixir way instead. As I understand it, Elixir/Phoenix is against the monolithic approach but unfortunately, I have no idea where to start.

How would you build such an application with Phoenix?

  • Put everything under one roof (as my Rails app does it)?
    Probably not, I guess.

  • Three completely separate projects?
    One for each domain and one to manage shared business logic? As said, it’s been a PITA with Rails, maybe Elixir/Phoenix can handle it more gracefully.

  • An umbralla app?
    To be honest, I am not completely sure what an umbrella app is but it sounds like it could be what I need.

It would be great if somebody pointed me in the right direction. To clarify, I do not (necessarily) need any tutorials or code samples but a quick explanation of the rough concepts. I’m quite good at figuring stuff out myself and I’ll probably come back later with more specific questions :wink:

Thanks a lot!

Michael

It depends mostly on how “individually” you want the parts to run. If they want to be able to run parts independently (started on a node without the other parts) then I’d go with an umbrella. Otherwise I’d go with a single mix project, but keeping the boundries between the separate parts explicit.

An umbrella app can be started as a unit, though. It’s also a single mix project. I don’t see why you would make this distinction.

2 Likes

Currently, the whole monolith runs on a dedicated server and performance-wise, I see no reason to change that. It’s basically just a blog engine with a few product pages, the most elaborate parts being concerned with creating email list subscribers and re-identifying them.

Could you elaborate a bit on “keeping the boundaries explicit”?

Thanks!

1 Like