Install the Backend

Step 1

Download, fork or clone the boilerplate from github and install dependencies.

git clone https://github.com/The-SaaS-Factory/backend-saas-boilerplate-node-apollo-graphql-TS.git
cd backend-saas-boilerplate-node-apollo-graphql-TS
npm install

Step 2

Create a MySQL DB in your local environment (Xampp, Wamp, Laragon, etc).

Step 3

Copy the .env.example file to .env and update the environment variables accordingly.

⚠️

The DATABASE_URL variable is the connection string to your MySQL DB. Example: mysql://root:root@localhost:3306/saas-boilerplate

⚠️

Clerk is already installed in the boilerplate. Only you need update the VITE_CLERK_PUBLISHABLE_KEY variable in the .env file. https://clerk.com/docs/quickstarts/react#set-environment-keys (opens in a new tab)

Step 4

Run the prisma commands to push the schema to the database and generate the client.

npx prisma db push

Step 5

Put some data in the database by running the seed command. (Recommended)

Run the seed

npx prisma db seed  

Step 6

Run the development server.

npm run start

Step 7

Create the admin user:

In the local App

In Clerk

{
  "permissions": [
    "superAdmin:totalAccess"
  ]
}
⚠️

When we edit an organization in Clerk, a webhook is sent to our application. In this way we synchronize the permissions that we have just placed with the permissions of our Database

⚠️

For it to work we must have run seed or manually placed the permissions in the permissions table of our database

⚠️

The other important thing is to have configured the webhook in clerk... For local development we suggest ngrok