Using Ruby on Rails
Ruby on Rails, a robust Model-View-Controller (MVC) web framework, serves as the foundation for the FrogID project. With its convention over configuration approach, Rails provides a streamlined development experience, reducing setup time and minimising the need for explicit configurations.
In Rails, database querying is facilitated through Object-Relational Mapping (ORM). The ORM, powered by ActiveRecord, enables developers to interact with the underlying database, in this case Postgresql, using intuitive Ruby methods and conventions. This abstraction layer simplifies database operations by abstracting away the need to write raw SQL queries. By leveraging ORM, developers can focus on application logic rather than dealing with low-level database management tasks. Although Rails' popularity has waned somewhat in recent years, it still delivers resilient functionality and reliability for contemporary applications.
The use of Rails in the FrogID project provides several benefits. Firstly, it offers a seamless and efficient approach to managing data. Developers can define database models using Ruby classes and utilise Controller methods for querying, creating, updating, and deleting records. These API endpoints are consumed in various areas of the project, including the mobile apps, Gatsby static pages, the Admin frontend, and React frontend. Rails' clear separation of concerns and modular development principles enable the definition of these endpoints in a concise manner while still allowing for a DRY (Don't Repeat Yourself) approach for similar APIs that are utilised by different components. This simplicity and consistency streamline the development process, enhance productivity, and promote code reuse.
Rails seamlessly integrates with Sidekiq, a popular Ruby library for handling background jobs and task queueing, similar to Celery in Python. In the FrogID project, Sidekiq plays a crucial role in handling tasks such as emailing, data exports, data migrations, and more. By enabling asynchronous processing and efficient resource utilisation, Sidekiq significantly enhances the project's performance and responsiveness.
At the Interaction Consortium, Django is our preferred choice for backend application management. However, despite this preference, we have found that Ruby on Rails, with its MVC architecture, is a sound choice for managing the application's APIs and maintaining a single source of truth. The MVC architecture of Rails provides a clear separation of responsibilities, making it easier to manage and maintain the APIs while ensuring consistency and scalability.