This is a boilerplate to build your next SaaS product. It's a RubyOnRails 5 API only backend with Authentication and GrpahQL API. It works nicely together with clients made with React.js & React.Native or any other frontend which implements the JSON Web Tokens philosophy. We have a demo frontend made with gatsbyJS available here: https://gatsby-redux.zauberware.com/.
clone the repo:
git clone https://github.com/zauberware/rails-devise-graphql my-saas-backend cd my-saas-backend
env_sample to .env for local development. We set it up with default rails
3000 and gatsby
cp env_sample .env
Install the bundle:
Make sure the postresql is running on localhost. You may have to change your credentials under
rake db:create rake db:migrate rake db:seed
Run the development server:
While this is an API-only application you will not be able to access any routes via browser. Download a GraphQL client like GraphiQL or others.
Point the GraphQL IDE to
Note: Make sure that the
.env file is included in the root of your project and you have defined
DEVISE_JWT_SECRET_KEY. You can try out the Demo frontend or you implement the actions in any other client. Read more about the JSON Web Token this. There are plenty of packages available.
The app uses a postgresql database. It implements the connector with the gem
pg. The app already includes a
User model with basic setup.
The app uses devise's logic for authentication. Emails are currently disabled in the environment settings.
graphql-ruby is a Ruby implementation of GraphQL. Sadly it's not 100% open source, but with the free version allows you amazing things to do. See the Getting Started Guide and the current implementations in this project under
Protect your app and only allow specific domains to access your API. Set
.env to your prefered client. If you need advanced options please change the CORS settings here
The app uses Puma as the web serber. It is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications in development and production.
The project runs on every webhoster with ruby installed. The only dependency is a PostgreSQL database. Create a block
production: in the
config/database.yml for your connection.
Choose the one click installer or push a clone of this repo to heroku by yourself. We added a
Profile to the project and heroku run the
release: statement after deploying a new version. Heroku will automatically set the db settings for your project, so there is nothing to do in
Make sure all ENV vars are set and the database settings are valid.
If you need a frontend than have a look at this basic Gatsby boilerplate. A Gatsby Redux SaaS starter for your next SaaS product. Uses react-redux, apollo-client, magicsoup.io, styled-components, styled-system.
Author website: https://www.zauberware.com