Hi all! Do people have any example for full stack multiplatform architectures? I am working on a personal project myself, containing a ktor backend, react web app and an android app. This application has an experimental focus on reusing as much code as possible, up until now 25% of the backend code comes from the shared code, and the frontend in itself can share more code than that (obviously 🙂 ) even if the react app and the android app have two different purposes. Therefore I am wondering how others are also experimenting with this and perhaps have some already published articles on this topic, please let me know 🙂
04/07/2021, 5:59 PM
I am also working exactly on the same thing, right now I am trying to share the
code as below
(Web & android)
1. UI behavior related logic
2. the http client that we use to connect to backend
3. Also trying to have redux to maintain APP state so that it could be turned into declarative UI
(web & android & API)
1. Data models/Enums/API endpoints
2. Any common business logic
I have not completed the app though, but please do share how you are thinking of code sharing , I did not find too many resources that showcases code sharing between web and android.
04/07/2021, 6:12 PM
So this is a slide from a presentation I will have about this in the coming weeks. Basically I use MVVM architecture on the frontend with use cases. My data is stored in the repositories, and the usecases are fetching/updating the data and passing it on to the viewmodel. The view model then turns the data into a view state.
The backend and frontend therefore share the same architectural concepts. Between every layer they communicate with a Flow that returns a Result object.
The idea is that every component is as simple as possible, making it easier to reuse. Therefore my frontend and backend share the same Repositories for every object (albeit with different implementations) and the actual API between the frontend and backend is abstracted away
making things simple made it also possible to create a whole bunch of microservices. The microservices interact with each other with the exact same code as how the frontend interacts with the backend
It does seem like I can reuse the usecases from the frontend in the backend as well
so perhaps I can get a higher amount of shared code between FE and BE