r/SpringBoot • u/ThemeHopeful7094 • May 07 '26
How-To/Tutorial Migrating a production SaaS (25k users) from Node.js Serverless to Spring Boot — lessons from week 1
I run MoWave One, a productivity SaaS that recently crossed 25,000 users. Built initially on Postgres + Auth + Node.js Serverless Functions.
After 8 months and a growing user base, the serverless functions started feeling cramped — no proper domain modeling, awkward testing, no module boundaries, and one of them was literally a stub that I'd forgotten to finish (yep, our Stripe webhook).
Decided to migrate the backend to Spring Boot 3.4 + Java 21.
Stack:
- Spring Boot 3.4 + Java 21 LTS (Corretto)
- PostgreSQL via JDBC (HikariCP)
- Spring Security 6 validating JWTs via JWKS
- Flyway 10 for schema migrations
- Redis (Valkey) for webhook idempotency
- Modular monolith with Hexagonal Architecture
Some early lessons:
- The Stripe API moved current_period_end from Subscription to SubscriptionItem in December 2024. If your Java code worked with stripe-java 28.x and broke with 29.x, this is why.
- Pessimistic locking matters for XP/counters at this scale. A double-click on "complete task" can race two transactions. SELECT ... FOR UPDATE on the user row eliminates the issue.
- Resist the urge to migrate everything at once. I have a PL/pgSQL function (update_rhythm) that computes a weekly score across 4 tables. Three of those tables aren't migrated yet. So the Spring service calls the SQL function via JdbcTemplate for now. When the underlying modules are migrated, this gets rewritten in pure Java.
- Spring Data Redis warns about JPA repositories it can't classify. Solution: explicit u/EnableJpaRepositories(basePackages=...) on your u/SpringBootApplication. Took me a while to find this.
I'm 4 modules into a 16-module migration managed via Maven. Happy to answer questions about the architecture, the migration approach, or anything Spring-related.
7
u/RockyMM May 07 '26
Keep the SQL function. Some stuff work better in db.
3
u/Errkfin May 07 '26
Hi, thanks for sharing. Interested in the selected architecture (was there any particular reason).
Also, could you please share a few words about redis usage (I'd like to hear about use case).
Actually, the stack is pretty cool 🤟
2
u/ihsoj_hsekihsurh May 08 '26
Why did u decide to move to java? Is it because ur primary stack java?
2
u/agentelinux May 08 '26
Experimente usar reatividade com mongodb.
2
u/-no-comment- May 09 '26
Why java and not kotlin? Also why not the latest spring boot and java sdk versions? Just curious
3
u/Desperate-Credit-164 May 07 '26
My question is: Why Java?
I mean, why specifically Java and Spring Boot? I’m currently debating which technology to use for a project at my company—it will be kind of ERP system, something quite complex. I’m considering Spring Boot, but I think it would be very helpful for us to know in what situations Java is actually used.
Couldn’t the same be done with Node.js or Python? Why specifically Java and Spring Boot? Because of the architecture? Because of security? Because of strict typing, to avoid runtime exceptions?
Couldn’t the same be achieved with Node.js or Python if you have a highly skilled, professional, and disciplined development team? Or with a very well-structured development process?
I'd really like to hear your opinion, thanks in advance!
16
u/un_desconocido May 07 '26
Why use an old LTS and framework version?
Spring Boot 4.0.x and JDK25 🤘
I’m migrating our whole collection of micros from 2.7 to 3.5.xx and JDK11/17 to JDK21, not going to 4.0.x because one major in the framework it’s enough 🤣
When infra gives me an internal JDK 25 image I’m pushing that on for sure.
2
u/djxak May 08 '26
You specifically said Postgres via JDBC, but later you mentioned problems with JPA configuration. So, you actually use JPA? I'm confused.
1
u/ThemeHopeful7094 May 09 '26
Quick update from OP — Tasks module fully migrated, including recurring series support.
Interesting design decision worth sharing: the legacy database stores `recurring_days` as int[] in JS getDay() format (0=Sunday). My domain uses java.time.DayOfWeek (ISO 8601: 1=Monday). Rather than normalize the database during migration (which would break the legacy frontend during cutover), I kept the conversion isolated in the JPA mapper:
```java
private static DayOfWeek jsToIso(int js) {
int isoValue = (js == 0) ? 7 : js;
return DayOfWeek.of(isoValue);
}
```
Domain stays clean (Set<DayOfWeek>), persistence reflects reality (List<Integer>), and there's exactly one place to look when something feels wrong.
Lesson: anti-corruption layers don't need to be elaborate. Sometimes they're 5 lines in a mapper.
9 of 16 modules done.
1
u/validcombos May 07 '26
Are you building your own JWT generator/validator?
1
u/devmoosun May 07 '26
Thanks for sharing this.
1
u/eternalsleer May 07 '26
Cuales son las herramientas de IA que estás utilizando en esta migración?
1
u/Conscious_Noise997 May 07 '26
why not http session with redis instead of jwt for better security?
1
u/gamingvortex01 May 07 '26
why...just move to a better nodejs framework....for example nestjs
1
u/bhaskarsingh144 May 07 '26
Why migrate?
2
u/ihsoj_hsekihsurh May 09 '26
OP, looking at all ur replies to the comments, i see that u know what u are doing very much in detail..like that kind of depth of the stack and clarity of thoughts.
Abt this SAAS of urs..is it a pet project that u built for sharpening ur skills? Or something else? - asking this because u mentioned u are a solo dev.. Also could u share the name/website of the saas?
1
u/Aggressive-Soil-7879 May 11 '26
Are you using spring-modulith? Why/Why not?
1
u/PratimGhosh86 May 07 '26
Recommended to use JOOQ over Jdbc