yukiisbored / patchouli-x

Search your darlings ✨
ISC License
1 stars 0 forks source link

The Big Rearchitecture #21

Closed yukiisbored closed 3 months ago

yukiisbored commented 3 months ago

I've been working on Patchouli X for a while now and I think it is time to start refactoring about the architecture.

This issue essentially serves as a working document on the direction that I hope Patchouli X will achieve. In addition, it might help others who are doing something similar.

It is important to note that Patchouli X is a project developed by a single person.

In the beginning...

I've deliberated for quite a while about the general tech stack that Patchouli X will use. After many considerations, I landed on using Web technologies because of the following:

With all of that in mind, I started building Patchouli X with React, tRPC, and Electron. The reason for Electron is simply because it is the established "go-to" and I thought that I would have no problems with it.

Current state of affairs

Patchouli X has a "working version". It is not feature complete and it is definitely not up to the "level" in terms of user experience that I like.

I have been experiencing roadblocks from using Electron.

The future at 10'000 ft

I want to achieve the following high level architecture for Patchouli X.

flowchart TB
  subgraph Backend
    Scraper --- Router
    Database --- Router
    Scraper -.- Database
  end
  subgraph Desktop
    Router -- tRPC over stdout/stdin --- Main
    Main --- Window1["Window"]
    Main --- Window2["Window"]
  end
  subgraph WebExtension
    Router -- tRPC over ??? --- Extension
  end

This is not by any means the final end product, but it's an illustration of what I'd like to achieve.

At ground level

Part 1: Divorce the Backend and Frontend

The first step would be to migrate towards Monorepo structure and separate the backend and the frontend completely. We will throw away Electron for now and just run Patchouli in a discrete web browser.

In detail, we need to:

Part 2: Shipping a Desktop version

The second step is to build a desktop application from the backend/frontend.

After much deliberation, I think Tauri is a good choice because:

However, it is unclear how the sidecar binary will be built, especially when it comes to what runtime to use.

Part 3: ???

Part 4: Profit!

yukiisbored commented 3 months ago

Oh, Bun has single-file executables: https://bun.sh/docs/bundler/executables