Skip to content

thesaas-company/saas-infra

Repository files navigation

SaaS Boilerplate for Infrastructure πŸš€

In the dynamic landscape of SaaS companies, the relentless cycle of rebuilding tech stacks often distracts from addressing your core business challenges. Ideally, your focus should center on solving the unique problems your startup encounters. However, early-stage startups frequently invest substantial resources in infrastructure engineers, leading to unnecessary expenses.

Here, our mission is to optimize your costs, reducing them to below $15k/year while guaranteeing a 99% Service Level Agreement (SLA). We aim to standardize your technology stack, enabling the rapid reconstruction of infrastructure in a matter of days, not months.

Motivation

My motivation stems from the hands-on experience of building the infrastructure for multiple saas comapny from scratch. The process revealed the repetitive nature inherent in many SaaS companies, where 80% of the infrastructure is commonly shared, leaving only 20% for unique customizations.

Understanding the difficulty of constructing a universal layer for diverse infrastructures, I observed previous attempts, such as Opta, which, despite failures, provided valuable inspiration. This realization sparked the idea to document my insights gained from the roller coaster journey.

My focus lies in a specific niche where CTOs prioritize Infrastructure as Code (IaC) for compliance, irrespective of the ongoing Terraform vs. Pulumi discussions. The emphasis is on practical solutions, leveraging Terraform if it meets the requirements. In this niche, CTOs prioritize achieving Product-Market Fit over engaging in unnecessary debates.

Philosophy 🀝

  • Build Once, Share with Others: Foster a collaborative environment by building infrastructure components once and sharing them with others for increased efficiency.

  • Decentralized Infrastructure Ownership: Encourage each service to own its custom infrastructure components, such as databases, message queues, and email services.

Tech Stack πŸ› οΈ

  • CICD: Buildkite + GitHub + Buildkit
  • Cloud Providers: AWS/GCP
  • Version Control: GitHub/GitLab
  • Infrastructure as Code (IaC): Terraform
  • Monorepo: Turbo + Task
  • Development Environment: Pixi.sh + Dev Container
  • Secrets Management: AWS/GCP Secret Manager
  • Container Orchestration: Kubernetes (GKE + EKS)
  • Programming Languages: Go + NodeJs + Python (No Restrication)
  • Database Support: No Restrication
  • Communication Protocols: GRPC (buf + connectrpc) + REST
  • Containerization: Docker
  • Serverless Deployment: Vercel
  • Observability: Grafana (OnCall + Monitoring + Observability + Tracing)

FAQ ❓

Is it production-ready?

No, it's in a very early stage, and we are actively seeking partners to help build it collaboratively through open source.

Does it have production-grade support for GCP?

Currently, we're exclusively working with AWS customers. We welcome discussions about your requirements; please schedule a call.

Why Choose Our Boilerplate?

Enjoy a $15k/year infrastructure engineer cost with 99% uptime and a developer experience that engineers desire, backed by a community-driven scaling approach.

Do You Support Our Tech Stack?

Absolutely! You can choose any language for your development; we don't impose any restrictions. While we've standardized a few stacks for the community, these decisions are well-thought-out and based on startup growth. Feel free to evolve your engineering stack in the future and replace them as per your specific needs.

Why Monorepo?

A Monorepo structure simplifies versioning, dependency management, and cross-service collaboration, promoting streamlined CI/CD pipelines, code reusability, and unified testing.

Monorepo is scary, isn't it?

Feeling apprehensive about adopting a Monorepo? It's completely understandable. That's precisely why our existence revolves around providing the necessary tools to make running a successful Monorepo more accessible and manageable. We're here to alleviate the fears and empower you on your journey towards a streamlined development process.

Is it secure?

Yes, our IaC architecture incorporates learnings from Opta. While Opta support is not provided, we've removed the Opta wrapper from the modules and independently maintain all modules. This IaC architecture is compliance-ready, ensuring no issues in SOC2 compliance.

Is it scaleable/extendable?

Yes, at any point, involve your infrastructure engineers for CICD and IaC migration if necessary, especially as complexities arise with your growth. The entire idea here is to offer you a smooth exit path, unlike PAAS. It's 100% better then hacking around serverless funtions.

does it work with other cicd providers like github, circleci etc?

No, it's on our roadmap. We plan to address this once the project reaches a mature stage(v1.0.0)

Is it for CTOs?

