README

This README would normally document whatever steps are necessary to get the application up and running.

Things you may want to cover:

  • Project url: shonko-backend-app
  • Ruby version
    • 2.7.4
  • Development configuration:
    • # The following instructions assumes that essential tools are configured, e.g. command line tool,git and homebrew
      $ rbenv install 2.7.4 # Or rvm, or whatever way to install the specified ruby version.
      $ # Generate development credentials.
      $ # Since it's a standalone application for now, there are no 3rd party credentials required. Simply generate your own development credentials:
      $ rails credentials:edit --environment development
      # Install dependencies
      $ bundle install
      # Setup development database
      $ rails db:setup # equvalent to rails db:migrate since no seed datum are configured
      # Now the rocket is ready to lift off!
      $ rails s # or bundle exec puma
  • Dependencies
    • Routes
      • friendly_id + babosa
        • For semantic url resource parameters(with ASCII support).
    • Act as extensions
      • gem 'acts_as_list'
        • For sorting data with simple API
        • I actually prefer some other approaches, for example, using float column to store position.
          • (previous.position + next.position) / 2 is a super simple and performant solution for sorting. However, considering the character of this project, I tend to adapt off-the-shelf solution.
    • API
      • jsonapi-serializer
        • Small and lightening fast serializer
    • Development
      • bullet
        • Detect N+1 query issue
    • Test
      • factory_bot
        • Adapt factory pattern for building testing(or development) records in ease.
      • database_cleaner-active_record
        • Truncate database for each tests, make sure each tests are independent.
      • shoulda-matchers
        • Simple one-liner test syntax.
      • faker
        • Random data generation.
  • Configuration
    • master.key
  • Database creation
    • rails db:create
  • Test Methodology
    • Test pyramids: Test pyramid
      • Request test as intergration test
        • Covers routes as well.
      • GraphQL integration test:
        • Covers all directly related fields
        • Do not cover nested objects
        • For scheamas that are not fields in root query type, cover the test with accessible objects in the root query type as ingress.
          • e.g. course as the ingress for sections and lessons
        • 截圖 2022-04-05 下午7 30 01
      • Unit test
    • Principles:
      • Fast
        • Mock behaviors from dependencies. e.g.
          • Mock ORM classes instead of performing real query:
            allow(ActiveRecord::Base).to receive(:find).and_return(double))
            
      • Complete
      • Reliable
      • Isolated
      • Maintainable
      • Expressive
        • DAMP against DRY: Descriptive and Meaningful phrases
  • Code of conduct:
    • SOLID
    • Comments:
      • Only applies for FIXME and OPTIMIZE, and they should be attached with follow-up task to resolve them.
  • TODO