zachdaniel

zachdaniel

Creator of Ash

Ash Framework - a declarative, resource-oriented application development framework for Elixir

Ash Framework

What is Ash?

Ash Framework is a declarative, resource-oriented application development framework for Elixir. A resource can model anything, like a database table, an external API, or even custom code. Ash provides a rich, and extensive set of tools for interacting with and building on top of these resources. By modeling your application as a set of resources, other tools know exactly how to use them, allowing extensions like AshGraphql and AshJsonApi to provide top tier APIs with minimal configuration. With filtering/sorting/pagination/calculations/aggregations, pub/sub, policy authorization, rich introspection, and much more built-in, and a comprehensive suite of tools to allow you to build your own extensions, the possibilities are endless.

For those familiar with Phoenix, you can think of Ash as a declarative application modeling layer designed to replace your Phoenix contexts.

Ash Framework 2.0

Ash Framework 2.0 has been released! This begins the official stable release cycle (although it was already quite stable). Thanks to everyone in the community who helped make this possible, from the contributors, the curious, to those already using Ash in prod. I’m eternally grateful for all of your support.

Additionally, I’d like to thank Alembic, who have brought me on to work on Ash full time. Alembic is building complex software with small teams in record time by leveraging tools like Ash Framework and Phoenix LiveView.

Along with the 2.0 release of core, the AshPostgres, AshPhoenix and AshArchival packages have had 1.0 version released as well. AshGraphql is next up, and should be released in the next few weeks. Feel free to dive in to it before then, though :).

Is Ash an alternative to X?

Ash is not meant to be an alternative to Phoenix, Ecto, or Absinthe. Ash uses Ecto under the hood, AshGraphql uses Absinthe. Phoenix is absolutely the recommended way to build web interfaces on top of your Ash application (there is a whole package dedicated to it, AshPhoenix). Ash is not meant to be the only way that you ever interact with your data, so it is almost a certainty that you will need to use Ecto in some cases. For instance, Ash does not currently support bulk actions or atomic updates. For this reason, you can implement custom actions for things that can be encapsulated in your resource, and you have all of Elixir at your disposal to implement custom behavior outside of your resources, with a wide array of escape hatches in between.

Extensions

Extensions in 1.0+

  • AshPostgres - Back a resource with postgres. Rich querying capabilities, supporting aggregates, calculations, and fragments. Comes with a migration generator to get you up and running in record time!
  • AshPhoenix - Helpers to integrate Ash Resources with Phoenix. Tools like AshPhoenix.Form allow you to build forms over your resources, and manage complex nested related data with one data structure.
  • AshArchival - A tiny but powerful extension. Get archival (A.K.A soft deletion) with one line of code.

Extensions <1.0

  • AshGraphql - Create a GraphQL from your resources with only a few lines of code. Backed by the excellent Absinthe library. It comes with its own fully implemented dataloader, and automatically derives all the types, fields, and mutations automatically. Getting a relay compatible GraphQL API is as easy as setting the relay? toggle.
  • AshJsonApi - Create a JSON:API spec compliant API in minutes.
  • AshAdmin - A rich admin UI automatically derived from your resource definitions.
  • AshCsv - Back your resource with a CSV file.
  • Spark - The core declarative DSL library that backs Ash and its extensions.

Unreleased Extensions

  • AshPaperTrail - Creates and manages a versions table for a resource, and writes all changes to that version resource. With one line of code.
  • AshJsonApiWrapper - Back your resource with an external API using finch and configuration to describe how your resource maps to the response from the external service.

Your Own Extensions

All of the extensions above are created with a set of tools that are free to use to create your own extensions. They can all be used as a basis point, or as inspiration. Many users have created their own extensions for various reasons. An extension can both add to the resource’s DSL and programatically restructure the resource. For example, AshArchival adds an attribute, modifies every destroy action, and adds a “base filter” to the resource. This allows for extremely powerful extensions.

Links

Expect to see a lot more content before long, like tutorial and short, topical videos.

Elixir Forum

Up until now, I haven’t posted much here, and have primarily engaged with the community via twitter and discord. However, if there are users here on the forums who are interested, I’m more than happy to answer questions here. For now, I’ll be subscribed to the ash tag, so if you use that, I’ll be notified.

Where to start?

Ash is quite broad, and covers a considerable amount of ground. My suggestion is to follow the tutorials for a kicking off point. There are getting started guides for each individual package as well that, combined, will get you up and running from scratch.

:smiling_face_with_sunglasses: Happy hacking! :smiling_face_with_sunglasses:

Most Liked

zachdaniel

zachdaniel

Creator of Ash

Absolutely @anil28! There are a couple things on the roadmap that I’d like to tackle before I do, but soon I’ll be making a “make a twitter clone” style video along the lines of what @chrismccord did for Phoenix.

21
Post #7
juhalehtonen

