tldr; I have a moderate sized PoC elixir code base collecting dust that will never be used again, and hopefully it has something someone will need.
Background
I've been looking into different markets for my next startup. One that stood out was Student Housing software for colleges and universities. What intrigued me initially was that the #1 company bought #2 and #3 in 2022, so the options for colleges dwindled to just a few. And the #1 can now charge 4-5x resulting in 6 figure yearly bills!
Certainly I can build something that I could charge significantly less that would benefit the few thousand smaller colleges that couldn't afford that price gouging.
While I was deep in customer discovery, I figured I would also build out a PoC to show directors at the school to let them know I deeply understood the problems they faced. If they could see that, then maybe they would give me a shot.
The Stack
I always need to be learning, so I took the chance to finally learn Ash. Something about it screamed "Yes!" to me.
My previous passion project was ClickDuel and I used that to really dive into Elixir and LiveView. Take a look, my kids and I still love using it. So the housing app was my chance to take a deep dive into Ash.
Ash
As with any new tool, there is a ramp up period. Ash was no different. During the 4 months I worked on this project, as I struggled with doing some basic stuff (like Phoenix Forms using Ash) I kept asking myself, "Is Ash really gonna make me faster in the long run?" Now that I am on 2 other new projects, both using the same stack as above, I can confidently say yes. I am glad I had the time to learn Ash. The speed at which I got the new stuff up was crazy fast. And 3.0 introduces domains, which encapsulate code so much better.
I have used ORMs in PHP, C#, Ruby, and NodeJS, so I am well versed in the problems of figuring out your domain and data structures and mapping that to the tool du jour. Ash is not an ORM, but it serves the problem, and I like Ash's approach so much better than others.
The team is really responsive answering questions in their forum.
For my deployment model, every school would need to be isolated in the database, and Ash's multi-tenancy approach made this dead-a$$ simple to implement. Like, a few lines of code.
Ash also has a powerful policy system to enforce access to data, but it was just too much to learn, so I constantly just disabled it.
User Defined Schemas
The thing with Student Housing is that an immense amount of it is based on dozens of forms. A form to request housing, a form for your profile, a form to be an RA, a form to switch rooms, a form to submit a maintenance ticket. You get the picture.
But the problem is that every single school has their own fields and structure and workflow for these forms. So I went with our buddy, JSON Schema. There is a decent chunk of code dealing with that. Chances are, I ran into the same problem as you, if you're using JSON Schema...
Other tools
Don't reinvent the wheel!
Flowbite
One of the things that I am happy to drop $ on are good looking UI components. Flowbite does a great job with theirs. Dark mode just works. Finally got a good looking sidebar to quickly view an item; always wanted to implement that. Though I will say their dropdown logic is flaky.
AG Grid
I made extensive use of AG Grid. There are LiveView hooks and whatnot showing how I loaded data, and stylized different types like bools, links, and status.
JSON Editor
This provided a simple drop-in to edit JSON Schemas. Visual drag n drop was out of scope for the PoC, though I did try some out. O' lord did I try them out. Days of my life I want back.
ExJsonSchema
Great JSON schema validator.
SortableJS
This allowed me to provide a way to sort items in the UI.
react-querybuilder
There is no chance I am using this properly. I don't understand React at all (I'm a Vue dev). But I needed to allow users to build complex queries, and this is a no-brainer tool to use for that purpose. The challenge was using it in LiveView.
JSX
I think it was just changing to --target=es2020
and I was able to use .jsx
files alongside .js
which made some of the Javascript work easier.
Finally, the code
Please keep in mind that this was implemented as a proof of concept. I just needed to get some stuff working, and not necessarily working well, and certainly not with any tests.
Many times, I went with whatever approach worked, and moved on with life, so please be mindful of that if you browse the code. Though, if I did something stupid, please let me know so I can fix it in future projects I work on.
https://github.com/lardcanoe/housing-app
If I get 10 likes, or some comments, I'll take the time to document how to get it running locally. It's should be pretty typical for an elixir app though...
I am more than happy to expand on any topic above, or others. Just leave a comment.
Top comments (10)
Great repo.
With Ash, I am taking a similar bet. - after 2-3 months, it should give me the speed 🚄.
Currently struggling with phoenix forms. Any suggestions/ tips from your end on those?
P.S. will dig more in the repo in upcoming week
Of course! I had a bunch of tabs open to numerous repos, and I would just hunt for usage of an Ash function I needed, and looked at how they did it.
And hopefully my repo can now be one someone else hunts in. Though, keep in mind I think most of those are Ash 2.0, including mine. With 3.0, you now need to make your attributes in the form public.
My biggest issue was using embedded resources, with
inputs_for
and it turns out most of my problems were because I failed to include the relation in the list ofaccepts
of the action. This would result in some cryptic message, and lead me down the wrong path. Once I fixed it, I could just useforms: [auto?: true]
That being said, the Ash docs are MUCH better now.
We've added hints in said cryptic error message about no form being configured. like "did you mean to accept this attribute?", to help mitigate these issues. Was definitely very confusing, and TBH I had no idea it was causing so much confusion before it was brought to my attention 😂
oh, I just realized it was you who originally brought it to my attention 😂
I've spent the last few months working on an Ash project, looking forward to 3.0
See a discussion at elixirforum.com/t/ash-framework-3-... for 3.0
I left my notes in the tread as well.
Hey Steve,
The app itself looks really good - what happened with the pitch?
A few notes:
I have an obscene amount of notes for all this, but I won't be making that public.
Yes, that sounds fairly brutal.
So did the #1 app maker buy you out of serving the category as an organization, convince you that small colleges need to bleed $111k at a time at student housing to-do, or just fall over?