Skip to content

Grigore-George-Mihai/hybrid_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hybrid Template

This repository serves as a hybrid template for a Ruby on Rails (RoR) application with grape. It includes a pre-configured setup with essential gems and tools to streamline development.

Table of Contents

Installation

  1. Clone:
git clone https://github.com/Grigore-George-Mihai/hybrid_template

Customize

  • Update the project name to reflect your application.
  • A basic implementation of Devise for web logins and Devise-JWT for API authentication is included. You can modify the configuration as needed to suit your specific authentication requirements.
  • Modify or remove the settings for Scout APM, Rollbar, and PgHero as needed, based on your performance, error tracking, and database monitoring requirements.
  • Run the following rake task to create your environment files:
    rake env:setup
    • After running the task, open the newly created .env.development and .env.test files to modify them with the appropriate environment-specific variables as needed.
  • Create DB and seed:
    rails db:create db:migrate db:seed

Gems

Database and Monitoring

  • Pg: PostgreSQL driver for Ruby, providing fast and efficient database connectivity.
  • PgHero: A tool for monitoring PostgreSQL database performance, including query insights, index suggestions, and table size analysis.

Grape

  • Grape: A REST-like API framework for Ruby that is designed to run on Rack or complement existing web application frameworks like Rails.
  • Grape Entity: A framework-agnostic entity layer to decorate and serialize data objects for API responses.
  • Grape Swagger: Adds Swagger-compliant documentation to your Grape API.
  • Grape Swagger Entity: Extends grape-entity to generate Swagger documentation automatically.
  • Grape Swagger Rails: Integrates grape-swagger into Rails applications for serving Swagger UI.

Authentication

  • Devise: Flexible authentication solution for Rails based on Warden.
  • Devise-JWT: Adds stateless token-based authentication to Devise using JSON Web Tokens (JWT) for secure API authentication.

Admin Interface

  • ActiveAdmin: A flexible and extensible admin framework for Ruby on Rails applications, making it easy to build custom admin panels.
  • ActiveAdmin Addons: Enhances ActiveAdmin with additional features like input widgets, searchable selects, and improved UI components for better admin interfaces.

Pagination

  • Pagy: A fast, efficient, and lightweight pagination gem for Rails, providing easy customization and flexibility with minimal overhead.

Background Processing

  • Sidekiq: Efficient background processing for Ruby applications.
  • Sidekiq-Scheduler: Extends Sidekiq to support scheduled and recurring jobs using a simple configuration.
  • Redis: In-memory data structure store used by Sidekiq for managing background job queues, scheduling, and retries.

Decorator and Forms

  • Draper: Helps in decorating models with additional presentation logic.
  • Simple Form: Simplifies form creation with a clean and flexible syntax.

Performance Monitoring

Error Tracking

  • Rollbar: Real-time error tracking and reporting.

Debugging

  • Byebug: Debugging tool for Ruby applications.

Code Quality & Linting

  • Rubocop Rails Suite: A custom suite that bundles Rubocop with various plugins for Rails projects.

Testing

Security

  • Brakeman: Static analysis tool for finding security vulnerabilities in Rails applications.
  • Bundler Audit: Scans your Gemfile for known vulnerabilities.

Environment Management

Rake Tasks

Security Check

  • Run the following rake task to check for security risks in your application:

    rake security:check
    • This task runs tools like Brakeman and Bundler Audit to ensure your application is secure.

Grape Resource Generator

This repository includes a custom Rails generator for creating Grape resources, entities, and corresponding RSpec tests. The generator helps streamline the process of adding new API endpoints to your application.

Usage

Generate a new Grape API resource:

rails generate grape_resource <ResourceName> field:type field:type

Replace with the name of your resource (e.g., Book) and field:type with the attributes and types (e.g., title:string description:text).

Features

  • API Versioning: Supports --version option (default: v1).
  • Auto Mounting: Automatically mounts new resources in the API.
  • Swagger Integration: Adds entities to Swagger models.
  • Optional Model Generation: Prompts to generate the corresponding model.

Example

rails generate grape_resource Book title:string description:text
This will create
  • A Grape resource in app/api/v1/resources/books.rb
  • A Grape entity in app/api/v1/entities/book_entity.rb
  • A corresponding RSpec test in spec/api/v1/resources/books_spec.rb
  • The resource will be automatically mounted in the API
  • The entity will be added to Swagger documentation
  • The generator also gives you the option to create the User model with the specified attributes.

Docker Setup

  • If you prefer to run the application inside a Docker container, follow these steps:
  1. Build the Docker image:

    docker-compose build
  2. Start the Application and services:

    docker-compose up
  3. Stop the Application:

    docker-compose down
  4. Remove named Volumes:

    docker-compose down --volumes

Contact

For questions or further information, feel free to reach out via LinkedIn.

About

Hybrid Ruby on Rails (RoR 7.2.2) application with grape

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published