juhalehtonen

Huge congratulations on the release! :clap:

I’ve been using Ash on my hobby project(s) for a while now, and now that a stable release is out, I’m definitely going to look into seeing how Ash could be applied in work context as well!

What I also really like about Ash is how powerful (yet straightforward to grasp) the concept of Resources is, and all the power that comes from deriving things out of those resources thanks to the consistent interface between them. The first time I set up ash_json_api for my project, I was just blown away by how much I got out of it – and how little boilerplate I had to write.

In general, the more I’ve used Ash, the more I’ve gotten out of it. Everything fits together really nicely, and I’m yet to encounter a situation where I would need to fight the “Ash way” of doing things. At the same time, it’s also nice to know that I can do what I want if I choose to, and I can adopt Ash gradually instead of in an all-or-nothing way.

bread

bread

Congrats on the release! I’m constantly blown away with the quality of work and support the Ash community has put into this project. It’s gotten to the point that I can’t imagine starting a new Elixir project that doesn’t use Ash, being able to prototype an idea with ETS and switch it over to Postgres with just a few lines of code is really a game changer for me.

zachdaniel

zachdaniel

Creator of Ash

I’ll try to leave most of the talking to other Ash users who see your message :slight_smile: With that said, there are tons of escape hatches at various levels, from adding functional hooks to changes, to making actions manual and taking over their execution. One thing we’re actively working on(because it can be problematic) is making errors more understandable. More often than I would like, errors are lacking important context that would make debugging much easier. I don’t think this is a problem with the pattern, just something that requires some elbow grease on our end :slight_smile: See: add error context to error creation / normalisation by rellen · Pull Request #440 · ash-project/ash · GitHub

In terms of performance, Ash generally leans into other tools to provide performance/stability guarantees, i.e AshPostgres ultimately runs your queries with Ecto. AshJsonApi is built with Plug, and AshGraphql uses Absinthe and Dataloader. I’d be lying if I said there was no additional overhead on top of those tools when using Ash, but similar to the error situation above, that isn’t intrinsic to what we’re doing, just optimizations waiting to be made :slight_smile:

Check out AshHq if you haven’t already, its all implemented with Ash, from an extension that runs full text search with postgres, to the newly added (yesterday) AshBlog data layer that stores files in the priv directory. Lots of goodies in that codebase.

Site: https://ash-hq.org

Source: GitHub - ash-project/ash_hq: The Ash Framework homepage and documentation site.

gdub01

gdub01

I’ve just spent most of the morning looking at Ash.

It looks amazing… and I’m pretty interested in that auth resource you were mentioning on YouTube now =)

Therefore, not clear to me why should I choose Ash over Phoenix

It’s not Ash or Phoenix, but rather Ash handles defining things like permissions/filters/datalayers around resources. There’s no concept of web-related things particularly, although there are exertions you can use to plug into things like Phoenix.

Phoenix does all the things Phoenix will still do… but then Ash comes along to give all these cool ways of defining flows, policies, attributes, etc. that you can call from anywhere - like a Phoenix controller or a Phoenix Liveview.

So it seems the ash framework provides a consistent way to define resources, change them, and read them at a separate layer from web.

It may replace/augment/overlap the idea of ‘contexts’ in Phoenix… but that would be it I think.

I’ve wanted an opinionated way of doing those filters/policies/etc. for a while so I don’t make spaghetti inadvertently =)

Looks awesome.

Where Next?

Popular in News & Updates Top

fhunleth
We recently released Nerves 1.6 and corresponding updates to the Nerves new project generator, nerves_bootstrap and our official systems....
New
bartblast
Hologram v0.6.0 is here, bringing production-ready features to the full-stack Elixir web framework! This release focuses on enhanced secu...
New
zachdaniel
:police_car_light: New AshAuthentication Installers :police_car_light: The AshAuthentication igniter installers are released! Today on s...
New
sorenone
Oban v2.23.0 has been released. Sharpens resilience under database outages, catches misconfigured unique constraints at compile time, an...
New
fhunleth
Nerves v1.14.3 has been released. Changes Remove warning when using Elixir 1.20 Minor doc updates throughout
New
fhunleth
Normally, we don’t announce patch release Nerves systems, but the nerves_system_br v1.30.1 release is particularly important for anyone u...
New
zachdaniel
Going into main shortly, to be released with atomics being wrapped up (which will get its own larger announcement), we will support valid...
New
lawik
It is my pleasure to announce the official release of the new generation of NervesHub with the v2.0.0 release. Containers are tagged. :p...
New
zachdaniel
Hey everyone! Work is progressing nicely on bulk updates &amp; destroys, which are the primary missing features before I switch to focus ...
New
zachdaniel
@jimsynz just launched an epic new extension for Ash! It allows you to create rich mix tasks for calling your resource actions directly f...
New

Other popular topics Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
polypush135
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement