TagStudio icon indicating copy to clipboard operation
TagStudio copied to clipboard

[Feature Request]: Implement the n-th tier architecture

Open michaeldcanady opened this issue 1 year ago • 0 comments

Checklist

  • [X] I am using an up-to-date version.
  • [X] I have read the documentation.
  • [X] I have searched existing issues.

Description

Looking over the source code I think it would be helpful to separate the project into more abstract "layers" to allow more flexibility and versatility.

Solution

just as a rough example, actual layers should be specific to the project and more can be added as needed:

  • database: these are services that wrap around the database and marshal the rows into basic objects.
Class TagService():

def __init__(self, db_path: str) -> None:
    # things needed to initialize connection to DB

def get(self, tag_id: str) -> Tag:
     # Gets a specific tag from the database

def list(self) -> List[Tag]:
    # Lists all tags in the DB

def update(self, tag_id: str, new: Tag) -> Tag:
    # Updates the provided tag and returns it

def create(self, new: Tag) -> Tag:
    # Creates the provided tag

def delete(self, tag_id: str) -> None:
    # deletes the tag withe provided id from the db
  • base: Provides general utilities and user interface building blocks that can be used in any other layer.
  • platform: Defines service injection support and the base services that are shared across layers
  • studio: Entrypoint for the GUI, this assembles the GUI and provides services specific to the GUI -a user layer designed to be interchangeable.
  • cli: Entrypoint for the CLI, this assembles the CLI and provides services specific to the CLI -a user layer designed to be interchangeable.

Alternatives

No response

michaeldcanady avatar Aug 21 '24 16:08 michaeldcanady