cd Desktop
mkdir saas-boilerplate
or whatever you would like to call itcd saas-boilerplate
mkdir backend
cd backend
git clone https://github.com/rcmiskin10/dj_react_backend_render_template.git .
pip install virtualenv
python3.8 -m venv env
source env/bin/activate
pip install -r requirements.txt
- Create a file called
.env
and place the environmental variables from below:
STRIPE_API_TEST_PK=<STRIPE_API_TEST_PK>
STRIPE_API_TEST_SK=<STRIPE_API_TEST_SK>
STRIPE_LIVE_MODE=False
PROD_BACKEND_URL=<PROD_BACKEND_URL>
PROD_FRONTEND_URL=<PROD_FRONTEND_URL>
BACKEND_URL=http://127.0.0.1
FRONTEND_URL=http://localhost:3000
DEBUG=True
DEV_EMAIL_HOST_USER=<DEV_EMAIL_HOST_USER>
DEV_EMAIL_HOST_PASSWORD=<DEV_EMAIL_HOST_PASSWORD>
POSTMARK_SERVER_TOKEN=<POSTMARK_SERVER_TOKEN>
DEFAULT_FROM_EMAIL=<DEFAULT_FROM_EMAIL>
- Now you need to set up Stripe.
- If you do not have a stripe account register a free one here: https://dashboard.stripe.com/register. If you do have a stripe account login here: https://dashboard.stripe.com/login.
- Once account is set up or you're logged in, turn on
Test Mode
(Toggle button in top right corner of dashboard) it should bring you to: https://dashboard.stripe.com/test/payments - Go to https://dashboard.stripe.com/test/apikeys
- Grab your
Publishable key
token and set the environmental variableSTRIPE_API_TEST_PK
in your.env
file created from step11
above. - Next grab your
Secret key
token and set the environmental variableSTRIPE_API_TEST_SK
in your.env
file created from step11
above.
- Grab your
- Next go to https://dashboard.stripe.com/test/products?active=true to add your products, i.e. subscription tiers
- Add as many tiers as you want i.e.
- Free w/ a description and price: $0
- Pro w/ a description and price: say $10
- Make sure both are Recurring and Monthly or however you would like to set up your subscriptions.
- Add as many tiers as you want i.e.
- Now set up your local Postgres database
- Download Postgres v13 (or latest version) from https://www.postgresql.org/download/macosx/ and follow instructions.
- Create database, i.e.
postgres
- Make sure your database default setting in
settings.py
isdefault="postgresql://postgres:postgres@localhost/postgres"
, if your database name ispostgres
. - Now run
python manage.py migrate
- you should see all migrations applied
- Then
python manage.py createsuperuser
so you can log into Django Admin- Enter email and password.
- Now run
python manage.py runserver
and head to http://127.0.0.1:8000/admin/login/ and login with email and password created in13.5.1
- you should be able to get to the Django Admin now and see all of the tables.
- Now go to Products admin here: http://127.0.0.1:8000/admin/payments/product/
1. Add First product from Stripe above in step
12.4.1
- Enter the Product Name
- Tier
- Stripe product id
- You can find Stripe Product Id in https://dashboard.stripe.com/test/products?active=true and click on product and in the URL you will see an ID with prefix
prod_xxxxxxxx
and letters and numbers as the unique id. - Do the same for all products 2. Now go to http://127.0.0.1:8000/admin/payments/productprice/
- You can find Stripe Product Id in https://dashboard.stripe.com/test/products?active=true and click on product and in the URL you will see an ID with prefix
- Add the price for each product from Stripe here: http://127.0.0.1:8000/admin/payments/productprice/add/
- Select
Product
that you added to Django in14.1
- Add the Price from what you entered in on Stripe
- Add the interval, i.e. Monthly
- Add the stripe price id
- Go to https://dashboard.stripe.com/test/products?active=true
- Select the Product and scroll down to
Pricing
and look underAPI ID
and copy id with prefix and numbers/letters likeprice_xxxxxxxxx
and pase into stripe price id on django admin.
- Do for all products 3. Now you can add descriptions of the tiers here: http://127.0.0.1:8000/admin/payments/productdescriptionitem/add/
- Select
- Add as many description list items for each product
- Now we can add the rest of our environmental variables in
.env
1. SetDEV_EMAIL_HOST_USER
to yourgmail
for DEV testing 2. Set yourDEV_EMAIL_HOST_PASSWORD
to the password set up in your gmail account from above. You need to create an App Password in: https://myaccount.google.com/security- Make sure 2-Step Authentication is enabled.
- Then go to https://myaccount.google.com/apppasswords and create a new app and a new password will be created. 3. Now Emails will be sent through gmail smtp in DEV
- We will set up prod environmental variables later.
- Next up is setting up the landing page data.
- Note here you can add whatever copy, images, icons, you would like through the Django admin
- Go to http://127.0.0.1:8000/admin/landingpage/landingpage/add/
- Add the hero section copy and image
- Add the features of your SaaS
- the
Feature mui icon name:
can be selected from https://mui.com/material-ui/material-icons/?query i.e. findAdd
and get the name of the icon from the end of the import in the modalimport AddIcon from '@mui/icons-material/Add';
i.e.Add
- the
- You can add as many features as you like and
Order
them however you like by apply1,2,3...
to each feature. i.e. 1 will be first in line. - Do the same for how it works, Secondary hero, and Social Media Links
- Go to http://127.0.0.1:8000/admin/landingpage/landingpage/add/
- Note here you can add whatever copy, images, icons, you would like through the Django admin
- Next we will deploy to render.com.
- First set up Cloudinary by going to the cloudinary website through this link and create a free cloudinary account. After your account has been created go to the dashboard page and copy the cloud name, api key and api secret.
- Follow tutorial here: https://docs.render.com/deploy-django#use-renderyaml-for-deploys
- The
backend/render.yaml
already exists in the saas boilerplate. You can change all the names to fit whatever you like, but our boilerplate named everythingbackend
- In the Render Dashboard, go to the Blueprints page and click New Blueprint Instance.
- Make sure to first create a repository to hold your
backend/
folder on github.- Now you can select the repository that contains your blueprint and click Connect.
- Give your blueprint project a name and click Apply.
- Now add the Production Environmental Variables by clicking the
backend
app and going toEnvironment
- Add you Stripe
STRIPE_API_TEST_PK
found in your local .env file or if you are ready to use live Stripe data use the Production PK found in stripe dashboard. - Same with the
STRIPE_API_TEST_SK
STRIPE_LIVE_MODE=False
BACKEND_URL
will be the url that your backend render app is pointing to: something similar to thisbackend-xxxxonrender.com
- For your media files first set up Cloudinary account by going to the cloudinary website through this link and create a free cloudinary account. After your account has been created go to the dashboard page and copy the cloud name, api key and api secret.
- Add the cloud name to
CLOUDINARY_CLOUD_NAME
- Add the api key to
CLOUDINARY_API_KEY
- Add the api secret to
CLOUDINARY_API_SECRET
- Add the cloud name to
- For your emails create a postmark account here https://postmarkapp.com/. Follow instructions here: https://postmarkapp.com/support/article/1008-what-are-the-account-and-server-api-tokens to find your Server API Token and set it to
POSTMARK_SERVER_TOKEN
- Set
DEFAULT_FROM_EMAIL
to your email with postmark.
- Set
- After you deploy the frontend app below come back to setting
FRONTEND_URL
- Add you Stripe
- Finally run
python manage.py createsuperuser
in the Render shell in the settings of the backend app so that you can create an admin account.- To see your backend admin page, go to
<YOUR_APP_URL>/admin
to login.
- To see your backend admin page, go to
- The