A Rails 6 boilerplate to create your next Saas product. Preloaded with graphQL, devise, JWT, CanCanCan, RailsAdmin, Rubocop, Rspec, i18n and more.
A Rails 6 boilerplate to create your next Saas product. Preloaded with graphQL, devise, JWT, CanCanCan, RailsAdmin, Rubocop, Rspec, i18n and more.
This is a boilerplate to build your next SaaS product. It's a RubyOnRails 6 backend with authentication, GraphQL API, Roles & Ability management and a admin dashboard. It works nicely together with clients made with Angular, React, Vue.js, React.Native, Swift, Kotlin or any other client framework which implements the JSON Web Tokens philosophy.
2.6.x2.1.46.0.XThis boilerplate works like a charm with the following gems:
You can have a running backend in seconds on heroku: or clone this repo:
git clone https://github.com/zauberware/rails-devise-graphql my-saas-backend
cd my-saas-backend
Clone env_sample to .env for local development. We set it up with default rails 3000 and client 8000 ports:
cp env_sample .env
Install the bundle:
bundle install
Make sure the PostgreSQL is running on localhost. You may have to change your credentials under /config/database.yml:
rake db:create
rake db:migrate
rake db:seed
Run the development server:
rails s
Download a GraphQL client like GraphiQL or others to access and test your API. Point the GraphQL IDE to http://0.0.0.0:3000/graphql
Note: Make sure that the .env file is included in the root of your project and you have defined CLIENT_URL and DEVISE_SECRET_KEY. 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 and a Company model with basic setup. We see an Company as a company with it's users. We did not add multi-tenancy to this app. If you want to do it by yourself check out the apartment gem.
The app uses devise's logic for authentication. For graphQL API we use the JWT token, but to access the rails_admin backend we use standard devise views, but registration is excluded.
Change devise settings under config/initializers/devise.rb and config/initializers/graphql_auth.rb.
Admins of a company can invite new users. The process is handled with devise_invitable. We added a inviteUser and acceptInvite mutation to handle this process via graphql.
Like in the reset password process we redirect the users to the frontend domain and not to backend.
graphql-auth is a graphql/devise extension which uses JWT tokens for user authentication. It follows secure by default principle.
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 app/graphql/.
Our BaseResolver class provides everything you need to achieve filter, sorting and pagination. Have a look at the resolver resolvers/users/users.rb:
How to:
Include SearchObject module in your resolver:
class Users
__Author website:__ [https://www.zauberware.com](https://www.zauberware.com)
No open issues yet, or sync has not completed.