Skip to main content
You’ll build the backend for a small sales CRM where reps manage their own deals and managers see everything.

What you'll build

1

Create the project

Create a project named CRM. (Or describe it to the AI builder: “A CRM with companies, contacts, deals with stages, and activities”, then adjust.)
2

Create collections and fields

3

Add relations

4

Add a login guard

Create a guard on users with login field email. Turn registration off: you’ll add staff yourself in the dashboard. See Guards.
5

Create roles and permissions

6

Add row-level security

  • sales_rep on deals and activities: default owner behavior. Reps see records they created.
  • sales_rep on companies, contacts, users: allow field_equals on a field every record has, so reps see the shared directory.
  • sales_manager: allow policies covering every record, so managers see the whole pipeline.
See Row-level security.
7

Add a hook

beforeUpdate on deals: stamp the close date when a deal is won or lost. (Add a closed_on Date field first.)
8

Build a pipeline report

Report on deals: dimension stage, metrics count and sum(value). Add a dashboard with stats Open pipeline value and Deals won this month.
9

Connect the frontend

Create an end_users API key with your app’s origin. Reps log in with POST /auth/users/login and load their deals:
See the JavaScript client.
You have a multi-user CRM backend with validation, access control, business rules, and reporting.