Separate routing from MVC in phoenix

Hi all,

is it possible to separate link definition from MVC in phoenix (separate project in umbrella)? My case is having umbrella with web, domain and email apps, web is calling domain, domain is calling email and email is using web endpoint to generate links.

I solved this case using pubsub between domain <-> email, but still curious if it is possible?

As links are generated from router definition, and in production router initiates the plugs in the compile time you have your answer.

So, if I understand it right, routing module must define routes in some other format at compile time which then would by compiled to phoenix router, after little bit of thinking, it does not seem so hard

Imo this is a classical case for dependency inversion. Instead of making the email part depend on the web endpoint create a behaviour for all the routes it needs. Let web create an implementation for the behaviour and use configuration to tell the email part to use the module defined in web. Now email only depends on web at runtime, when the configured module is used.