Skip to main content

Welcome

· 4 min read
Anoop Karnik Dasika
Founder of Bayesian Labs

MicroSaaS products are one of the most exciting ways to create impactful software with minimal resources. They allow solopreneurs and small teams to quickly launch, validate, and iterate on ideas. To help developers hit the ground running, I built a boilerplate for MicroSaaS products using a TurboRepo monorepo setup and am excited to share it with the open-source community.

In this blog, I'll walk you through the architecture, design decisions, and why I chose each part of the stack.


Why a MicroSaaS Boilerplate?

Building a MicroSaaS product often involves:

  1. Repetitive setups for backend, frontend, and infrastructure.
  2. Struggling with the decision of monorepo vs polyrepo.
  3. Ensuring scalability without overengineering.

This boilerplate solves these problems by providing a pre-configured, modular, and extensible foundation. Here's what you get out of the box:

  • A monorepo setup using TurboRepo for code-sharing and efficient builds.
  • TypeScript for type safety across the stack.
  • A Next.js frontend for fast and modern web development.
  • A Node.js/Express or NestJS backend for APIs.
  • Prisma for database management and ORM.
  • TailwindCSS for rapid UI development.
  • Docker for containerized deployments.
  • GitHub Actions for CI/CD pipelines.
  • A clear folder structure to keep everything organized.

Monorepo with TurboRepo

Why TurboRepo?

TurboRepo is a powerful build system for monorepos that simplifies dependency management and speeds up builds. In a MicroSaaS setup, where you might have shared components or utilities between your frontend and backend, a monorepo makes life easier.

Key Benefits:

  • Shared code between packages.
  • Efficient caching for faster builds.
  • Simplified dependency management.

Folder Structure

Here’s how the boilerplate is organized:

/microsaas-boilerplate
├── apps
│ ├── web # Next.js app
│ ├── api # Express/NestJS backend
├── packages
│ ├── ui # Shared UI components
│ ├── utils # Shared utilities
├── prisma # Database schema and migrations
├── docker # Docker configuration
├── .github # GitHub Actions workflows
└── turbo.json # TurboRepo config

Frontend with Next.js

Why Next.js?

Next.js offers the perfect blend of server-side rendering (SSR) and static site generation (SSG), making it ideal for modern MicroSaaS products. Features like API routes and image optimization come in handy for building performant apps.

Key Decisions

  • File-based routing: Keeps the code organized and easy to scale.
  • TypeScript: Ensures type safety and reduces bugs.
  • TailwindCSS: For rapidly building beautiful and responsive UIs.

Backend with Node.js and Prisma

Why Prisma?

Prisma simplifies database interactions with a declarative schema and powerful type safety. It works seamlessly with relational databases like PostgreSQL and MySQL, making it an excellent choice for SaaS apps.

Key Decisions

  • REST API vs GraphQL: The boilerplate uses REST for simplicity but can be extended to GraphQL if needed.
  • Session management: Includes JWT-based authentication for secure user sessions.
  • Database migrations: Prisma CLI ensures migrations are easy to manage and deploy.

DevOps: Docker and GitHub Actions

Why Docker?

Docker ensures consistency across development, testing, and production environments. The boilerplate includes:

  • A Dockerfile for both the frontend and backend.
  • A docker-compose.yml for local development.

CI/CD with GitHub Actions

Automated workflows for:

  • Linting and testing.
  • Building and deploying Docker containers.
  • Running database migrations.

Design Principles

When creating this boilerplate, I followed these guiding principles:

  1. Simplicity: Avoid overengineering. The goal is to ship MVPs quickly.
  2. Scalability: While simple, the stack can scale as your app grows.
  3. Extensibility: Easily add new features, packages, or technologies.
  4. Developer Experience: Focus on tools that make development enjoyable and productive.


Conclusion

This boilerplate is the result of many iterations and lessons learned while building MicroSaaS products. I hope it saves you time and effort so you can focus on what truly matters—your product and your users.

Feel free to fork, star, and contribute to the repository. Let’s build amazing MicroSaaS products together!

Check out the repo here


Share Your Feedback

Have ideas to improve the boilerplate or want to share your experience using it? Drop a comment below or open an issue on GitHub!