The Phoenix Files

Phoenix and LiveView applications are awesome on Fly.io! This is the home for Phoenix-oriented content ranging from Ecto to LiveView and more.

By Mark Ericksen

Taking Control of Map Sort Order in Elixir

If you've recently upgraded to Elixir 1.14.4 and OTP 26, you may have noticed that map keys are no longer showing in a predictable order. Fear not! Understanding why it's happening and taking the time to sort the keys by default can save you some ...

Read more about Taking Control of Map Sort Order in Elixir
By Jason Stiebs

Streaming OpenAI Responses

ProblemYou are building an application that interfaces with OpenAI's ChatGPT and want to create a real time interactive experience just like the OpenAI Chat UI. To do this we will need to work with the ChatGPT Streaming API, which is built using...

Read more about Streaming OpenAI responses
By Mark Ericksen

Loading a structure.sql File on Prod Without Mix

ProblemAt some point, you or your team ran mix ecto.dump and generated a priv/repo/structure.sql file. Then old migrations files were removed. Things were great and you could handle the local dev and test setup using mix ecto.load. If you were mi...

Read more about Loading a structure.sql file on Prod without mix
By Jason Stiebs

Tensors and Nx, Are Not Just for Machine Learning

The Elixir community has a sleeping giant brewing with Nx, and not just for Machine Learning. Nx allows you to describe nearly any numerical operation, which can then be run in an optimized environment for such operations. If you read the Nx READM...

Read more about Tensors and Nx, are not just for machine learning
By Mark Ericksen

Developing After Mix ecto.dump

ProblemAt some point, you or your team decided to cut the dead weight of many old migrations and instead run mix ecto.dump and generate a priv/repo/structure.sql file. Now you want to bootstrap a new staging server, dev environment, or just get s...

Read more about Developing after mix ecto.dump
By Berenice Medel

Building a Drag-and-Drop List With LiveView and SortableJS

In this post, we'll create a List component with draggable and droppable elements functionality. We'll use some components from core_components.ex to design the List component, and then add the necessary logic to implement its behavior. The end re...

Read more about Building a Drag-and-Drop List with LiveView and SortableJS
By Jason Stiebs

Minimum Viable ChatGPT Plugin

ProblemYou just got access to the ChatGPT Plugin beta, and you want to hook up your database of knowledge to the AI GPT4, so it can help you and customers navigate your complex world. You've never done that, and all of their docs are in Python......

Read more about Minimum Viable ChatGPT Plugin
By Chris McCord

Phoenix LiveView Zipped Uploads

File and image uploads in LiveView are already easy and elegant. But what if the user wants to upload an entire directory with more nested directories and files? How should we handle that? Chris McCord walks us through what it takes to make that a...

Read more about Phoenix LiveView Zipped Uploads
By Jason Stiebs

Elixir and Rust Is a Good Mix

ProblemWe need to perform a CPU intensive or system level programming task and there are just no good solutions in hex.pm, in this example let's pretend there are no good ways to do image processing with Elixir. As is often the case, there IS a h...

Read more about Elixir and Rust is a good mix
By Mark Ericksen

Can Phoenix Safely Use the Zip Module?

A lot of cool stuff is available in Erlang's OTP Standard Library. Elixir has the ability to directly use everything in OTP and that means we have a number of built-in features available to us. One of those features is the Erlang :zip module. As t...

Read more about Can Phoenix Safely use the Zip Module?
By Jason Stiebs

Crafting Your Own Static Site Generator Using Phoenix

The year is 2023, you have many options for building a Static Website. From the OG Jekyll to literally hundreds of JavaScript based options to people suggesting you should just craft HTML by hand. All of these solutions are correct and good, and y...

Read more about Crafting your own Static Site Generator using Phoenix
By Sophie DeBenedetto

Building a Chat App With LiveView Streams

In this post, we'll build out a LiveView chatroom app with the help of LiveView's new streams feature. You can follow along in the open source codebase or skip ahead to play around with the finished product. We'll see how streams seamlessly integr...

Read more about Building a Chat App with LiveView Streams