Now that we have our local environment all set up, let’s build out our keel schema.
In the root folder of the repo we cloned, we need to create a
schema.keel file, this is where we will define our backend. Think of it as our backend blueprint.
In the schema.keel file, we’ll define our data models for the app, actions that can be taken on those models and permission rules that specify who is allowed to perform the actions we have defined.
The application (opens in a new tab) we are building a backend for a collaborative notes taking SaaS application and it has the following features:
- A user can login or signup
- A user can be part of a team or not
- A user can have an individual account
- A user and a team can have documents
- Users/teams can upload a profile image
- users/teams can change their team name
Everything in Keel is a model, which is built around your data. Models are defined in a
.keel file, they can be named anything and are also fully typed. We need to define the following models for the application based on the above information we know about the application:
These four models will cater for most features of our application and from there we can build out the rest of the backend with the knowledge we get from building them out. Each of these models will have their specific actions, permissions and functions where necessary. Let’s build out the user model.