You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* use rails_admin as a simple admin backend
* remove api only for project because we want to access it by rails_admin
* add annotate gem
* Add basic assets to handle login/password reset and rails_admin
* use devise default views to get into rails_admin area
# Rails 6 boilerplate with devise, JWT, graphQL, CanCanCan and RailsAdmin.
2
2
3
-
This is a boilerplate to build your next SaaS product. It's a RubyOnRails 6 API only backend with Authentication and GraphQL API. It works nicely together with clients made with **React.js & React.Native** or any other frontend which implements the [JSON Web Tokens](https://jwt.io/introduction/) philosophy. We have a demo frontend made with [gatsbyJS](https://www.gatsbyjs.org/) available here: <https://gatsby-redux.zauberware.com/>.
3
+
This is a boilerplate to build your next SaaS product. It's a RubyOnRails 6 backend with Authentication and GraphQL API. It works nicely together with clients made with **React.js & React.Native** or any other frontend which implements the [JSON Web Tokens](https://jwt.io/introduction/) philosophy.
4
4
5
5
## Versions
6
6
@@ -9,6 +9,22 @@ This is a boilerplate to build your next SaaS product. It's a RubyOnRails 6 API
9
9
- Rails version `6.0.X`
10
10
- Postgresql Server as db connector
11
11
12
+
## Dependencies
13
+
This boilerplate works like a charm with the following gems:
@@ -60,7 +76,7 @@ Point the GraphQL IDE to `http://0.0.0.0:3000/graphql`
60
76
The app uses a postgresql database. It implements the connector with the gem `pg`. The app already includes a `User` model with basic setup.
61
77
62
78
### 2. Authentication
63
-
The app uses [devise](https://github.com/plataformatec/devise)'s logic for authentication. Emails are currently disabled in the environment settings.
79
+
The app uses [devise](https://github.com/plataformatec/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.
64
80
65
81
### 3. JSON Web Token
66
82
[graphql-auth](https://github.com/o2web/graphql-auth) is a graphql/devise extension which uses JWT tokens for user authentication. It follows [secure by default](https://en.wikipedia.org/wiki/Secure_by_default) principle.
@@ -74,18 +90,47 @@ Protect your app and only allow specific domains to access your API. Set `CLIENT
74
90
### 6. App server
75
91
The app uses [Puma](https://github.com/puma/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.
76
92
77
-
### 7. Testing
93
+
### 7. UUID
94
+
The app uses UUID as ids for active record entries in the database. If you want to know more about using uuid instead of integers read this [article by pawelurbanek.com](https://pawelurbanek.com/uuid-order-rails).
95
+
96
+
### 8. Automatic model annotation
97
+
Annotates Rails/ActiveRecord Models, routes, fixtures, and others based on the database schema. See [annotate_models gem](https://github.com/ctran/annotate_models).
98
+
99
+
### 9. Abilities with CanCanCan
100
+
[CanCanCan](https://github.com/CanCanCommunity/cancancan) is an authorization library for Ruby and Ruby on Rails which restricts what resources a given user is allowed to access. We combine this gem with a `role` field defined on user model.
101
+
102
+
### 10. Rails Admin
103
+
To access the data of your application you can access the [rails_admin](https://github.com/sferik/rails_admin) dashboard under route `/admin`. It's currently only allowed for users with role superadmin.
104
+
105
+
If you want to give your admin interface a custom branding you can override sass variables or write your own css under `app/assets/stylesheets/rails_admin/custom`.
106
+
107
+
### 11. Testing
78
108
79
109
We are using the wonderful framework [rspec](https://github.com/rspec/rspec). The testsuit also uses [factory_bot_rails](https://github.com/thoughtbot/factory_bot_rails) for fixtures.
80
110
81
111
Run `rspec spec`
82
112
83
-
### 8. Linter with Rubocop
113
+
#### FactoryBot
114
+
To create mock data in your tests we are using [factory_bot](https://github.com/thoughtbot/factory_bot). The gem is fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), includéng factory inheritance.
115
+
116
+
#### Faker
117
+
Create fake data easily with [faker gem](https://github.com/faker-ruby/faker). Caution: The created data is not uniq by default.
118
+
119
+
#### Shoulda Matchers
120
+
[Shoulda Matchers](https://github.com/thoughtbot/shoulda-matchers) provides RSpec- and Minitest-compatible one-liners to test common Rails functionality that, if written by hand, would be much longer, more complex, and error-prone.
121
+
122
+
#### Simplecov
123
+
[SimpleCov](https://github.com/simplecov-ruby/simplecov) is a code coverage analysis tool for Ruby. It uses Ruby's built-in Coverage library to gather code coverage data, but makes processing its results much easier by providing a clean API to filter, group, merge, format, and display those results, giving you a complete code coverage suite that can be set up with just a couple lines of code.
124
+
125
+
Access results with `$ open /coverage/index.html`.
126
+
127
+
128
+
### 12. Linter with Rubocop
84
129
85
130
We are using the wonderful [rubocop](https://github.com/rubocop-hq/rubocop-rails) to lint and autofix the code. Install the rubocop VSCode extension to get best experience during development.
86
131
87
132
88
-
### 9. Deployment
133
+
### 13. Deployment
89
134
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.
90
135
91
136
#### Heroku
@@ -102,17 +147,9 @@ If you want to use [bitbucket pipelines](https://bitbucket.org/product/de/featur
102
147
103
148
Make sure to set ENV vars `$HEROKU_API_KEY` and `$HEROKU_APP_NAME` in bitbuckets pipeline settings. (Will appear after enabling pipelines for your project.)
104
149
105
-
The pipeline has 2 environments: staging and production. Staging pipline is getting triggered in `develop` branch. Production uses all `release-*` branches.
106
-
107
-
108
-
### 9. Frontend
109
-
110
-
#### GatsbyJS
111
-
112
-
If you need a frontend than have a look at this basic [Gatsby boilerplate](https://github.com/zauberware/gatsby-starter-redux-saas). A Gatsby Redux SaaS starter for your next SaaS product. Uses react-redux, apollo-client, magicsoup.io, styled-components, styled-system.
The pipeline has 2 environments: staging and production. Staging pipline is getting triggered in `develop` branch. Production deploy triggered by `master` branch.
0 commit comments