Explore Accounts from IEx

Learn to explore your code using exports in Phoenix.

When we’re working with big applications with huge available libraries, it pays to have a few tools in your toolbox for exploration. Reading code is one technique we can use, and another is looking at the public functions in IEx. To do so we’ll use a function called exports.

Most experienced programmers strive to separate complex code into layers. We’ll have plenty of opportunities to explore these layers from the inside in the upcoming lessons. Right now, rather than focusing on how the code works, we’ll look at the various things that it can do—starting in this section with the Accounts context. The generated Accounts context is the layer that we’ll use to create, read, update, and delete users in the database. It provides an API through which all of these database transactions occur.

The Accounts context will handle a few more responsibilities beyond basic CRUD interactions for a user. When a user logs in, we’ll need a bit of code that looks up a user. We’ll need to store an intermediate representation called a token in our database to keep our application secure. We’ll also need a way for our user to securely update their email or password. We’ll do all of these things in the Accounts context.

How to view public functions

We can get a good idea of what the Accounts context does by looking at its public functions. Luckily, IEx makes this easy. Open up the IEx with iex -S mix in the terminal given below, alias the context, and get a look at the exports, like this:

Get hands-on with 1200+ tech skills courses.