Building a Production-Grade Authentication Service for SaaS
From EdTech MVP to Multi-Tenant Platform

Repository: https://github.com/AkshayThoolkar/ai_edtech_auth_service.git


1. Introduction: The Real Problem

In the software world, the standard advice is almost always: “Don’t roll your own authentication.”

They are usually right. Authentication is security-critical infrastructure where mistakes are expensive. Mature providers like Auth0, Cognito, and Descope exist precisely because identity is hard to get right.

And yet, I built my own.

I didn't do it because I wanted to reinvent cryptography or because commercial tools are bad. I did it because, in my specific business context, owning authentication became strategically necessary. For a high-growth B2C platform, "just buying auth" wasn't a silver bullet—it was a tax on my unit economics.

This article details the business logic behind that decision, the architecture of the production-grade system I built to replace the vendors, and how I designed it to evolve into a multi-tenant identity provider for my future ventures.


2. Context: The EdTech Platform

To understand the decision, you have to understand the product. I was building an AI-powered EdTech platform targeting students and learners.

The constraints were clear:

User Base: Highly price-sensitive B2C users.

Acquisition Model: Heavy reliance on free trials and freemium tiers to drive growth.

Scale: Aggressive goals to reach millions of users.

In a microservices architecture, authentication isn't just a login screen. It is the identity source of truth, the root of authorization decisions, and a dependency for every single API call.


3. Decision: Build vs. Buy

I didn’t start by building this. Initially, I integrated Descope. It was genuinely excellent: fast setup, customizable UI, and a smooth developer experience. For an MVP, it reduced time-to-market dramatically,.

But as I modeled the long-term business logic, the math broke down. At the time, Descope’s basic plan was roughly $249 for 10,000 Monthly Active Users (MAU). That’s approximately ₹2.2 per user.

That sounds reasonable until you project growth:

• 10,000 users → ~$249/month

• 100,000 users → ~$2,500/month

• 1 million users → ~$25,000/month

For B2B Enterprise SaaS with high revenue per user, these costs are negligible. But for a B2C product where many users are not immediately monetized, authentication alone could become one of the largest operating expenses. If authentication sat outside my system, I inherited its pricing and constraints. If I brought it inside, I inherited the responsibility—but also the leverage.

The Trade-off Matrix