Features
🚀 Rails 6
As explained above, rails 6 is the future and is far different from rails 5.
🚀 Rails API only
It is common to use frontend js libraries like react, vuejs to replace rails view in modern web development
🚀 ActionCable
This project demonstrates usage of actioncable with a working chatting backend which is authenticable thorugh JWT with functionalities as below:
- A user can
- create/delete a room
- set his/her avatar
- Other users can join rooms
- Users inside a room can
- send messages with each other
- update a message
- delete a message
- launch a vote which others can attend
- pick up random users of a specific number inside the room
The related fronend demo is written in react-pangu, and the js library bridges frontend and backend is written in actioncable-jwt
🚀 Devise
Quoted from it's homepage:
Devise is a flexible authentication solution for Rails based on Warden. It:
- Is Rack based;
- Is a complete MVC solution based on Rails engines;
- Allows you to have multiple models signed in at the same time;
- Is based on a modularity concept: use only what you really need.
To our best of knowledge, devise provides a full, industry-standard, easy-to-ingrate way of all kinds of authentication. Damn, it's awesome!
🚀 JWT
JSON Web Tokens
🚀 devise-jwt
While there are lots of solutions which hook devise and jwt together, this repo is better implemented from our point of view.
We implmented a devise-jwt denylist policy leveraging the power of redis in app/models/jwt_denylist.rb.
🚀 Postgres
We use postgres as default database store cause sqlite3 will be replaced sooner or later when the traffic of one web server becomes lager enough
🚀 Rspec
Behaviour Driven Development for Ruby. Making TDD Productive and Fun.
🚀 RuboCop
A Ruby static code analyzer and formatter, based on the community Ruby style guide. https://docs.rubocop.org
🚀 CircleCI
CircleCI is the leading continuous integration and delivery platform for teams looking to shorten the distance between idea and delivery In this project, we leverage CircleCI to test Rails-pangu's code base with both rspec and RuboCop
🚀 Factory Bot
A library for setting up Ruby objects as test data.
🚀 Docker
Docker is a standard containerize solution which is almost used in every team worldwide. As a result, a Dockerfile and related scripts are provided to help generate a docker image for this project.
The provided docker building solution contains the following optimizations:
Docker building acceleration
When a project grows, hundreds or even thousands of different versions of different gems will be tried or used. Even a small change in
Gemfilecauses re-bundling for everyGemwhile building aRubybased docker image, that most of the docker image building time is wasted for bundling a large number of stable gems, such asrails,pg... To solve this issue, we utilized a trick which accelerates the docker building process by bundling two rounds forGemfilefiles, and generates two layers of docker image:- Build the first layer for
Gemfile.core, which is for stable or coreGems, such asrails,pg. - Build the second layer for
Gemfile, which is for mutable or non-coreGems, for example,Gems wrote or forted by yourself.
Though, this process generates extra one layer of docker image which makes the image lager a little bit(hundreds of
KBs). It worths that way cause time is much more limited than disk spaceThe following lines of
Dockerfiledemonstrates this docker building process:- Build the first layer for
COPY Gemfile.core .
RUN echo 'gem: --no-document' >> ~/.gemrc && \
cp ~/.gemrc /etc/gemrc && \
chmod +r /etc/gemrc && \
bundle install --gemfile Gemfile.core -j16 --binstubs=$BUNDLE_PATH/bin
COPY Gemfile .
COPY Gemfile.lock .
RUN bundle install --gemfile Gemfile -j16 --binstubs=$BUNDLE_PATH/bin
Bundling
Gems acceleration (For developers in China only)By default, we mirror gem source
https://rubygems.orgtohttps://gems.ruby-china.com, which boosts the bundling speed largely for developers in China.
🚀 Puma
Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications in development and production.
🚀 Redis
Is there any web project isn't using redis as a faster and sometimes easier way of storing data? Well, if there isn't, just replace it!