DEV Community

Rahul Bhatt
Rahul Bhatt

Posted on

⚡️ Building a Multi-Tenant Spring Boot Starter from Scratch — with Subdomain Routing, Dynamic Datasources & Ego Logs

🚀 Building a Multi-Tenant Spring Boot Starter from Scratch

Developer Preview v0.1.0-SNAPSHOT is live!

🧠 Why This Starter Exists

Spring Boot lacks a true plug-and-play solution for multi-tenant SaaS platforms. Most solutions are deeply coupled, opinionated, or too abstract.

But also — this project came from a personal place.

Right after I received a disappointing 0.5 LPA raise (yes, backwards momentum), I decided to convert that frustration into engineering fire. Inspired by Blue Lock, I wanted to log every technical decision like a striker chasing goals — enter the ego-logs/ folder.

🧱 Project Structure

├── starter/       → Core Spring Boot auto-config starter
├── demo/          → Sample app showing real usage
├── ego-logs/      → My engineering journal (yes, Blue Lock–style)
├── scripts/       → Placeholder for CI or future tools
├── daily/         → Temp debug + local artifacts
Enter fullscreen mode Exit fullscreen mode

🧩 Features in Developer Preview

✅ Subdomain-based tenant resolution
✅ Header-based tenant resolution
✅ Tenant registry (in-memory)
✅ Per-DB isolation strategy
@EnableTenantIsolation annotation
✅ Clean Spring Boot auto-configuration
⚙️ Extensible resolvers + datasource logic

📦 Add It via JitPack

Maven

<dependency>
  <groupId>com.github.rahul-s-bhatt</groupId>
  <artifactId>multi-tenant-springboot-starter</artifactId>
  <version>v0.1.0-SNAPSHOT</version>
</dependency>
Enter fullscreen mode Exit fullscreen mode

Gradle

dependencies {
  implementation("com.github.rahul-s-bhatt:multi-tenant-springboot-starter:v0.1.0-SNAPSHOT")
}
Enter fullscreen mode Exit fullscreen mode

💻 Usage Snapshot

Enable the starter via application.yml

multi-tenancy:
  default-tenant-id: acme
  registry:
    type: IN_MEMORY
    in-memory-tenants:
      - tenantId: acme
        datasourceUrl: jdbc:h2:mem:acme
        username: sa
      - tenantId: globex
        datasourceUrl: jdbc:h2:mem:globex
        username: sa
  isolation:
    type: TENANT_PER_DATABASE
  resolution:
    type: HTTP_HEADER
Enter fullscreen mode Exit fullscreen mode

🧠 How It Works

flowchart TD
  A[Request] --> B[Filter: TenantResolver]
  B --> C[TenantContextHolder]
  C --> D[TenantRegistry]
  D --> E[RoutingDataSource]
  E --> F[DB A or DB B]
Enter fullscreen mode Exit fullscreen mode

🔥 About ego-logs/

This is my commitment to daily logging of what I learned, attempted, failed at, or broke. No GitHub green dots — real dev logs.

Just like Blue Lock's Ego Jinpachi believes in personal records to dominate the game, these ego logs are my engineering training arcs.

🛣️ What's Coming

  • JWT-based tenant resolution
  • Schema-based isolation
  • Runtime tenant onboarding APIs
  • Liquibase / Flyway integration
  • Multi-tenant Spring Security support

🧑‍💻 Contribute or Fork

If you're working on a SaaS platform, this is for you.
Star 🌟 the repo, fork it, build your own isolation strategy.

GitHub → rahul-s-bhatt/multi-tenant-springboot-starter
JitPack → jitpack.io/#rahul-s-bhatt

🫡 Final Words

Dev discipline isn't just commits — it's clarity, context, and ego-fueled progress.

This is just the beginning.


If you enjoyed this drop, follow @rahul_s_bhatt for future dev logs, open-source updates, and architecture deep dives.

Top comments (0)