← All posts

How I Built a Full SaaS in 6 Weeks — Architecture, Decisions, and Tradeoffs

May 27, 2026·#saas#architecture#nestjs

A complete breakdown of the Maalig AI architecture: Angular 18 SSR + NestJS + MongoDB + Redis + Razorpay. Every major decision explained.

How I Built a Full SaaS in 6 Weeks

Building a production-grade SaaS in 6 weeks sounds impossible. It isn't — but it requires making ruthless decisions about what to build and what to defer.

The Stack

  • Frontend: Angular 18 with SSR (Angular Universal)
  • Backend: NestJS with MongoDB + Redis
  • Payments: Razorpay (India) + Stripe (global)
  • Infrastructure: Docker Compose on a bare-metal Linux server

Week 1: Core Auth

I started with auth because everything else depends on it. Email + password registration with email verification, Google OAuth, JWT with Redis blacklist for logout.

The key decision: use refresh token rotation from day one. Don't cut corners on auth — it's the hardest thing to retrofit.

Week 2–3: AI Chat + Channels

The core product: a WhatsApp/Telegram bot powered by OpenAI. I built the channel abstraction first (one interface, multiple adapters) so adding new channels doesn't break existing ones.

Feature flags went in here too — I needed a way to turn off AI chat for free users without deploying code.

Week 4: Billing

Razorpay for Indian users (UPI, debit cards, net banking). Stripe for international.

The hardest part: idempotent webhook handling. Razorpay can fire payment.captured multiple times. I solved it with a lastRazorpayPaymentId field on the user document.

Week 5: Lead Capture + Analytics

Every WhatsApp conversation captures: name, phone, email, intent. Stored in MongoDB, exportable as CSV.

Analytics: page views, funnel events, MRR estimate, plan distribution.

Week 6: DevOps + Production Hardening

Multi-stage Dockerfiles, GitHub Actions CI/CD, rolling deploys with health checks and automatic rollback.

What I'd Do Differently

  1. Start with the billing model first — it shapes everything
  2. Use a monorepo from day one (not retrofit it in week 3)
  3. Write integration tests for the payment webhook from the start

The platform is live. Real payments. Real users. 6 weeks from first commit.