Nitro is built with CoBRA. CoBRA stands for "Component Based Rails Architecture". Instead one gigantic Rails application, Nitro componentizes its overall architecture. CoBRA is a code organization and management technique that breaks large applications into small, distinct parts. This allows for better separation of concerns, dependency management, and ultimately, scalability.
Every Nitro component can be viewed as an application within itself. Nitro components fall into 4 classifications.
- Ruby Gems
- Rails Engines
- Front End
- Hybrid
You are very familiar with Ruby gems already. A gem is any Ruby library or application. All gems contain a gemspec file that defines its purpose and dependencies. Most gems can be packaged and installed from https://rubygems.org, but a gem does not need to be published. It is simply is a standalone Ruby program.
In Nitro, Ruby gem components do not have databases. And while not a defining feature, most Ruby gem components contain the majority of their logic in their lib directories.
Examples of Ruby gem components inside Nitro are:
aurora_clientgmapsnaughtynew_relic_eventnitro_authnitro_confignitro_metricsnitro_object_storenitro_redisruby_test_helperssfi_central_client
Rails Engines are miniature Rails applications. They provide all the functionality of a Rails app, with slightly different configurations. Rails Engines also contain gemspecs, which make them Ruby gems as well. One popular Rails Engine is Devise.
Nitro Rails Engine components typically do not utilize all Rails features. As you gain familiarity with Nitro's structure, you'll find Rails Engine components that use:
- all MVC classes
- just Models
- just Controllers
- just Views, Controllers, and other supporting user interface objects
- just Models & Controllers
Examples of Rails Engine components inside Nitro are:
adpcall_queuescharitable_givingequipment_assetsmobile_devicesmarketingpromosscrumsolar_roofingtrainingux_prototypes
Front End components are user interface focused components that typically use the React Javascript framework. You can conceptually think of a Front End component as its own React application.
Examples of React components inside Nitro are:
call_queue_uicontact_center_dashboardcredit_application_uihome_uiops_dashboardpeople_uipromos_uiscrum_uispaces_uisupport_tickets
A hybrid component is both a Rails engine and a front end component.
Here are some examples:
compliancecontact_centercorporate_eventsfinancehuman_resourceslearning_dojonitro_survey
Regardless of type, there are some standard conventions for every component in Nitro.
- They all live in the
components/directory. - They all contain a
README.mdwith a description of the component's purpose. - They all contain a
bin/directory with executables for setups, builds, and tests.
Before Nitro used componentization, it was one gigantic Rails application. As we transitioned into using CoBRA, we started breaking out the most obvious divisions of functionality. Today, anytime a new feature gets added to Nitro, it starts as a new component.
However, there is still a lot of older and essential Nitro functionality that has yet to be componentized. This legacy code lives in our two largest components.
core_models- Nitro's legacy Modelsnitro_component_transition- Nitro's legacy Controllers & Views
Adding new code into these components should be avoided. Any chance one has to break out some legacy functionality into another component, it should be discussed as a team and pursued if possible. This is not always an easy undertaking, so remember to utilize the support of more senior Nitro developers.