Skip to content

Code organization and architecture

FEOD (Fractal Entity Oriented Design)

Application layers

  • Global
  • Common
  • Modules
  • Pages
  • App

Global

Holds everything that needs to be accessible anywhere in the app without importing.

Common

  • Utility functions and components that are helpful across the app, but not a business logic.
  • No exporting through index files.

Folder structure:

  • ui (common components)
  • composables
  • util
  • types

Modules

  • Business logic.
  • Module might be large and contain other nested modules inside.
  • Module defines its interface explicitly by exporting entities usable from outside.
  • Inner modules are invisible from outside until the parent reexports their functionality.
  • Inner modules can import directly from the parent module sources.
  • Modules can import other Modules public entities (specified in the index file) and from Common

Folder struture:

  • modules (inner modules)
  • api
  • ui
  • composables
  • index.ts

Pages

  • Holds pages of the app, they use modules to build their content.
  • Pages can import Modules and Common.
  • Pages file/folder names should mimic the route path.

App

  • Holds the root component of the app, the entry point, configuration, routing, integration with external services.
  • App imports all other layers, but no one can import from App.
  • If we need to provide something outside the App layer, inversion of control should be used.