app icon indicating copy to clipboard operation
app copied to clipboard

App architecture

Open leschbenedikt opened this issue 5 months ago • 8 comments

Hi,

as you may have noticed I recently started to contribute to this project.

But before I get really into this I wanted to know if there are any plans on app architecture? At the moment I don't really see a clear pattern.

Currently it seems like most of the time the domain and data layers are mixed into the UI. In my opinion the project could use some clear layers and structuring.

I would be happy to suggest a few things but wanted to check with you first before heading in the wrong direction.

leschbenedikt avatar Aug 02 '25 18:08 leschbenedikt

Hey 👋

As you noted, there is no clear architecture pattern in the app. The architecture has mostly emerged during the programming without much thought - caused by my lack of flutter knowledge. If you have ideas on how to improve this, I'd love to hear them.

Probably the first thing would be moving everything to Riverpod?

kolaente avatar Aug 03 '25 13:08 kolaente

It's either riverpod or bloc in my opinion. Depending on what you like more.

Riverpod is more feature rich and flexible I would say and is also considered more modern. But it has a lot of "magic" going on which could be hard to understand for people new to flutter and riverpod. Often it is said that it is easier to learn than bloc but it really depends. I think it is faster to write code in the beginning but harder to debug and understand existing code bases. Also the flexibility makes it easier to circumvent architectural concepts.

Bloc is more boilerplate and not that fancy as riverpod. But you can reduce the boilerplate a lot by using just cubits which i prefer. But it still has more boilerplate. And at some few places even a fairly large amount. Also dependency injection isn't as nice as with riverpod What I like is that it comes close to an android app with compose and viewmodel. It's easier to navigate through the code cause the is less "magic". And I also like that is more structured. It is harder to mess up your architecture.

I really depends on what you like more and think is best for the project.

Also I would recommend changing the folder structure to make it clearer where everything is. At the moment it is kind of wild.

I would either recommend a layer base structure or a feature based structure.

Layer bases would somewhat look like this:

  • data/ -- datasources/ -- repositories/ //implemtation -- models/
  • domain/ -- use_cases/ -- repositories/ //interfaces -- entities/
  • presentation/ -- pages/ -- widgets/

And feature base would be:

feature1/

  • data/ -- datasources/ -- repositories/ //implemtation -- models/
  • domain/ -- use_cases/ -- repositories/ //interfaces -- entities/
  • presentation/ -- pages/ -- widgets/

feature2/

The second one is more structured but often it's hard to assign everything to a single feature. Therefore you will often have some kind of core folder where that stuff resides.

The first one does not have that issue but the subfolders can get rather large. And when creating more subsub folders it is getting harder to structure uniformly on all layers

leschbenedikt avatar Aug 03 '25 20:08 leschbenedikt

Thanks for the insight!

I think I would prefer Riverpod. In general, I'm all for less code even if it feels a little magic at first. But take that with a grain of salt, I really don't have much experience with it.

That being said, let's move forward with Riverpod. If we discover it's not great, we'll switch.

For the data structure, I think layer base is the way to go. Despite the features the app is still rather small and we're using the same structure in the main repo.

kolaente avatar Aug 05 '25 21:08 kolaente

Another thing I'd like to do: move the authentication to oauth only where the web frontend is an oauth provider redirecting to a custom vikunja:// app scheme. That would simplify the login experience in the app since users will only need to enter their instance url and then their credentials instead of having to choose between login with frontend and the other options.

kolaente avatar Aug 05 '25 21:08 kolaente

I'm also available in Vikunja's matrix room if you want to chat more in real time https://matrix.to/#/#vikunja:matrix.org

kolaente avatar Aug 05 '25 21:08 kolaente

Created the first PR of many regarding the architecture. Changed to folders to layer first as far as possible right now.

Will not introduce repositories and then add riverpod

leschbenedikt avatar Aug 08 '25 18:08 leschbenedikt

Another thing: Right now we don't have any permission handling in the app. That means when a user uses a project which was shared read only, we don't handle this (by disabling buttons, for example). This could be a separate issue, I just want to note it down.

Initially, I thought about this since https://github.com/go-vikunja/vikunja/pull/1277 was merged and now the header is different, but it seems like the app ignores it completely.

kolaente avatar Aug 17 '25 13:08 kolaente

Thanks for sharing. Probably better in another issue as this will be a pretty big change already. But when it's done it should be a small change.

leschbenedikt avatar Aug 17 '25 13:08 leschbenedikt