This repository serves as a default template for a Ruby on Rails (RoR) application using the --api flag with the Graphql gem. It includes a pre-configured setup with essential gems and tools to streamline API development.
Clone the repository
git clone https://github.com/Grigore-George-Mihai/graphql_template
1. Rename the Application
This will update the app name everywhere it appears (module name, titles, DB names, cable prefixes, Docker volumes, etc.).
bin/rails setup:rename_app
2. Create Environment Files
Copy environment template files into .env.development
and .env.test
.
bin/rails setup:copy_env
Then open each file and update values as needed:
- Database credentials (
POSTGRES_USER
,POSTGRES_PASSWORD
) - Any other environment-specific variables
3. Set Up the Database
bin/rails db:prepare # Creates and migrates the database
bin/rails db:seed # Loads seed data
4. Optional Integrations
- Scout APM — Add your SCOUT_KEY value in .env.development (or the appropriate .env file) to enable. If left blank, ScoutAPM stays disabled.
- Rollbar — Add your ROLLBAR_ACCESS_TOKEN value in .env.development (or the appropriate .env file) to enable. If left blank, Rollbar stays disabled.
✅ You’re now ready to start development!
Database
- Pg: PostgreSQL driver for Ruby, providing fast and efficient database connectivity.
GraphQL
- GraphQL: GraphQL implementation for Ruby, providing query execution and schema building tools.
- GraphiQL: GraphiQL is a graphical interactive in-browser GraphQL IDE.
Authentication
- JWT: Ruby library for creating and verifying JSON Web Tokens.
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.
Performance Monitoring
Error Tracking
- Rollbar: Real-time error tracking and reporting.
Code Quality & Linting
- Rubocop Rails Suite: A custom suite that bundles Rubocop with various plugins for Rails projects.
Testing
- Factory Bot Rails: Provides fixtures replacement with a straightforward definition syntax.
- Faker: A library for generating fake data.
- RSpec Rails: Testing framework for Rails.
- Shoulda Matchers: Simplifies testing Rails applications with RSpec.
- SimpleCov: Code coverage analysis tool.
- Rspec-Sidekiq: Testing framework for Sidekiq jobs.
Security
- Brakeman: Static analysis tool for finding security vulnerabilities in Rails applications.
- Bundler Audit: Scans your Gemfile for known vulnerabilities.
Environment Management
- Dotenv Rails: Loads environment variables from
.env
.
Run the following rake task to check for security risks in your application:
bin/rails security:check
- This task runs tools like Brakeman and Bundler Audit to ensure your application is secure.
If you prefer to run the application inside a Docker container, follow these steps:
- Build the Docker image:
docker-compose build
- Start the Application and services:
docker-compose up
- Stop the Application:
docker-compose down
- Remove named Volumes:
docker-compose down --volumes
For questions or further information, feel free to reach out via LinkedIn.