Absolutely!, we are creating this for a community of CTOs who are tired of reinventing the wheel. With our solution, a CTO can establish their entire infrastructure within days without the need to worry about the nitty-gritty details. Once the foundation is set, you can focus on implementing unique ideas and enhance the existing stack module by module.

Do you support all AWS resource in IaC ?

Certainly! Explore all the available modules here. If you can't find the module you need, feel free to create your own implementation.

Do you support tenant managment, Where we can deploy a tenant using IaC/Pipeline ?

Absolutely! Yes, we exclusively offer stateless automation that can be monitored through CICD, Here you need to build application for state managment

We only have a Next.js app, is this for us?

No, absolutely not. We recommend using Vercel for a full-stack solution. This tool is better suited for scenarios where your infrastructure evolves from a single app to multiple microservices.

What kind of ingress setup do you support?

We offer support for multiple ways to expose your app, and we are open to discussing additional possibilities. In the current setup, you can expose ingress in two ways:

  • Each tenant has a unique endpoint, such as tenant_name.us-east-2.xyz.com, consolidating the exposure of individual services.
  • Multiple services can share an ingress endpoint, for example, api.us-east-2.xyz.com.
  • Hybrid setups are also possible.

We welcome collaboration to explore and understand other potential solutions.

Pricing

At the moment, the open-source model is complimentary for startups, fostering community collaboration and knowledge sharing. For startups seeking personalized support, we provide a flexible plan that includes:

  • Setup for 2 environments in 1 region wihtin 10 days
  • Deployment capacity for up to 10 services
  • Comprehensive features like Observability, CICD, IaC, Development Environment, and Secrets Management
  • Swift deployment capabilities, enabling your developers to launch new services within 30 minutes.

Choosing to sponsor this project will prioritize your issues.

Contact Us

Requirments πŸ› οΈ

  • VSCode
  • Docker
  • Pixi brew install pixi
  • Task brew install go-task
  • arkade curl -sLS https://get.arkade.dev | sudo sh
  • buf brew install bufbuild/buf/buf

Getting Started πŸš€

To get started with this boilerplate, follow these steps:

  1. Clone the repository: git clone https://github.com/yindia/saas.git
  2. Navigate to the project directory: cd saas
  3. Install and get the shell by running pixi install && pixi shell
  4. Install cookiecutter pip install cookiecutter
  5. You are ready to create your first environment

Add new Environment πŸš€

An environment serves as the foundational infrastructure encompassing VPC architecture, DNS configuration, Kubernetes cluster, and Kubernetes base setup (Linkerd + Nginx + Cluster Autoscaler). To kickstart a new environment, follow these steps:

Arch

  1. Ensure you have an AWS account and set up AWS CLI credentials.
  2. Generate your initial environment by executing task add:environment. This command prompts you with questions such as name, region, AWS account ID, etc.
  3. The generated code resides in infrastructure/environment/aws/{{ENV_NAME}}/{{REGION}}.
  4. Run Terraform commands for testing and deployment.

Create a New Service πŸš€

To generate a new service, follow these steps:

  1. Generate your initial service by executing task add:service. This command prompts you with questions such as name, region, AWS account ID, etc.
  2. The generated Go code resides here services/{{SERVICE_NAME}}, and infrastructure code is located at services/{{SERVICE_NAME}}/infrastructure along with a Helm chart.
  3. Add custom Terraform configuration at services/{{SERVICE_NAME}}/infrastructure, for example, RDS in rds.tf:
module "saas_aws_postgres" {
  source  = "yindia/saas/opta"
  version = "1.0.0"
  # insert required variables here
}

Refer to the module docs

  1. Please also add inputs in input.tf, if service need any secret
  2. Run Terraform and Helm commands for testing and deployment.
  3. We generate a standard helm template for each service

πŸ“š Documentation

For complete usages, please dive into the docs.

Guide (TBD)

πŸ’¬ Discussions

Head over to the discussions to share your ideas.

Contributing 🀝

We welcome contributions! If you have ideas for improvements or find any issues, feel free to open an issue or submit a pull request.

Deployment 🀝

License πŸ“„

Acknowledgments πŸ™Œ

Thank you for considering our boilerplate for your infrastructure needs. We are eager to assist you in simplifying and optimizing your development process.

If you find this repository helpful, please consider giving it a star! ⭐️

References & Inspiration 🌟