Skip to content

RFC: Reorganize code & docs along abstraction levels #5550

@bajtos

Description

@bajtos

In my view, loopback-next is currently a mixed bag of low-level building blocks like @loopback/metadata and high-level framework packages like @loopback/core and @loopback/rest. Our documentation is often describing concepts from different abstraction layers in the same place, which makes it IMO more difficult for newcomers to learn how to use the framework.

I am proposing to reorganize our monorepo structure and the documentation in such way, that the documentation for framework consumers describes primarily framework-level APIs and deemphasizes the lower-level building blocks.

For example, we should stop referring to @loopback/context in our documentation and tell users to import DI/IoC features directly from @loopback/core. This way new-to-intermediate users don't need to understand the complexity of how LoopBack is composed internally. Of course, we should provide enough information for expert users to allow them to understand our building blocks and how they are composed together, but that should be in the part of the documentation that's clearly aiming at very advanced developers.

I am proposing the following rule of thumb: if a higher-level package is re-exporting all public APIs from another package (e.g. @loopback/core re-exports @loopback/context) or is encapsulating another package as a building block (e.g. @loopback/rest uses @loopback/express), then the later package should be moved to "building blocks" and our documentation should be updated to reference the former "framework" package in most places.

Proposed taxonomy of monorepo packages (not a complete list):

Framework

  • @loopback/core
  • @loopback/rest and related extensions (rest-explorer, rest-crud)
  • @loopback/repository
  • @loopback/boot and booter extensions
  • @loopback/authentication, @loopback/authorization, @loopback/security

I am proposing to move these packages from packages/{name} to framework/{name}.

Building blocks

  • @loopback/context (and its dependencies)
  • @loopback/http-server, @loopback/express, etc.
  • @loopback/openapi-v3

I am proposing to move these packages from packages/{name} to foundation/{name}. (I am not entirely happy with the name foundation, feel free to propose a better one.)

The documentation for this packages should primarily aim at people using these packages outside of LoopBack context, see the concept of microsites I mentioned in #5113.

Utilities

  • @loopback/build
  • @loopback/testlab
  • @loopback/eslint-config
  • @loopback/http-caching-proxy
  • @loopback/model-api-builder

I see these packages as mostly standalone additions to the framework that are not mandatory to use. Documentation-wise, they can be documented independently from the "main" framework documentation, but the docs should show how to use these utilities in the context of a LoopBack project. As a nice-to-have feature, the docs can also show how to use these utilities in non-LoopBack projects too.

Let's move them from packages/{name} to util/{name}.

Extensions

All existing packages in extensions/* belong to this category, we may want to move some additional packages from packages/* into this category.

Documentation wise, I think these extensions should be integrated into the rest of the docs, most importantly into "How to guides" (see also #5549).

Next steps

  • Discuss the proposal and reach consensus on whether we want to pursue this direction or not. If yes:
  • Create a task to define the new taxonomy/organization and for each existing package in our monorepo, identify where it will belong to
  • Re-arrange directory structure in the monorepo
  • For each package that was moved to "building blocks" section, update all code snippets in docs, example projects and CLI templates to replace imports from the building block with imports from a framework-level package.
  • A spike to figure out the next steps for reworking the documentation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions