bartblast

bartblast

Creator of Hologram

Suppose you’ve got a Rails app used as the backend, which provides REST API for an SPA frontend such as React, Angular or Ember.

What’s the best approach in your opinion to migrate it incrementally step by step to Phoenix LiveView? The requirement is that it’s transparent for the end user, so no big rewrite.

I’m thinking about using a kind of a reverse proxy which would route already migrated routes to Phoenix LiveView and the non-migrated routes to SPA.

How to handle authentication?..

I’m aware of such packages as PlugRailsCookieSessionStore plug, rails-reverse-proxy gem and reverse_proxy_plug. Are they applicable in this scenario?

Did anyone migrate to Phoenix LiveView incrementally from a similar setup? What was your procedure? What problems have you encountered? Thanks!

Showing Posts 1 to 4

al2o3cr

al2o3cr

Client-side routing in the SPA seems like it would significantly complicate this - you’d need to change the SPA to send a request to the server for some routes. :thinking:

What’s the reason for rewriting to LiveView? That may inform the migration strategy, if there’s a way to start delivering visible results towards that goal incrementally.

You may also find it less painful to migrate in two steps:

  • move over API routes in groups, until you have a Phoenix API + a minimally-changed SPA
  • incrementally switch SPA parts over to LiveView, until you have a Phoenix + LiveView app

This is a “backend first” approach where the SPA changes as little as possible while the Rails part is being replaced.

Flipping things on their heads, there’s a “frontend first” approach but it seems trickier because “make the UI identical” is harder than “make the API identical”:

  • create a Phoenix + LiveView app that calls the Rails API and migrate the SPA over
  • incrementally replace API calls with direct writes
03juan

03juan

What about replacing a part of the SPA by manually mounting a liveview websocket that mutates that part of the DOM independently, and then progressively move more parts of the SPA until the entire route can be rendered through the Phoenix endpoint?

bartblast

bartblast OP

Creator of Hologram

Thank you for your insights! @al2o3cr @03juan

mrkurt

mrkurt

I’d do it route by route and let Phoenix proxy the old stuff.

We run a Phoenix app in front of a Rails app (and a few others, actually), and use this Plug to route pretty much everything to our origin app: GitHub - tallarium/reverse_proxy_plug: 🔛 an Elixir reverse proxy Plug with HTTP/2, chunked transfer and path proxying support · GitHub

When we decide to take over a path, we just add it to our Phoenix router.

We also have Ecto types for a bunch of database stuff the Rails Migrations manage. It works well!

— All posts loaded —

Where Next? Top

Trending in Questions Top

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews