Phoenix Admin Frameworks

Phoenix Admin Frameworks

A very subjective evaluation

Tl;Dr version

I personally feel like you should probably either use Kaffy or roll your own admin interface completely from scratch. If you wanna know why, read on.

This is my very own analysis for my particular needs. Don't take it as being authoritative in any way. Hopefully it helps you in making a decision though :). As always, try stuff yourself before going all in!
💖
Even though I'm critiquing open source projects, I love what y'all are doing and the stuff you're making is amazing! I wouldn't be able to do my work without all the wonderful open source libraries out there! A lot of maintainers are doing their work on late evenings (after their regular work), and there's never time enough to do all the things you want to do...I get it :)

How did I get there?

I needed to add a small admin interface to an app I'm making. I've used the Django admin before, and while it's not the most beautiful thing in the world it's often "good enough" to get the job done. Here's a few screenshots if you haven't seen it before.

Polls change list page

Editing form for question object

It has two key things I had a need for:

  • Good filtering/searching so I can find what I'm looking for.

  • Ability to execute custom actions on an entry.

My, somewhat simplified, use case is:

  1. Find "companies" in my database that need my attention (filtering).

  2. Do some manual checks outside of the system.

  3. Execute an action for the company (custom actions), based on the outcome of step 2.

I checked the Elixir Toolbox page and found a set of different options.

Before we get into those, let's just make it clear what I'm running:

  • phoenix 1.7.10

  • phoenix_html 4.0.0.

This matters, because quite a few of the options have issues with such recent phoenix or phoenix_html versions.

Let's see what we got...

ex_admin

ex_admin seems abandoned. Last release was on Apr 24, 2016, and it doesn't work with modern Phoenix.

live_admin

live_admin was a breeze to get working. Sprinkle a few lines of config to expose the schemas you'd like to the admin interface.

Pros

  • Very easy to get started.

  • Gives you a way to search, edit, create and delete.

Cons

  • The current release on hex.pm doesn't work with phoenix_html 4.0.0. You need to get it from github to get it working. I'm sure this will be addressed shortly though, since the issue has been identified and even fixed, just not released.

  • There is search, but no more advanced filtering, from what I can see.

  • There's very limited documentation, to say the least.

  • Apparently there's a way to do custom actions, but I can't figure out how.

  • Gives you that "buggy feeling". As an example, when I type into the search box it does the search automatically after maybe half a second, and loses focus on the input field.

  • It looks ugly imo. I'm not usually picky about these kinds of things, but this is just too much for me. Apparently better default styling and custom CSS is on the roadmap, but it's not there yet.

Verdict

Seems actively maintained. Could become a contender in the future, but based on where it's at right now I'd be hard pressed to recommend it. Not for me this time.

Torch

torch is a bit different because it uses code generation to make you an admin interface. This means you'll get a lot of HEEx templates and controller files in your app that you have to care for going forward.

Pros

  • It actually looks quite nice.

  • Great filtering system - probably the best of them all.

Cons

  • It doesn't support custom actions, which are essential for my use case. Docs are very limited, so I’m not 100% certain, but that on its own is a problem.

  • Does NOT support Phoenix HTML 4.0 yet, so that itself makes it a no-go. However, there’s a fork which supports it, but it’s not merged into the main repository just yet. Even with the fork I still had errors in one of the .heex templates I needed to fix before things compiled.

  • The fact that development is so slow is worrying. Very little activity lately. Phoenix HTML 4.0 has been out since Dec 19, 2023, and Torch still doesn't work with it (Apr 5, 2024). It's worth mentioning that it takes very few changes to make your project compatible with Phoenix HTML 4.0.

  • I don't like the fact that it's using code generation, for this case. It makes future upgrades harder, and puts more of the maintenance burden on me. The upside is that you get "infinite configurability" since you can rewrite every single line of code if you want. In my case I like my admin to be more like a "low effort, just drop in" thing. Something I can get started with quickly, and update easily.

  • I had to struggle quite a bit to get it to work with my existing schemas. Probably a user error though.

Verdict

If all you want is a database browser, this might be it. You should maybe consider just using something like DBeaver in that case though. It felt like a lot of effort get set up properly, and quite some future effort maintaining it all as well. Not for me.

Kaffy

kaffy is configuration based, and not code generating, just like live_admin. With just a few lines of config you can have your first schema exposed through the admin.

Pros

  • Docs are not great, but not horrible either. Most of what you wanna know is documented. Most of the docs are at the Github page, but there's also a few things that are spread out in the reference documentation, and not linked to. I'm listing it as a pro, but don't have too high expectations.

  • As you can see from their demo page in the third screenshot - this admin library is more than just a simple data browser. You can add different types of widgets ("text", "tidbit", "progress", "chart").

  • This too, actually looks quite nice.

  • It supports searching, and you can also add your own filters where you want them, like the "type" filter in the first screenshot. The filters aren't as advanced as the ones in Torch, but they're decent.

  • Custom actions are very simple to add (see screenshot 2).

Cons

  • Has some rough edges w.r.t. Phoenix 1.7 / Phoenix HTML 4.0 compatibility. Right now you need to enable router helpers and install phoenix_views, as well as use a revision from an open pull request to get it working. That’s not the end of the world, and I really hope it’ll be fixed in the future.

  • I had some "gotchas" that took a few minutes to figure out when starting to customize Kaffy. Nothing too bad, but still slightly annoying.

  • There are some surprising inconsistencies in capabilities. For example, if you write a custom action affecting multiple items, you can have a modal pop up and ask for input. If your custom action affects a single item - you can't!

Verdict

I would wish that certain things were better documented, some error messages more clear, and a nice side panel for filtering. Regardless, this is a really pleasant admin UI to work with! It ticks all the boxes for me.

Rolling your own

Hey, don't stop reading just yet - I'm not crazy!

The current Elixir admin frameworks aren't super awesome (just yet). Coming from Django admin there were a lot of things I was used to that aren't available. It's likely that you'll run into some limitations that'll "force" you take take the route of creating (part of) your admin UI yourself.

However, with LiveView in particular it's actually really easy to put a basic Admin UI in place. If all you need is the ability to display a few numbers, and run some custom actions, this might very well be the right approach for you!

If you decide to go down this route though - be wary of going too far. If you end up building another full fledged admin framework then you might have gone too far, and it's probably smarter to put the focus back on your core product 😊.