Comment to 'UNA + NEO = PWA & Native Apps'
  • Great question @nims !

    UNA is not switching to the new stack. Instead we are creating a new frontend layer using the new stack. We choose to keep PHP for server side logic and MySQL for database. It may not be the most trendy and new combo, but modern PHP can be adapted to be very performant and it benefits from large pool of devs that can maintain it. Same goes for MySQL- it’s reliable, secure and scalable. Whenever there’s an issue chances are that there’s an extension or a tool that addresses it and it has been used in large scale production.

    Now, frontend is different. There’s only so much you can do with HTML until some sort of JS framework is required. We decided to go with React for web and ReactNative for native. For web we use NextJS meta framework and for native we use Expo to streamline the development.

    There is a lot more to it, of course. UNA is a complex platform so some components definitely call for other underlying solutions. For example, at scale certain calculations or queries may become cumbersome. This doesn’t mean that entire system needs to be rebuilt with another stack, which would ultimately underperform on some specific tasks anyway. Instead we need to embrace microservices architecture and isolate high load tasks to specialised workers, written and configured in a way that suits the challenge. For example, your feed calculation and associated queries may take 5 milliseconds with PHP and MySQL but at scale with large tables it may creep to, say, 5 seconds! If we do it in runtime the site becomes unusable. We could rewrite the whole app in something like Rust and use Postgres, but not only it would take 10 years - it would also make it much harder to find people to maintain it, documentation to understand it and tools to extend it. Solution? Instead we can isolate the particular issue and do things like adding multithreading to PHP, denormalising and cashing feed calculations, storing their cache in redis, etc etc. We can ultimately even create a separate Rust/Golang script that handles calculations and stores them in the most performant type of database. Point is that until certain workloads become large it’s best have everything handled by the most reliable and complete framework - PHP/MySQL is great for that.

    With the new frontend we get data from the PHP server via json api and websockets. We still render most screens on server (with NextJS) and stream some of the data in asynchronously using dynamic imports. It’s a mix of rendering and routing strategies - different for web and native, different for spaciest types pages - feeds, browsing, static, lists, changing/unchanging etc. React unlocks a lot of new strategies and that’s what NEO is for.