⚑️ Building a Multi-Tenant Spring Boot Starter from Scratch β€” with Subdomain Routing, Dynamic Datasources & Ego Logs

Code StrikerCode Striker
2 min read

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

🧩 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>

Gradle

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

πŸ’» 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

🧠 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]

πŸ”₯ 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.

0
Subscribe to my newsletter

Read articles from Code Striker directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Code Striker
Code Striker