<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Karan Sahani</title>
    <description>The latest articles on DEV Community by Karan Sahani (@karansahani78).</description>
    <link>https://dev.to/karansahani78</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3882361%2Fd9c33505-6eb9-4ecf-ba39-25e4aa109bda.jpeg</url>
      <title>DEV Community: Karan Sahani</title>
      <link>https://dev.to/karansahani78</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karansahani78"/>
    <language>en</language>
    <item>
      <title>⚡ I Got Tired of Writing the Same Spring Boot Code… So I Built a Generator Inside IntelliJ</title>
      <dc:creator>Karan Sahani</dc:creator>
      <pubDate>Thu, 16 Apr 2026 11:35:20 +0000</pubDate>
      <link>https://dev.to/karansahani78/i-got-tired-of-writing-the-same-spring-boot-code-so-i-built-a-generator-inside-intellij-g48</link>
      <guid>https://dev.to/karansahani78/i-got-tired-of-writing-the-same-spring-boot-code-so-i-built-a-generator-inside-intellij-g48</guid>
      <description>&lt;h1&gt;
  
  
  ⚡ I Got Tired of Writing the Same Spring Boot Code… So I Built a Generator Inside IntelliJ
&lt;/h1&gt;

&lt;p&gt;Every Spring Boot project starts the same way.&lt;/p&gt;

&lt;p&gt;You create an entity…&lt;br&gt;
and then spend the next hour writing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Repository&lt;/li&gt;
&lt;li&gt;Service&lt;/li&gt;
&lt;li&gt;Controller&lt;/li&gt;
&lt;li&gt;DTOs&lt;/li&gt;
&lt;li&gt;Mappers&lt;/li&gt;
&lt;li&gt;Exception handling&lt;/li&gt;
&lt;li&gt;Pagination&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nothing difficult.&lt;br&gt;
Just repetitive.&lt;/p&gt;

&lt;p&gt;And repetition is where productivity dies.&lt;/p&gt;

&lt;h2&gt;
  
  
  🤯 The Real Problem Nobody Talks About
&lt;/h2&gt;

&lt;p&gt;It’s not about writing code.&lt;/p&gt;

&lt;p&gt;It’s about rewriting the &lt;em&gt;same code&lt;/em&gt; again and again:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Same patterns&lt;/li&gt;
&lt;li&gt;Same structure&lt;/li&gt;
&lt;li&gt;Same logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And yet…&lt;/p&gt;

&lt;p&gt;We still do it manually.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 The Idea
&lt;/h2&gt;

&lt;p&gt;I asked myself a simple question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What if selecting a class could generate an entire backend layer?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not boilerplate.&lt;br&gt;
Not templates.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;production-ready code&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Under the Hood (The Interesting Part)
&lt;/h2&gt;

&lt;p&gt;Building this inside IntelliJ was way more complex than expected.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔹 1. Reading Code Like IntelliJ Does (PSI)
&lt;/h3&gt;

&lt;p&gt;You don’t parse Java files manually.&lt;/p&gt;

&lt;p&gt;You work with IntelliJ’s &lt;strong&gt;PSI (Program Structure Interface)&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect fields&lt;/li&gt;
&lt;li&gt;Identify annotations like &lt;code&gt;@Entity&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Extract metadata&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without PSI → nothing works.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔹 2. Generating Code That Doesn’t Look Generated
&lt;/h3&gt;

&lt;p&gt;Most generators fail here.&lt;/p&gt;

&lt;p&gt;They produce:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ugly code&lt;/li&gt;
&lt;li&gt;Poor structure&lt;/li&gt;
&lt;li&gt;Hard to maintain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted the opposite:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Code that feels like a senior developer wrote it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That meant:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean layering (Controller → Service → Repository)&lt;/li&gt;
&lt;li&gt;DTO separation&lt;/li&gt;
&lt;li&gt;Proper naming conventions&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🔹 3. Dependency Injection Without Breaking Projects
&lt;/h3&gt;

&lt;p&gt;This turned out to be one of the hardest parts.&lt;/p&gt;

&lt;p&gt;You need to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Detect if dependency already exists&lt;/li&gt;
&lt;li&gt;Support both Maven &amp;amp; Gradle&lt;/li&gt;
&lt;li&gt;Avoid duplicates&lt;/li&gt;
&lt;li&gt;Insert safely inside correct block&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A naive approach breaks builds instantly.&lt;/p&gt;

&lt;p&gt;So I built logic to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Scan existing dependencies&lt;/li&gt;
&lt;li&gt;Inject only when missing&lt;/li&gt;
&lt;li&gt;Keep it idempotent&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🔹 4. Optional Security (JWT)
&lt;/h3&gt;

&lt;p&gt;Security isn’t just “add dependency”.&lt;/p&gt;

&lt;p&gt;It involves:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Filters&lt;/li&gt;
&lt;li&gt;Authentication flow&lt;/li&gt;
&lt;li&gt;User + roles&lt;/li&gt;
&lt;li&gt;Token handling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And it had to be:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Optional. Clean. Non-breaking.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🔹 5. Supporting Multiple Databases
&lt;/h3&gt;

&lt;p&gt;Different teams → different databases.&lt;/p&gt;

&lt;p&gt;So I added dynamic support for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;MySQL&lt;/li&gt;
&lt;li&gt;PostgreSQL&lt;/li&gt;
&lt;li&gt;MongoDB&lt;/li&gt;
&lt;li&gt;H2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Challenge:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JPA vs Mongo are fundamentally different&lt;/li&gt;
&lt;li&gt;Configurations vary&lt;/li&gt;
&lt;li&gt;Drivers must be injected conditionally&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚡ The Biggest Lesson
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Generating code is easy.&lt;br&gt;
Generating &lt;strong&gt;safe, usable, production-ready code&lt;/strong&gt; is hard.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧩 What This Changed for Me
&lt;/h2&gt;

&lt;p&gt;I stopped thinking like a developer writing code.&lt;/p&gt;

&lt;p&gt;And started thinking like:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A developer building tools for developers.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🚀 Why This Matters
&lt;/h2&gt;

&lt;p&gt;This isn’t just about saving time.&lt;/p&gt;

&lt;p&gt;It’s about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reducing friction&lt;/li&gt;
&lt;li&gt;Standardizing architecture&lt;/li&gt;
&lt;li&gt;Eliminating repetitive mental load&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because energy should go into solving real problems…&lt;br&gt;
not rewriting CRUD for the 50th time.&lt;/p&gt;

&lt;h2&gt;
  
  
  💬 Final Thought
&lt;/h2&gt;

&lt;p&gt;The best tools don’t just automate tasks.&lt;/p&gt;

&lt;p&gt;They remove &lt;em&gt;unnecessary thinking&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;If you’ve ever tried building developer tools,&lt;br&gt;
or struggled with safe code generation…&lt;/p&gt;

&lt;p&gt;I’d love to hear your approach 👇&lt;/p&gt;

</description>
      <category>automation</category>
      <category>productivity</category>
      <category>showdev</category>
      <category>springboot</category>
    </item>
  </channel>
</rss>
