Building Startups Right: Inside Our Proven SaaS Architecture
Chamoda Pandithage
Dec 15, 2024
saas-architecture

Building a successful SaaS startup requires balancing agile development, customer-focused design, and scalable architecture. @xaventra, we guide startups from crafting MVPs to building scalable systems for sustainable growth. This blog shares our insights on SaaS architecture and the approach we use to create high-performing, future-ready platforms.

Our Technology Stack

Our tech stack, Python, Golang, and TypeScript powers iterative, scalable platforms. Python ensures rapid development, Go handles performance and scalability, and TypeScript offers reliable, modern front-end flexibility.

Let’s dive into each language and their go-to frameworks.

Python [FastAPI]

We choose FastAPI for its performance, simplicity, and modern features. Here’s why we love it:

  • Adaptability: FastAPI handles everything from simple CRUD to complex applications, offering the flexibility and performance we prefer over heavier frameworks like Django.
  • OpenAPI Support: FastAPI auto-generates OpenAPI specs with Swagger UI, simplifying client SDK creation for frontends and mobile apps.
  • High Performance: FastAPI is among the fastest Python frameworks, thanks to its async support.

Golang [Goa]

We use Golang with the Goa framework for its speed, simplicity, and scalability in building high-performance microservices. Golang’s goroutines enable efficient concurrency, while Goa’s expressive DSL helps define, implement, and test services, ensuring maintainable and scalable microservices.

Here's a list of why we love to use Golang with Goa framework:

  • Concurrency Support: Golang’s goroutines and channels enable efficient handling of concurrent tasks, ideal for scalable, real-time applications.
  • Goa’s DSL for API Design: Goa’s domain-specific language (DSL) simplifies designing clear, well-defined APIs, making service definitions intuitive and maintainable.
  • OpenAPI Support: Like FastAPI, Goa generates OpenAPI documentation out-of-the-box, simplifying the creation of client SDKs for front-end and mobile apps.

Typescript [Next.js]

We use TypeScript with the Next.js React framework to build cutting-edge UI/UX experiences. Its type safety, scalability, and modern features like server-side rendering (SSR), static site generation (SSG), and API routes enable us to create high-performance, SEO-friendly applications with ease.

We love leveraging Next.js’s Static Site Generation (SSG) to deliver lightning-fast, SEO-optimized web apps by pre-rendering pages at build time.

PostgreSQL

We choose PostgreSQL as our primary data storage solution for its robust performance, scalability, and advanced features, making it perfect for building reliable, data-intensive applications.

Cloud native architecture

Our cloud-native architecture integrates Python (FastAPI), Golang (Goa), TypeScript (Next.js), and PostgreSQL to deliver scalable, high-performance MVPs for modern SaaS applications. This architecture is best understood through a diagram, so here we go.

Architecture diagram

Let me walk you through the diagram from left to right, starting with each component. We'll build the landing page using Next.js for static site generation, ensuring it's fast and SEO-friendly. We typically host it on Cloudflare Pages with continuous deployments, following Jamstack principles for speed and security.

Next, the web application is built with Next.js, leveraging SSG as much as possible while keeping the option for SSR when needed. When not using SSR, we follow a Jamstack approach, hosting on Cloudflare Pages with continuous deployment. We also use FastAPI and GOA OpenAPI specs to auto-generate code for the frontend.

For mobile applications, we prefer React Native with TypeScript, which enables code reuse and automatic code generation from OpenAPI.

At the MVP stage, we use an NGINX proxy server, typically hosted on Google Cloud (our preferred platform), to route requests to the relevant microservices. For most projects, we build FastAPI backends, using Golang when performance and concurrency are critical to the application's core features. We store production-critical data in PostgreSQL databases, typically one per microservice. Object data is stored in Cloudflare R2 (similar to AWS S3) for edge delivery.

12 Factor Ready

We follow the 12 Factor Principles to ensure scalability as the product grows. While we usually don't deploy to a Kubernetes cluster at the MVP stage, we design everything with future Kubernetes deployment in mind, avoiding major refactoring later.

Pragmatic Architectural Approach

With our technology and architecture, we take a pragmatic approach, keeping things simple yet scalable as we build and iterate on the MVP. This ensures that we can quickly adapt to new challenges while laying a solid foundation for future growth.