Phoenix API-only with Admin Panel

Hey! I’m returning back to Elixir and Phoenix after 2 years break, so I need to catch up a bit.
In my project, I’m going to build frontend with ReactJS, and backend with Elixir Phoenix, as API-only. I’m aware that I can use --no-html flag to create Phoenix without HTML. But also, I would like to have the Admin Panel, and I would like to have this with the minimal effort. I could use “standalone” admin panel like AppSmith running in another Docker Container. But I believe that doing it with Phoenix Elixir and Kaffy/Torch, it should be easier (+ I have an access to models/methods/actions, etc.).

Not looking here a detailed instructions how to do it, but your opinions and experience, whether does it make sense or not, and what can be tricky. And maybe how to start building this. For instance, I can use --no-html and then add missing libraries, or go opposite: start with full package and then remove unnecessary.

Thanks for all your help!

1 Like

I’m using the following pattern:

  1. create an umbrella.
  2. create an app for the core business domain:
$ mix phx.new.ecto demo
  1. create an app for Web API:
$ mix phx.new.web \
  --binary-id \
  --no-assets \
  --no-html \
  --no-live \
  --no-dashboard \
  demo_web_api
  1. create an app for admin dashboard:
$ mix phx.new.web \
  --binary-id \
  --no-dashboard \
  demo_admin

In development, I:

  1. I will abstact my business in demo.
  2. expose demo to frontend developers by demo_web_api
  3. expose demo to administrators by demo_admin

When I am ready to ship, I will create a release with all these apps.

Pros:

  • every app has its own responsibility, It’s easy to add or remove new app without changing the core business domain. And you are confident to do that.

Cons:

  • a little verbose.

Back to your questions:

  1. Should I start from minimal deps or full deps? In demo, I prefer minimal. In demo_web_api and demo_admin, I prefer full deps.
  2. Should I use an AppSmith or Kaffy / Torch? I depends. If the work schedule is tight, and you don’t want to improve your skills by writing an admin panel, It’s ok to use them.
2 Likes

The same can be done using the Components projects approach, that @pragdave promotes and that I think its very well suited to separate responsibilities, like suggested with the use of umbrella apps. You can see this approach in my repo for his course:

3 Likes

Cool! I like the umbrella approach, thanks!