fx-fotos icon indicating copy to clipboard operation
fx-fotos copied to clipboard

AWS backend implementation

Open keyvan-m-sadeghi opened this issue 2 years ago • 1 comments

Had a cool chat with @Roman-Uholnikov about an AWS backend implementation.

Below is my general suggestion on the structure for adding multiple backends, @ehsan6sha please chime in and advice if any of it doesn't make sense:

  1. Having a top level folder, photos/backend
  2. A seperate folder for each backend stack: photos/backend/icp, photos/backend/aws for the time being
  3. A top level TypeScript interface with function signatures for all needed backend funnctionalities, all stacks implement this interface. Goes in: photos/backend/apis.ts
  4. UI in settings page so that the user can choose between available backend stacks, I believe @emadbaqeri is working on an initial settings UI as part of #33
  5. Each implementation exports an object implementing the interface as its default root export, so when the backend is changed in settings we can do something like:
async function getBackend(selectedBackendKey: string) {
    const { default: { uploadPicture, downloadPicture, ... } } = await import(`../backend/${selectedBackendKey}`)
    return {
        // demo only, actual signatures in "Backend" interface at ../backend/apis.ts
        uploadPicture,
        downloadPicture,
        ...
    };

And then the UI will use APIs that are imported in the above line from ./backend/apis.ts

What do you guys think?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

keyvan-m-sadeghi avatar Jul 19 '21 12:07 keyvan-m-sadeghi

To me it looks good. We can optimize line "const { default: { uploadPicture, downloadPicture, ... } } = await import(../backend/${selectedBackendKey})" though.

ehsan6sha avatar Jul 19 '21 14:07 ehsan6sha