hubertlepicki
So I have the umbrella project that consists of user_interface and admin applications. I want to display some links from user_interface back to appropriate admin panel section when logged in user is admin. And I also want to display links to public facing URLs in user_interface, from within admin_panel.
As you can guess I am creating circular dependency here. One application has to be compiled before the other, so I think I need to decouple these.
As far as I see it, I have the options to:
- move the routes resolution to runtime. I think either exposing GenServers with registered names on each end that expose underlying router functions will do, or I an use :erlang.apply
- use dependency injection where I would figure out the appropriate router module at run time
- hardcode the URLs

Any other ideas? What do you think would be best?
Trending in Questions
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Do we have maintainer of absinthe-graphql/dataloader here? We have a PR that we’d like to merge to the library. Relatively small additive...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #hex











Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hubertlepicki
Well, there’s also option to just use module names / functions directly, just can’t import them. So I need to make remote call, directly using module names of the other apps. There is no compile-time check for safety, and compiler gives you warning, but that’s probably fine - none of the other solutions give compile time safety either. But I think its the best and simplest. I’ll go with that. Leaving this thread here so it’s helpful for someone in future
benwilson512
I’m not sure that this is the right way to go. Part of the idea of an application is that it can be run independently without anything other than items on its dependency list. If you try to run your admin panel without the user_interface happening to be there it’s going to crash.
hubertlepicki
Which is still good I think. Even if user_interface is not running, if I do:
It will still work as long as the other app is compiled at some point and function exists/matches arity etc. The only problem I see is that compiler will not detect invalid function calls. I.e. I rearrange routes in user interface and my admin interface will crash.
Well I don’t know, it looks like stupid question but surprisingly tough one.
benwilson512
It’s this assumption that is the issue. Build a release with just your admin app in it. It’s only going to have the admin app and the code from the admin apps dependencies. It isn’t going to have any code from the user_interface app.
josevalim
Agreed. Cyclic dependencies should be avoided and it is very likely you are going to run into issues, such as xref warnings. Ideally you would want to move this behind a configuration and have a explicit dependency from a → b or b → a, but not both ways (which is not even possible Mix-wise).
If you expecting too many options, then it likely means you have an artificial boundary between your applications and they should likely stick together.
andre1sk
It looks like refactoring the shared functionality into separate module(s) would be an option
Gazler
In this instance, I’d probably hard-code the URLs on the basis that they are acting as 2 independent systems. I’d probably configure the base url for each so that it can be easily changed.
Assuming the admin interface is running on port 5000 and the web interface on 4000, then I’d configure it like:
Then have a module like:
If I was paranoid about these going out of sync then I’d have a 3rd application that is just for testing, that includes both applications as a dependency and assert the urls match.
This would ensure that things work even if you deploy your admin interface independently from the web interface e.g.
admin.myapp.comhubertlepicki
And this is in fact how it’s going to be deployed/built with distillery. Okay thank you all. I’ll go with not making those apps dependent on each other at all, and hard-code the URLs the way @Gazler suggests.
michalmuskala
For me this is a similar case to having, for example, front-end URLs on back-end in a SPA application (for example a URL in an email).
My preferred way of dealing with things like that is through configuration, similar to a way that @Gazler showed. Alternatively, you could have the configuration keep an MFA you’d call at runtime to produce the link. This, of course, also has the disadvantage of not being checked at compile-time, similar to other dynamic functions.