Creating a SaaS Entity Builder

Creating a SaaS Entity Builder

From custom properties to auto-generated API, Views, Forms, and everything an Entity might need.

Why Custom Entities?

I posted a poll on LinkedIn about “Typed-interfaces vs Custom Entities” and it would seem that custom entities are a bad choice. But let me explain why I think it’s in your best interest to implement them.

Only 22% voted for Custom Entities

Easier to track = easier to limit

Every SaaS has plan limits, let’s say your application is an employee management system. Your /pricing page would look like this:

  • Basic plan - 10 employees/month
  • Pro plan - 30 employees/month
  • Enterprise plan - 100 employees/month

The standard way of implementing this is to have your PricingPlan object track the “Employee” limits:

Employees per month

It might seem easy, but imagine down the road you need to track another entity EmployeePayments, and for the sake of the argument, you want to let your Basic plan members make up to 10 payments and Pro plan members up to 20 payments PER MONTH.

Plan limits just became more difficult:

max payments or payments per month

Extracting the limits logic

Let’s fix this by adding another interface/DB-model PlanLimit:

PlanLimit interface

Look at line #9, we had to define our entity anyway!!

Custom Entity Advantages

Now, why should we define our entity properties if we already have done that on the Database/ORM layer?

Employee database model

The reason is:

  • Plan Limits
  • Instant API
  • Autogenerated Views
  • Autogenerated Forms
  • Logs/Audit Trails
  • Workflows
  • Webhooks

If we were to build our application manually, we’d need to implement all these features for EVERY new entity, or worse, start over when creating a new SaaS.

That’s why I’m building this Entity Builder on my Remix SaaS kit.

Custom Entity Builder

Plan Limits

Plan Limits for “Employees”

Instant API

“Employees” API

GET — /api/employees

Autogenerated Views

Table View

Autogenerated Forms

Create Form

Logs/Audit Trails

Logs/Audit Trails

Workflows and Webhooks

I’m still working on those 🛠️.


Let me know what‘s missing 😀!

Did you find this article valuable?

Support Alexandro Martínez by becoming a sponsor. Any amount is appreciated!