Rails_api_base

screenshot of Rails_api_base

Rails_api_base

API boilerplate project for Ruby on Rails 7

Overview:

The Rails API Base is a boilerplate project for JSON RESTful APIs that follows community best practices in terms of standards, security, and maintainability. It is built on Rails 7.0 and Ruby 3.2. The template includes various features such as user authentication, administration panel, feature flag support, RSpec tests, code quality tools, API documentation, and Docker support. It also provides dev scripts to enhance the development experience.

Features:

  • Schema: The project includes a pre-defined schema with tables for users and admin users.
  • User Authentication: Users can sign up using their credentials, sign in, sign out, and reset their password. They can also access and update their user profile.
  • Administration Panel: The template includes an administration console powered by ActiveAdmin for easy management of users.
  • Feature Flag Support: The project includes a UI for managing feature flags, allowing developers to enable or disable certain features.
  • RSpec Tests: The template includes RSpec tests to ensure the quality and functionality of the API.
  • Code Quality Tools: The project integrates code quality tools such as Code Climate and Test Coverage to maintain code standards and ensure test coverage.
  • API Documentation: The API follows the OpenAPI standard and includes API documentation generated using the RSpec API Doc Generator.
  • Docker Support: The template provides support for running the project in a Docker container, making it easy to set up and deploy.

Installation:

To use the Rails API Base template, follow these steps:

  1. Clone this repository.
  2. Install PostgreSQL if you don't have it installed already.
  3. Install Node.js and Yarn.
  4. Run the bootstrap.sh script with the name of your project (e.g., ./bootstrap.sh --name=my_awesome_project).
  5. Run rspec to ensure that all tests pass.
  6. Run rails s to start the Rails server.
  7. Run yarn install followed by yarn build --watch to bundle the JS assets.
  8. You can now try your REST services by accessing the API.

If you want to use Docker for running the project, follow these additional steps:

  1. Ensure that Docker and Docker Compose are installed.
  2. Run the bootstrap.sh script with the -d or --for-docker flag (e.g., ./bootstrap.sh --name=my_awesome_project -d).
  3. Generate a secret key for the app by running bin/web rake secret, copy it, and add it to your environment variables.
  4. (Optional) If you want to deny access to the database from outside the Docker network, remove the ports key in the docker-compose.yml file for the db service.
  5. (Optional) Run the tests to ensure everything is working: bin/rspec ...
  6. You can now try your REST services using Docker.

Summary:

The Rails API Base template is a comprehensive boilerplate project for building JSON RESTful APIs. It provides a solid foundation for developing APIs following best practices, including security, testing, and code quality. With features like user authentication, administration panel, feature flag support, and Docker integration, developers can quickly start building robust and maintainable APIs.