Pragmatic single-tenant SaaS architecture
Architectural decisions that make a difference when building solo or on a small team.
When you are building a SaaS alone (Indie Hacker) or in a very small team, the biggest risk is not technical, it is time. You need to validate, launch, and iterate fast. Complex architectures involving microservices, Kubernetes, and event-sourcing are often the premature death of projects that haven't even had their first user.
The Modular Monolith
Forget microservices. Start with a well-structured monolith. Next.js is perfect for this, as it allows you to have your Frontend and Backend (API Routes / Server Actions) in the same repository and deploy.
Advantages:
- Zero internal network latency: Your "API" calls can be just function calls if you use Server Actions.
- End-to-end typing: Share TypeScript interfaces between the front and back without extra packages.
- Atomic deploy: A single push updates everything. No incompatible API version issues.
The Database
Use a managed relational database. PostgreSQL is the safe choice. Services like Neon, Supabase, or PlanetScale (MySQL) offer generous free tiers and scale very well.
- ORM: Use Prisma or Drizzle. The productivity and type safety they bring are worth the small initial performance overhead.
Auth and Multi-tenancy
Don't reinvent the wheel for authentication.
- Use libraries like Lucia Auth or Auth.js if you want to self-host.
- Use services like Clerk or Supabase Auth if you want to outsource the complexity.
For B2B SaaS, model your database thinking about Organization or Team from day 1. All data must belong to an organization, and the user belongs to the organization.
model Tenant {
id String @id @default(cuid())
users User[]
todos Todo[]
}
model Todo {
id String @id @default(cuid())
tenantId String
tenant Tenant @relation(fields: [tenantId], references: [id])
}Deploy and Infra
Keep it simple.
- Vercel is excellent for starting. Zero config, integrated CI/CD.
- If you need to leave, a simple VPS (like Hetzner or DigitalOcean) with Coolify or Dokku solves 99% of cases for a fraction of the price.
Summary
The best architecture for a solo dev is the one that gets out of the way and lets you focus on the product.
- Monolith (Next.js).
- Postgres + Prisma/Drizzle.
- Ready-made Auth.
- Ready-made UI components (shadcn/ui).
- Automatic Deploy.
Scale the infrastructure when you have the revenue to pay for it.