paulstatezny

paulstatezny

Uniform - Less boilerplate, more code reuse in your portfolio of Elixir apps

Announcing Uniform.

Uniform tries to minimize the work required to maintain a large portfolio of Elixir apps. It does this via centralization and automation.

How it works

Uniform works best when you have a portfolio of apps whose core is very similar. (For example, a suite of Phoenix LiveView apps that all use TailwindCSS.)

Here’s how it works:

  1. You build your entire portfolio of apps in a single, “vanilla” Elixir app. (No “umbrella” or “poncho” setup.) You can generate this “Base Project” with mix new, mix phx.new, etc.
  2. You use Uniform’s “blueprint” DSL to set up “base files” and mix dependencies that are required for every app.
  3. You “eject” each app into its own completely separate codebase using mix uniform.eject. The ejected codebase contains the exact project structure you need, with only the code relevant to that app.
  4. You deploy each app using these ejected codebases.
  5. (Recommended) You automate updating ejected codebases via CI, (with mix uniform.eject) so that they basically “update themselves”.

The sales pitch

When you embrace the Uniform approach, it can feel a bit like magic.

  • Security defect in all 10 of the apps you maintain? Fix it in your Base Project and :magic_wand: poof – it’s fixed everywhere.
  • Need to quickly prototype a new app? mix uniform.gen.app my_app and you’re off to the races. No need to set up your suite of common tools for the umpteenth time. (Re-running generators, adding configuration, etc.)
  • Have a private library in one app that you want to use in another? Modify a couple lines of Uniform configuration and it’s instantly available.
  • Want to update some Hex deps across a dozen apps? Update them in your Base Project and they’re updated everywhere.

Uniform tries to lower the amount of effort required for developers to get stuff done. It automates away the manual work needed to keep your codebases “uniform” – in total sync. (But only in the ways you prefer them to be.)

Request for feedback

We know this approach is unconventional to say the least. But we’ve been quietly iterating on it, and it’s working pretty well for us!

We’re very curious what the community at large thinks about this approach.

Links

Click here for the docs and guides.

The code snippets in the Setting up a Phoenix project guide show what it looks like to configure Uniform for a “real” project.

Most Liked

halostatue

halostatue

This looks really useful, and might be interesting to adapt to make it easier to eject into umbrella apps (one of the systems that I’m working on has client-specific modules).

If I might suggest, an example ejectable repo would be useful to better understand how Uniform works, though.

paulstatezny

paulstatezny

@halostatue (and anyone else!) I added an example Uniform project on GitHub.

It’s quite barebones; the example apps are just facades. But it does include the basic structure of setting up Uniform for Phoenix apps. Over time we’ll need to add more to highlight the different features of Uniform.

You can see the codebases that are ejected from the base project here:

paulstatezny

paulstatezny

@halostatue That sounds like it fits perfectly into Uniform’s model.

Are you currently using private Hex packages for that shared code? Copy-pasting it across codebases? Something else?

Feel free to hit me up on Elixir Slack (@paulstatezny) if you want to talk about specifics that you’re not comfortable sharing here. I’d be happy to walk you through a potential setup that fits your needs.

halostatue

halostatue

The current code is…ad hoc and within the umbrella right now. What we’d be looking at retrofitting with Umbrella would be the management of those adapter submodules. I’m thinking we‘d have apps/adapter_template and then somehow do mix uniform.eject --umbrella to know it would be ejecting into the umbrella rather than to a new repo / package. There’s some other bits that would be good (and maybe Uniform could detect).

As I said, though, I’m not even quite sure what it is that we want, and we’ve got a few other overdue upgrade tasks that we’re working through now so we probably won’t be looking at this for a few weeks.

Where Next?

Popular in Libraries Top

mhanberg
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix! You can read this blog post or the docs for more info...
New
RobertDober
Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as...
239 11851 134
New
kelvinst
Hey everyone! Well, we made this lib a while ago and now we decided to finally go out and public with it! It’s a tool for creating and m...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
Qqwy
Solution is a library to help you with working with ok/error-tuples in case and with-expressions by exposing special matching macros, as ...
New
Eiji
ExApi is a library that I’m developing now and hope release soon This library will allow to: list all apis list all api implementation...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
bryanjos
Hi, I wanted share a small library we at Revelry Labs made for rendering react components from the server side. There are instructions fo...
New
Azolo
Hey everyone, I just released WebSockex which is a Elixir WebSocket client. WebSockex strives to work as a OTP special process, be RFC6...
New
KallDrexx
For a good number of months I've been working on creating a very basic RTMP live video streaming server. Now that I have a very, very ba...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
srinivasu
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
sergio
I couldn’t find any guides that worked well with Phoenix 1.6.0 and esbuild. I hope this helps people test the waters and eases you into t...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New

Sub Categories:

We're in Beta

About us Mission Statement