Skip to content

Refactor Backend Architecture #584

@aaronzi

Description

@aaronzi

Linked to #570 (Phase 1 PR)

Motivation

The current backend architecture relies heavily on the service layer to interact with the internals of the entities saved in the repositories. Much of the operations could be done more efficiently at the backend level, profiting from performance enhancements and modularity.

Other than that, concurrency and scalability could be easier achieved with comparably less impact on performance.

Roadmap

The scope of the changes is large. Therefore, the changes will be implemented in several phases:

Phase 1: Structural changes ✅

  1. Refactor Crud*Repository (service layer) to receive the *Backend as a Spring component
  2. Replace InMemory implementation with a spring-data provided (JPA + H2 e.g.)
  3. Replace the *Service dependency in the Service Level with the *Backend using repository fragments (*ServiceBackend) [1, 2]
  4. Implement the *ServiceBackend for InMemory and MongoDB [2]

Tests must be adapted according to the changes.

Phase 2: Filtering

Supersedes #516

  1. Add QueryDslExecutor [3] to *Backend
  2. Implement getAll* using the QueryDsl

Phase 3: Pagination

Look at [4] for example using PagingAndSortingRepository

  • Refine

Jannis Norte:
Found implementation for MongoDB; see [5]

References

[1] https://docs.spring.io/spring-data/mongodb/docs/3.3.5/reference/html/#repositories.custom-implementations
[2] https://github.com/spring-projects/spring-data-examples/tree/main/mongodb/aggregation/src/main/java/example/springdata/mongodb/aggregation
[3] https://docs.spring.io/spring-data/commons/docs/current/api/org/springframework/data/querydsl/QuerydslPredicateExecutor.html
[4] https://docs.spring.io/spring-data/mongodb/docs/3.3.5/reference/html/#repositories.definition
[5] https://docs.spring.io/spring-data/mongodb/docs/current/api/org/springframework/data/mongodb/repository/support/SimpleMongoRepository.html

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

Status

Sprint

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions