Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We��ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaner data storage architecture #246

Open
10 tasks
dsonck92 opened this issue Jul 28, 2024 · 0 comments
Open
10 tasks

Cleaner data storage architecture #246

dsonck92 opened this issue Jul 28, 2024 · 0 comments
Assignees
Labels
refactoring Code refactoring

Comments

@dsonck92
Copy link
Collaborator

Currently, the service layer of the API has a lot of contamination within its business logic. The proposal is to change the software layers to the following:

  • Routers, talk to the service layer and are responsible for changing the "business logic" models into "API" models
  • Services, contain core business logic like:
    • Validating the action can reasonably be performed
    • Validating the action is allowed to be performed
    • Starting all actions in the way they are supposed to
  • Data abstraction layer, interfaces defining the core concepts of data storage for the business logic
  • Caching, contains the Redis caching code, conforming to the business layer data storage abstraction
  • Repo, contains the DB persistence code, also conforming to the business layer data storage abstraction

This layered system has the following interface layers

  • Service interfaces
    The router layer demands implementations of the service layer
  • Data storage interfaces
    The service layer, and caching layer, demand implementations of the data storage layer

By splitting it in these layers, it becomes possible to:

  • Test the router JSON validity and request parsing in isolation
  • Test the service behavior with easy to inject data types and analyze its behavior on the data storage in isolation
  • Test the caching behavior in isolation
  • Test the repo query logic in isolation
  • Swap out the caching layer for direct repo access
  • Swap out the repo implementation with another
@dsonck92 dsonck92 added the refactoring Code refactoring label Jul 28, 2024
@dsonck92 dsonck92 self-assigned this Jul 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Code refactoring
1 participant