My 2022 Stack for Building a SaaS
Introduction
A SaaS (Software as a Service) is a web application where you charge money for access. For example, an invoice tracking platform that costs $5 a month to access would be considered a SaaS.
I've come across many tools and frameworks over the years that aim to simplify building applications. During that time, I've seen countless tweets telling people to use framework X over Y, with arguments like:
- "X uses a modern programming language"
- "X scales better than Y"
I see these arguments regularly and find them silly. I believe programming languages and frameworks are all tools that achieve the same end goal - building a web application.
Scaling shouldn't even be a concern as a startup. You'll end up slowing yourself down and over-engineering. Worry about those issues when the time comes, not now.
My Stack
When building a SaaS, I believe you should use tools and frameworks you're already familiar with. With my experience in Vue.js, I can utilise the frameworks mentioned below.
Landing
I like to have the landing page, blogs, and documentation in one codebase that deploys to static HTML files. I use Nuxt 3 as it utilises Vue.js, along with their Nuxt Content plugin to power blogs and documentation.
Nuxt Content lets me write articles and documentation in markdown files. This makes it easy to write and maintain without styling titles or paragraphs each time. The website deploys to Vercel just by pushing to GitHub, making updates a breeze.
Dashboard
I stuck with Laravel and Vue.js since I already knew them. I like Laravel because it comes with authentication scaffolding, letting me focus on the core app instead of email verifications.
Vue.js is straightforward, easy to use, yet powerful enough for state management. While React.js is often promoted on Twitter, I personally found it too complex for simple tasks and not beginner-friendly.
I went with the VILT (Vue.js, Inertia, Laravel & Tailwind CSS) stack. I could quickly style my application with Tailwind's utility classes without spending hours writing CSS and remembering class names.
Finally, Inertia bridges my Laravel application with Vue so I can pass information from the database to users.
Database
For years I used MariaDB as my database solution - an optimised fork of MySQL that worked flawlessly with previous SaaS applications. I never faced bottlenecks until we surpassed 90 million records. By that point, we started facing constant freezing, which I overcame with server-side caching - not ideal.
When building Analyse, I knew we needed a more robust solution. I knew we'd surpass 100 million records quickly - and we did, in our first 6 months.
After looking at other database solutions, I found nearly all required learning a new query language, weren't MySQL compatible (requiring rewritten queries), or needed maintaining two databases. With my motive to move fast, learning new languages and rewriting queries wasn't on my bucket list.
SingleStore
After hearing about SingleStore from a Fathom Analytics article, I decided to try it - I was blown away. It took small tweaks to my table schema (like removing foreign key constraints) in return for a massive performance boost. I didn't need to learn a new query language or rewrite queries. It just worked.
When I first saw SingleStore offered a free self-managed version, I was skeptical we'd face issues as we grew. I was massively wrong. The free tier has allowed us to rapidly query and store more than 120 million records. It's a great feeling that I can host this off existing infrastructure for no extra cost.
Hosting
When deploying to production, I always host on "bare metal" - paying a flat monthly fee to rent hardware in the cloud. The advantage is knowing exact expenses and owning that hardware for as long as you rent it.
I use a AX41-NVME from Hetzner to host Analyse - a beefy machine with 64GB RAM, 512GB SSD, and a great Ryzen CPU. I run my SaaS and SingleStore on this machine, and even with thousands of customers and more than 120 million records, we only average 1% CPU load.
We receive more than 30 million API requests every month.
What About Serverless?
I see this brought up a lot with many recommending serverless. Common arguments include:
- "3am wake-up calls"
- "Dealing with server maintenance"
Honestly, in the 8 months since my SaaS launched, I haven't once dealt with any of these. Nor in previous years with other projects. I'm sure it happens but nowhere near the frequency people claim - it's scaremongering. People rush into serverless, don't configure it correctly, and wake up to huge bills.
The principle of serverless is great but it's over-hyped. I wouldn't recommend it until you're at a scale where these issues happen often. Start small and affordable, then upgrade when the time is right.
I've seen people go serverless early, spending $45+ a month on AWS and Laravel Vapor only to get 5 users and make $0 in revenue. If you start on a small $5 Digital Ocean droplet, you can scale up when needed - you'll probably find it lasts a long time.
Analytics
Analytics are crucial for gauging interest, finding where visitors come from, and when your site is most active. This helps identify quiet spots - usually a great time to launch new features or update a dashboard.
Many turn to Google Analytics, but it breaches visitor privacy. Google uses visitor data for advertising, which is why they don't charge for access.
Google Analytics is also considered illegal in many countries, which could open you up to legal trouble. This is why I use Fathom Analytics - they charge a small fee but offer privacy-focused analytics. As a bonus, Fathom isn't picked up by ad blockers unlike Google Analytics, making your dashboard more reliable.
Payments
For generating revenue, I use Paddle. They have a fantastic support team and support PayPal, which my target audience primarily uses. As a customer, you also get access to ProfitWell, an awesome platform that provides additional revenue visibility.
I love how active their CEO (Christian Owens) is on Twitter. While it's not a reason to switch, it shows their commitment to great support.