Yesterday I may have tweeted one of my biggest understatements of the year, which kind of went like this:
Some people close to me pointed out that "pretty dope" may not really cover how I really think about the platform, because after I first found out about Directus, it was what I talked about non-stop for a couple of days straight 😅
- Directus is an open-source data platform. In my opinion, it's the most mature and works for many use cases.
- It allows you to build a backend for a project in hours instead of weeks, for real.
- Imo, platforms like these will likely transform how (web) applications are built in the (near) future.
My journey to Directus
Let me walk you through my journey to using Directus. It all started when we wanted to store some employee-related data in a structured way while complying with rules and regulations and with the ability to automate some boring stuff @ Freave.
We started looking into Airtable. Many cool companies use Airtable these days, and it has a lot of the features we were looking for. But after some quick experimenting, we quickly realized it wasn't going to cover our use case (GDPR, US-hosting, no self-hosting option, etc.). So, our search continued...
We then stumbled on Baserow, an awesome open-source alternative to Airtable. It has most of the features that Airtable has, but you can self-host it 🙌🏻
So we hosted an instance with Baserow and started defining our data structure. Baserow really shined here because we could just start adding tables and fields without really knowing what the final structure would look like. You can always change on the fly.
But after our initial configuration, we started bumping into some issues for our specific use case:
- The Baserow API uses keys like
field_470210and table ID's like
71300(which is probably how they store the data internally). That made working with the API less intuitive than we wanted (you had to look up table & field ID's continuously)
- Baserow "owns" your DB. They define the structure, data, etc. So that made it hard(er) to query the data directly on the DB.
- The ease of use and flexibility of Baserow comes at a cost. E.g., it's straightforward to link two records together, but you can not restrict that link to just one record (many-to-one).
- There's no input validation. For our use case, that simply was a necessity.
- And some other issues that made Baserow incompatible with our use case.
I really do want to emphasize that Baserow is an awesome project. It's incredibly flexible and makes it a breeze to create (e.g., sign up) forms, organize data, share data, etc. And we still use it for some other use cases. So if you're specifically looking for a great self-hosted Airtable alternative, definitely check out Baserow.
Maybe Directus is a fit?
So after a while, Directus piques our interest. "Power any project with a modern, open-source data platform" reads their website. Definitely worth looking into.
So I follow their "Installing with Docker"-guide and pretty much run one (!) command:
docker run \ -p 8055:8055 \ -e KEY=255d861b-5ea1-5996-9aa3-922530ec40b1 \ -e SECRET=6116487b-cda1-52c2-b5b5-c8022c45e263 \ directus/directus
Doesn't even take a minute, and my terminal reads
Server started at http://0.0.0.0:8055. I check out the URL in the browser, and I'm presented with a sleek login UI (autogenerated pw in the terminal).
I log in and see that there are "no collections". So I "create a collection" and am presented with a UI that prompts me to define the table for a data model.
In the next hour, I learn that:
- By running one command, Directus was fully installed, migrated, etc and is now hosting a:
- REST API
- GraphQL API
- Admin panel
- Collections are tables
- Everything you model in the "Data model" section is immediately reflected in the API's, admin panel, CLI & DB.
- Directus doesn't care which DB you're using, and it also doesn't care if you use another tool to run migrations. Or if you skip their APIs and just directly talk to the DB
- The REST API it provides is not only intuitive but also supports everything you'd want it to
- Their ACL is powerful2. Like, insanely powerful
- Directus supports a lot of field types
- Has a built-in file manager that has all the features you'd want
- And way more
Before I continue, I just want to remind you that up until this point, we've only run one (!!!) command to start experimenting with Directus. Have Docker installed on your machine? Just take a minute to get it running. It'll help you understand my excitement.
Perfect fit for our use-case
So back to our use case: we wanted to store some employee-related data safely and automate some boring stuff. Let's see how Directus fits:
- ✅ Host it ourselves (helps with data regulations)
- ✅ No-code solution to build an advanced data structure
- ✅ (Very) advanced ACL to protect against unauthorized use
- ✅ Can automate boring stuff (in like >3 ways, e.g., webhooks, polling data, or Flows 👀)
It then cost us less than an hour to configure the models as we wanted, then change some stuff, and another couple of hours to automate what we wanted. And this is where Directus really shines. Building this ourselves would have literally cost 1 FTE at least a week to build.
To be fair, we did run into some issues when we started hosting it in a production-ready way. But that had more to do with some internal stuff we had to comply with.
Wow—this is really cool
Going from an idea to a working project in such a short time span is a very cool thing to be able to do. And it also puts some of the power developers have in many people's hands. Pretty much as long as you can start a Docker container and have some idea of data structures.
I then started experimenting with Directus for some other projects. Some related to work, some not.
- At one of my companies, we create marketing content for other companies. Other companies share some minimal content, events, and announcements with us, and we manage the rest. Took us less than a day to map the entire data structure to Directus, configure it so we could use it as a customer portal, and automate some stuff around it.
- I was curious about how Directus handled large datasets. So I imported vehicle data of every single car in the Netherlands (15M) into it (bypassed Directus for the import, so directly into the DB because that made sense performance-wise). Have to admit that Directus doesn't really handle these kinds of datasets (with relations) very well in the UI, but the API was still blazing fast.
- We've also expanded our initial use case to include more data and to automate more stuff. Which has been a breeze.
And these are just some examples. Because Directus can pretty much be the backend to anything you'd like. There are definitely use cases where it wouldn't work, but given that many web applications are just glorified database viewers, I think Directus is a right fit in many cases.
I also want to note that I've now touched on only 10% of what Directus is capable of. I've already created three draft posts of stuff I'm excited about. So I might expand on that more in the future.
Some topics I think are really cool and want to expand on:
- Directus ACL: is really powerful. Using roles & permissions, you can very granularly specify who can do what. It gets a little complex when many relations are involved, but that's also where it shines.
- The REST API (and GraphQL) it exposes. Has all the features you need and is very intuitive to use. Authenticate by exchanging your credentials for a JWT token or get a static access token from the UI.
- Automating stuff. Which you can do by using webhooks or by built-in Flows. Which has just received a major upgrade where you can now write custom code in a flow to have it do exactly what you want. Or you could still use the drag-and-drop editor for a lot of stuff as well.
- Translations. Because they're implemented really well. You can pretty much translate every part of the application, and it comes with translations for default components baked in.
- Data validation. Which can be incredibly extensive. You can even define custom validation rules for different roles 🤯
- Activity log & revisions. You can choose whether you'd like to include collections in the logs & revisions. And if you do, you get access to revisions for every change ever made to a model. With the exact changes made and by who (🤯, again). And you can use the activity log to comply with regulations by using it as an audit log (it doesn't support logging
viewevents, but you can easily accomplish that by creating an extension or simply using the webserver access log).
- Layouts. Which you can use to view your data in whatever way makes sense to you. Tables, cards, maps, or calendars. Whatevs 🙌🏻
- Single Sign-On. Which once again: 🤯. Takes you 5 minutes to integrate single sign-on in your admin panel.
For now, just run the Docker command and start experimenting 🚀. You won't regret it.