Tech Doc: How OFN is organized in Domains using Rails Engines

Luis Ramos edited this page Oct 29, 2018 · 8 revisions

In OFN we use Rails Engines to organize our application in separate Business domains. The discussion originated in the 2018 Global Gathering in Barcelona and continued here in discourse.

Business Domains

For now, we started by extracting the Cookies feature into the new Web domain (see the PR here). The vision in terms of domains is the following (although we will adapt and change as we go):

  • FrontOffice _ Web ___ Content CMS for the ecommerce website (including homepage, landing pages, map, menu and footer)
  • FrontOffice _ Shop ______ Product Search and Display features on the ecommerce website
  • FrontOffice _ Checkout _ Cart and Checkout flow features (includes User account and User registration)
  • BackOffice _ Catalog ___ Product/Inventory management (including Order Cycle management)
  • BackOffice _ Orders ____ Order Management System: Orders, packing and delivery management (including Invoicing and Accounting)
  • BackOffice _ Entities ___ Entity Management: Enterprises and Customers management (CRM)

FrontOffice _ Web

Content CMS for the ecommerce website (including homepage, landing pages, map, menu and footer)

_

Example API endpoints:

  • /home - homepage
  • /home/consumer - homepage for consumers
  • /home/producer - homepage for producers
  • /menu - app menu
  • /map - map

FrontOffice _ Shop

Product Search and Display features on the ecommerce website

_

Example API endpoints:

  • /shops - list of shops
  • /shops/enterprise/1 - shop for enterprise 1
  • /shops/enterprise/1/product/10 - product 10 details
  • /shops/enterprise/1/product?description=carrot - search for carrots in enterprise 1

FrontOffice _ Checkout

Cart and Checkout flow features (includes User account and User registration)

_

Example API endpoints:

  • /cart - add, display and change the cart
  • /checkout - collect details and submit purchases
  • /user - user account and associated endpoints
  • /user/registration - user registration process and data

BackOffice _ Catalog

Product/Inventory management (including Order Cycle management)

_

Example API endpoints:

  • /product - similar to /shop but with more management capabilities, for example, bulk update actions
  • /order_cycles/12 - manage Order Cycles details

BackOffice _ Orders

Order Management System: Orders, packing and delivery management (including Invoicing and Accounting)

_

Example API endpoints:

  • /orders - list orders and bulk actions
  • /orders/1 - view and change order details

BackOffice _ Entities

Entity Management: Enterprises and Customers management (CRM)

_

Example API endpoints:

  • /users
  • /enterprises
  • /customers
  • /groups

Dependencies between Domains

This is a simple diagram showing very simple examples of dependencies between the domains.

_

Technical structure

Each domain structure will mimic the existing structure on the main app. Each domain has it's own controllers, services, models, views, assets and serialisers.

_

Rails Engines

Rails Engines can be considered miniature applications, for more info see the Rails Guides entry for Rails Engines.

The OFN main application is under /app and each engine's code is under /engines/<engine_name>/app. The migration to engines will consist basically of moving files from /app/<relative_file_path> to /engines/<engine_name>/app/<relative_file_path>.

Each engine and the main app will have different ways of accessing/depending on (other) domains code:

  • requiring another domain's modules and classes directly, for example, the main app FooterLinksHelper requires the Web domain CookiesConsent service simply by using require 'web/cookies_consent'
  • the best way to depend on another engine is through its routes (ideally the API routes) - like in Spree, each domain's routes are mounted on the base url with mount Web::Engine, :at => '/'
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.