Using REST API for Core App in Umbrella Project Question

Hello, I had a question on design philosophy regarding a web app I’m working on.

I plan to make a website using Phoenix to provide a service that will also have a REST API for users to programmatically use that service. I was looking into repo design and saw that many projects had a “core” app that interfaces with more specialized logic apps and the web app. Maybe a dumb question, but I was wondering if it would be worth making the core app a REST API essentially and have users access it directly or if that would make the design too unwieldy. The reason I was doing so was mainly because I was considering the option to integrate a Nerves component to allow embedded devices to more easily use the service provided, but wasn’t sure if it was just unnecessary. The main issue I see is that the website would have some functionalities (like a search bar for the mentioned services) that wouldn’t necessarily be supported by the REST API. Does this sound like an awful idea or does anyone have success attempting something like this.

1 Like

I’m still rather new but I’ve seen a pushback against umbrellas unless you absolutely need them. If you’re deploying a flock of applications on the same docker/k8s/vm then it may make sense. If you’re coupling this application to another in a modular way, it probably makes sense. Livebook may not be the best example but it’s a typical Phoenix project that also tacks on a CLI (see https://github.com/livebook-dev/livebook/tree/main/lib) and it is not an umbrella.

There very much is a place for umbrellas but I came from C# where I’d have a core, data layer, CLI, with web and/or desktop. I never used those layers independently except maybe CLI would use core and data or the other UI layers would also use core and data. It made no sense for core and data to be separate at all. I deployed everything together as well. .NET paradigms aren’t 1:1 at all with Elixir really, it’s mostly an illustration that what I thought was “the way” was a decade ago but also not worth the abstraction. Now I take the approach of build first then pull things out when there’s a very clear separation that makes sense. If that core should be it’s own hex library for instance, umbrella makes sense.

Generally, you’d keep the application-logic bits (what’s in most “core” apps) separate from the REST API bits (which you’ll frequently see named <whatever_the_core_app_is>_web).

1 Like