New ask Hacker News story: Ask HN: Junior dev in charge of rewriting 500k line PHP app. Looking for advice

Ask HN: Junior dev in charge of rewriting 500k line PHP app. Looking for advice
7 by poncho_romero | 9 comments on Hacker News.
We are a 4 person company, that makes a web app I'll call Star . Today, Star is 11 years old and showing its age. It was developed entirely by one of the founders, who has no formal training, and the niche industry we serve has changed greatly in the last decade, rendering many of our core abstractions obsolete. In theory, Star follows MVC, but in practice there is no coherent architecture. Most of the functionality is tied up in 10k+ line controllers, which use an outdated framework full of magic. Due to a trend of centralization in the industry, our database design (focused on local markets) is entirely orthogonal to our customer's needs. We are also stuck on outdated technologies that no longer receive security updates. Although our existing platform is in bad shape, I would have been wary to rewrite (due to stories of Netscape et al), but the decision has been made. Because most of our competitors are also operating outdated/inflexible software platforms, if we can make this transition happen, we will have a huge leg up on them in development velocity. Our founders have deep knowledge of the industry, and we have our biggest client's support. We are primarily a CRUD app, but we also integrate with external APIs (e.g. to handle texting) and utilize Amazon S3 and SQS for generating reports and other long running tasks. Tentatively, I want to propose a Model-View-Controller-Services architecture, where each model is a thin database abstraction layer that knows nothing else; views are pure and idempotent (à la React components, but server side); each controller is responsible for one endpoint, receives a Request object, delegates work to services, and returns a Response object; and most work happens in services, which can call each other and models. We delegate authentication to Google, but will need to implement a very fine grained permissions system. I want to keep things simple, and avoid bringing in too many dependencies, so I am leaning towards a minimal set of Symfony components, rather than something like Laravel. One of the primary complaints we get is that our current system is too slow. In part, this is because most actions trigger a full page reload. I want to use HTMX to increase responsiveness while still keeping most of the functionality in the backend. We will also be using Docker. We may use Redis for session management, or we may again store session data in the database. Our application will be deployed on DigitalOcean and use Cloudflare for caching. We've agreed to have one large component of our app ready by Apr 1st, which our largest client will use while we finish the rest of the work. Our development strategy will be based around delivering this key component, plus the minimum number of features required to support it (accounts, permissions, ...). I am curious if anyone could share their experience building a new system from scratch, and what pitfalls we might try to avoid while focusing on delivering this component. Our data is relational in nature, although there are some areas where we will need to store JSON/markup (we allow users to create custom forms, workflows, and templates). We will likely use MySQL 8. One of our founders wants to have a separate database and deployment per client, because he is concerned about accidentally showing Company 1's data to Company 2. I think this may be overkill, as some of our clients are very small, but also because it adds developer overhead needing to make changes to X databases and X deployments, rather than 1 shared database and 1 shared deployment. (One problem we currently face is that updating/deploying Star is manual and time consuming.) Right now, we average on the order of 100s of concurrent users, while hoping to grow to 1000s of concurrent users soon. We have users across the US & Canada, but are unlikely to expand beyond those markets. Is a shared database and single deployment reasonable for us, or should each client have their own database?

Comments