This page contains information related to upcoming products, features, and functionality. It is important to note that the information presented is for informational purposes only. Please do not rely on this information for purchasing or planning purposes. The development, release, and timing of any products, features, or functionality may be subject to change or delay and remain at the sole discretion of GitLab Inc.
Status Authors Coach DRIs Owning Stage Created
proposed @grzesiek @fabiopitino 2023-05-22

GitLab Modular Monolith


The main GitLab Rails project has been implemented as a large monolithic application, using Ruby on Rails framework. It has over 2.2 million lines of Ruby code and hundreds of engineers contributing to it every day.

The application has been growing in complexity for more than a decade. The monolithic architecture has served us well during this time, making it possible to keep high development velocity and great engineering productivity.

Even though we strive for having an approachable open-core architecture we need to strengthen the boundaries between domains to retain velocity and increase development predictability.

As we grow as an engineering organization, we want to explore a slightly different, but related, architectural paradigm: a modular monolith design, while still using a monolithic architecture with satellite services.

This should allow us to increase engineering efficiency, reduce the cognitive load, and eventually decouple internal components to the extend that will allow us to deploy and run them separately if needed.


Working with a large and tightly coupled monolithic application is challenging:


  • Onboarding engineers takes time. It takes a while before engineers feel productive due to the size of the context and the amount of coupling.
  • We need to use CODEOWNERS file feature for several domains but these rules are complex.
  • It is difficult for engineers to build a mental map of the application due to its size. Even apparently isolated changes can have far-reaching repercussions on other parts of the monolith.
  • Attrition/retention of engineering talent. It is fatiguing and demoralizing for engineers to constantly deal with the obstacles to productivity.


  • There is little structure inside the monolith. We have attempted to enforce the creation of some modules but have no company-wide strategy on what the functional parts of the monolith should be, and how code should be organized.
  • There is no isolation between existing modules. Ruby does not provide out-of-the-box tools to effectively enforce boundaries. Everything lives under the same memory space.
  • We rarely build abstractions that can boost our efficiency.
  • Moving stable parts of the application into separate services is impossible due to high coupling.
  • We are unable to deploy changes to specific domains separately and isolate failures that are happening inside them.


  • High median-time-to-production for complex changes.
  • It can be overwhelming for the wider-community members to contribute.
  • Reducing testing times requires diligent and persistent efforts.


  • Increase the development velocity and predicability through separation of concerns.
  • Improve code quality by reducing coupling and introducing useful abstractions.
  • Build abstractions required to deploy and run GitLab components separately.

How do we get there?

While we do recognize that modularization is a significant technical endeavor, we believe that the main challenge is organizational, rather than technical. We not only need to design separation in a way that modules are decoupled in a pragmatic way which works well on but also on self-managed instances, but we need to align modularization with the way in which we want to work at GitLab.

There are many aspects and details required to make modularization of our monolith successful. We will work on the aspects listed below, refine them, and add more important details as we move forward towards the goal:

  1. Deliver modularization proof-of-concepts that will deliver key insights.
  2. Align modularization plans to the product structure by defining bounded contexts.
  3. Separate domains into modules that will reflect product structure.
  4. Start a training program for team members on how to work with decoupled domains (TODO)
  5. Build tools that will make it easier to build decoupled domains through inversion of control (TODO)
  6. Introduce hexagonal architecture within the monolith
  7. Introduce clean architecture with one-way-dependencies and host application (TODO)
  8. Build abstractions that will make it possible to run and deploy domains separately (TODO)


In progress.

  • A working group Bounded Contexts was concluded in April 2024 which defined a list of bounded contexts to be enforced for GitLab Rails domain and infrastructure layer.


  1. ADR-001: Modularize application domain? Start with modularizing the application domain and infrastructure code.
  2. ADR-002: Define bounded context around feature categories as a SSoT in the code.
  3. ADR-003: Assign stewards to all modules and libraries.


  • modules are Ruby modules and can be used to nest code hierarchically.
  • namespaces are unique hierarchies of Ruby constants. For example, Ci:: but also Ci::JobArtifacts:: or Ci::Pipeline::Chain::.
  • packages are Packwerk packages to group together related functionalities. These packages can be big or small depending on the design and architecture. Inside a package all constants (classes and modules) have the same namespace. For example:
    • In a package ci, all the classes would be nested under Ci:: namespace. There can be also nested namespaces like Ci::PipelineProcessing::.
    • In a package ci-pipeline_creation all classes are nested under Ci::PipelineCreation, like Ci::PipelineCreation::Chain::Command.
    • In a package ci a class named MergeRequests::UpdateHeadPipelineService would not be allowed because it would not match the package’s namespace.
    • This can be enforced easily with Packwerk’s based RuboCop Cops.
  • bounded context is a top-level Packwerk package that represents a macro aspect of the domain. For example: Ci::, MergeRequests::, Packages::, etc.
    • A bounded context is represented by a single Ruby module/namespace. For example, Ci:: and not Ci::JobArtifacts::.
    • A bounded context can be made of 1 or multiple Packwerk packages. Nested packages would be recommended if the domain is quite complex and we want to enforce privacy among all the implementation details. For example: Ci::PipelineProcessing:: and Ci::PipelineCreation:: could be separate packages of the same bounded context and expose their public API while keeping implementation details private.
    • A new bounded context like RemoteDevelopment:: can be represented a single package while large and complex bounded contexts like Ci:: would need to be organized into smaller/nested packages.


List of references