<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/scripts/pretty-feed-v3.xsl" type="text/xsl"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:h="http://www.w3.org/TR/html4/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Prabhu L S — Blog</title><description>Android &amp; AI Developer. Personal blog about Android development, Kotlin, Jetpack Compose, KMP, Spring Boot, AI, and homelab infrastructure.</description><link>https://prabhuls.me</link><language>en-us</language><lastBuildDate>Tue, 08 Sep 2026 15:34:48 GMT</lastBuildDate><managingEditor>dev@prabhuls.me (Prabhu L S)</managingEditor><webMaster>dev@prabhuls.me (Prabhu L S)</webMaster><atom:link href="https://prabhuls.me/rss.xml" rel="self" type="application/rss+xml"/><item><title>Beginner&apos;&apos;s Guide: Creating a Spring Boot REST API with Kotlin</title><link>https://prabhuls.me/blog/build-rest-api-with-kotlin-spring-boot</link><guid isPermaLink="true">https://prabhuls.me/blog/build-rest-api-with-kotlin-spring-boot</guid><description>basics of spring</description><pubDate>Mon, 01 Dec 2025 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;What to Expect from This Session&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Create a new &lt;strong&gt;Spring Boot project&lt;/strong&gt; from scratch&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Understand the &lt;strong&gt;basic structure&lt;/strong&gt; of a Spring Boot application&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set up a &lt;strong&gt;persistent in-memory database (H2)&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Write and run basic &lt;strong&gt;SQL queries&lt;/strong&gt; to manipulate data&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Call your &lt;strong&gt;API&lt;/strong&gt; endpoints to interact with the application&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Prerequisites&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Basic &lt;a href=&quot;https://medium.com/@riztech.dev/simplifying-kotlin-classes-objects-and-constructors-48ce681588a5&quot;&gt;Kotlin&lt;/a&gt; or Java understanding (classes and objects)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://medium.com/@techwritershub/the-basics-of-api-for-beginners-a-complete-guide-be4d0c9d9b15&quot;&gt;REST API&lt;/a&gt; basics understanding&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Familiarity with SQL SELECT commands and conditions&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.jetbrains.com/idea/download/&quot;&gt;IntelliJ IDEA&lt;/a&gt; or &lt;a href=&quot;https://developer.android.com/studio&quot;&gt;Android Studio&lt;/a&gt; (both are essentially the same)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;API Client: &lt;a href=&quot;https://www.postman.com/downloads/&quot;&gt;Postman&lt;/a&gt; (standard choice) or &lt;a href=&quot;https://www.usebruno.com/downloads&quot;&gt;Bruno&lt;/a&gt; (open-source alternative)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Checkout my &lt;a href=&quot;https://github.com/ls-prabhu/taskbackend/tree/master&quot;&gt;github&lt;/a&gt; for full source code.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Initialize Project&lt;/h2&gt;
&lt;p&gt;The easiest way to bootstrap your Spring Boot (Kotlin) application is by using the official Spring Initializer.&lt;/p&gt;
&lt;p&gt;We are going to create a TODO list back-end.&lt;/p&gt;
&lt;p&gt;Go to &lt;a href=&quot;http://start.spring.io&quot;&gt;start.spring.io&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./initilizer.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Choose the following configuration as shown above:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Dependencies:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Spring Web&lt;/strong&gt; — RESTful API support&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;H2 Database&lt;/strong&gt; — In-memory database (no external database required)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Spring Data JPA&lt;/strong&gt; — Data manipulation library for database operations&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Click the &lt;strong&gt;Generate&lt;/strong&gt; button to download a zip file. Extract the contents to your project folder and open it in your IDE.&lt;/p&gt;
&lt;h3&gt;Final Check&lt;/h3&gt;
&lt;p&gt;After importing the folder into your IDE, verify that you&apos;ve configured the Java version to match the one you selected in Spring Initializer:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;File → Project Structure → Project → SDK&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;File → Settings → Build Tools → Gradle → Gradle JVM&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;pre&gt;&lt;code class=&quot;language-mermaid&quot;&gt;classDiagram
direction TB

%% =======================
%% Application Root
%% =======================
class TodoApplicationKt {
  + main(String[]) Unit
}

%% =======================
%% Controller Layer
%% =======================
class ToDoController {
  + ToDoController(ToDoRepository)
  + create(ToDo) ToDo
  + completeTask() List~ToDo~
  + pendingTask() List~ToDo~
  + patch(Long, ToDoPatch) ToDo
  + delete(Long) Unit
  + deleteAll() String
  + deleteById(ToDoBulkDelete) String
  ---
  List~ToDo~ all
  List~ToDo~ sortedTodos
}

%% =======================
%% Repository Layer
%% =======================
class ToDoRepository {
  &amp;#x3C;&amp;#x3C;interface&gt;&gt;
  + completedTask() List~ToDo~
  + sortAllByDateAndTime() List~ToDo~
  + bulkDeleteById(List~Long~) Int
  + pendingTask() List~ToDo~
  + deleteAllTodos() Int
}

%% =======================
%% Data / DTOs
%% =======================
class ToDo {
  + ToDo(Long, String, LocalDate, LocalTime?, Boolean, LocalDate?)
  ---
  LocalDate date
  LocalTime? time
  String title
  LocalDate? completedDate
  Long id
  Boolean completed
}

class ToDoBulkDelete {
  + ToDoBulkDelete(List~Long~)
  ---
  List~Long~ ids
}

class ToDoPatch {
  + ToDoPatch(LocalDate?, LocalTime?, String?, Boolean?)
  + ToDoPatch()
  ---
  LocalDate? date
  LocalTime? time
  String? title
  Boolean? completed
}

%% =======================
%% Relationships
%% =======================
ToDoController --&gt; ToDoRepository : uses
ToDoController --&gt; ToDoPatch : input
ToDoController --&gt; ToDoBulkDelete : input
ToDoController --&gt; ToDo : returns
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Project Structure&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;./structure.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h1&gt;Data Object Creation&lt;/h1&gt;
&lt;h2&gt;Object&lt;/h2&gt;
&lt;p&gt;A data class that contains the following task attributes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;id&lt;/strong&gt; — Auto-incrementing identifier&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;title&lt;/strong&gt; — Task name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;date&lt;/strong&gt; — Task due date&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;time&lt;/strong&gt; — Task due time (optional)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;completed&lt;/strong&gt; — Status (boolean: completed or not)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;completedDate&lt;/strong&gt; — Date when the task was completed&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;//ToDo.kt
-----------------------------------------------------------------------------------------
@jakarta.persistence.Entity
data class ToDo(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    val id: Long = 0,
    var title: String,
    @JsonFormat(pattern = &quot;yyyy-MM-dd&quot;)
    var date: java.time.LocalDate = java.time.LocalDate.now(), // Default due date is today
    @JsonFormat(pattern = &quot;HH:mm&quot;)
    var time : java.time.LocalTime? = null,
    var completed: Boolean = false,
    var completedDate: java.time.LocalDate? = null,
)
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Explanation:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@Entity&lt;/strong&gt; — Marks this class as a JPA entity, mapping it to a database table&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@Id&lt;/strong&gt; — Designates the primary key field&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@GeneratedValue&lt;/strong&gt; — Configures automatic ID generation using the database&apos;s identity column&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@JsonFormat&lt;/strong&gt; — Specifies the JSON serialization format for date and time fields&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Repository&lt;/h1&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;//ToDoRepository.kt
------------------------------------------------------------------------------------------
@Repository
interface ToDoRepository : JpaRepository&amp;#x3C;ToDo, Long&gt; {
    @Query(
        value = &quot;SELECT * FROM to_do ORDER BY date ASC, time ASC&quot;,
        nativeQuery = true
    )
    fun SortAllbyDateAndTime(): List&amp;#x3C;ToDo&gt;

    @Query(
        value = &quot;SELECT * FROM to_do WHERE completed=true ORDER BY date ASC, time ASC&quot;,
        nativeQuery = true
    )
    fun Completedtsk(): List&amp;#x3C;ToDo&gt;

    @Query(
        value = &quot;SELECT * FROM to_do WHERE completed=false ORDER BY date ASC, time ASC&quot;,
        nativeQuery = true
    )
    fun PendingTask(): List&amp;#x3C;ToDo&gt;

    @Modifying
    @Transactional
    @Query(
        value = &quot;DELETE FROM to_do&quot;,
        nativeQuery = true
    )
    fun deleteAllTodos() : Int

    @Modifying
    @Transactional
    @Query(
        value = &quot;DELETE FROM to_do WHERE id IN (:id)&quot;,
        nativeQuery = true
    )
    fun BulkDeleteById(id: List&amp;#x3C;Long&gt;) : Int
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Explanation:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;ToDoRepository&lt;/strong&gt; extends &lt;strong&gt;JpaRepository&lt;/strong&gt; — This inheritance grants automatic access to powerful CRUD operations including &lt;code&gt;findAll()&lt;/code&gt;, &lt;code&gt;save()&lt;/code&gt;, &lt;code&gt;delete()&lt;/code&gt;, &lt;code&gt;findById()&lt;/code&gt;, &lt;code&gt;count()&lt;/code&gt;, and many more without writing any implementation code&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JpaRepository&amp;#x3C;ToDo, Long&gt;&lt;/strong&gt; — Takes two generic type parameters: first is the entity class (&lt;code&gt;ToDo&lt;/code&gt;) you want to manage, and second is the data type of the entity&apos;s primary key (&lt;code&gt;Long&lt;/code&gt; in our case)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@Query&lt;/strong&gt; — Enables you to write custom native SQL queries or JPQL queries and bind them to repository method declarations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@Modifying&lt;/strong&gt; and &lt;strong&gt;@Transactional&lt;/strong&gt; — Required pair of annotations for any query that performs INSERT, UPDATE, or DELETE operations to ensure proper transaction management and data consistency&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;REST Controller&lt;/h1&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;
//ToDocontroller.kt
--------------------------------------------------------------------------------------------
@RestController
@CrossOrigin(origins = [&quot;*&quot;])
@RequestMapping(&quot;/&quot;)
class ToDoController(private val repo : ToDoRepository) {

    @GetMapping
    fun getAll() : List&amp;#x3C;ToDo&gt; = repo.findAll()

    @PostMapping
    fun create(@RequestBody toDo: ToDo): ToDo {
        return repo.save(toDo)
    }


    @PatchMapping(&quot;/{id}&quot;)
    fun patch(@PathVariable id: Long, @RequestBody body: ToDoPatch): ToDo {
    val todo = repo.findById(id).orElseThrow()

    body.title?.let { todo.title = it }
    body.date?.let { todo.date = it }
    body.time?.let { todo.time = it }

    body.completed?.let { newValue -&gt;
        if (!todo.completed &amp;#x26;&amp;#x26; newValue) todo.completedDate = LocalDate.now()
        if (todo.completed &amp;#x26;&amp;#x26; !newValue) todo.completedDate = null
        todo.completed = newValue
    }

    return repo.save(todo)
}

    @DeleteMapping(&quot;/{id}&quot;)
    fun delete(@PathVariable id: Long) {
        repo.deleteById(id)
    }

    // Get all todos sorted by date and time
    @GetMapping(&quot;/bytime&quot;)
    fun getSortedTodos() : List&amp;#x3C;ToDo&gt; = repo.SortAllbyDateAndTime()

    // Get todos grouped by status (incomplete first, then completed)
    @GetMapping(&quot;/completed&quot;)
    fun completeTask() : List&amp;#x3C;ToDo&gt; = repo.Completedtsk()

    @GetMapping(&quot;/pending&quot;)
    fun pendingTask() : List&amp;#x3C;ToDo&gt; = repo.PendingTask()

    @DeleteMapping(&quot;/deleteall&quot;)
    fun deleteAll(): String {
        val deletecount = repo.deleteAllTodos()
        return &quot;$deletecount todos deleted&quot;
    }

    @DeleteMapping(&quot;/bulkdelete&quot;)
    fun deleteById(@RequestBody body: ToDoBulkDelete): String {
        val deleteCount = repo.BulkDeleteById(body.ids)
        return &quot;$deleteCount deleted&quot;
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Explanation:&lt;/h2&gt;
&lt;h3&gt;Class-Level Annotations:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@RestController&lt;/strong&gt; — Combines &lt;code&gt;@Controller&lt;/code&gt; and &lt;code&gt;@ResponseBody&lt;/code&gt;, indicating this class handles HTTP requests and returns JSON responses automatically&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@CrossOrigin&lt;/strong&gt; — Enables Cross-Origin Resource Sharing (CORS), allowing requests from any origin (use specific origins in production)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@RequestMapping(&quot;/&quot;)&lt;/strong&gt; — Sets the base URL path for all endpoints in this controller (root path in this case)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;HTTP Method Annotations:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@GetMapping&lt;/strong&gt; — Handles HTTP GET requests (retrieve data)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@PostMapping&lt;/strong&gt; — Handles HTTP POST requests (create new resources)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@PatchMapping&lt;/strong&gt; — Handles HTTP PATCH requests (partial updates)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@DeleteMapping&lt;/strong&gt; — Handles HTTP DELETE requests (remove resources)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Parameter Annotations:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@PathVariable&lt;/strong&gt; — Extracts values from the URL path (e.g., &lt;code&gt;/delete/5&lt;/code&gt; → &lt;code&gt;id = 5&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;@RequestBody&lt;/strong&gt; — Maps the HTTP request body (JSON) to a Kotlin object automatically&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Endpoint Breakdown:&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;getAll()&lt;/strong&gt; — Returns all todos using the built-in &lt;code&gt;findAll()&lt;/code&gt; method&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;create()&lt;/strong&gt; — Accepts a &lt;code&gt;ToDo&lt;/code&gt; object and saves it to the database&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;patch()&lt;/strong&gt; — Updates specific fields of an existing todo; uses Kotlin&apos;s &lt;code&gt;?.let&lt;/code&gt; to update only non-null fields&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;delete()&lt;/strong&gt; — Removes a single todo by ID&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;getSortedTodos()&lt;/strong&gt; — Returns todos ordered by date and time&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;completeTask() / pendingTask()&lt;/strong&gt; — Filters todos by completion status&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;deleteAll()&lt;/strong&gt; — Removes all todos and returns the count&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;deleteById()&lt;/strong&gt; — Bulk deletion of multiple todos by their IDs&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;DTO (Data Transfer Object)&lt;/h1&gt;
&lt;h2&gt;Explanation&lt;/h2&gt;
&lt;p&gt;DTOs are lightweight data structures that transfer specific data between client and server without exposing the entire entity. They enable &lt;strong&gt;partial updates&lt;/strong&gt; (sending only fields to modify), &lt;strong&gt;controlled data exposure&lt;/strong&gt; (hiding sensitive fields), and &lt;strong&gt;security&lt;/strong&gt; (preventing modification of immutable fields like &lt;code&gt;id&lt;/code&gt;). Each operation can have its own DTO, making the API clearer and more flexible.&lt;/p&gt;
&lt;h3&gt;DTO Implementations:&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;ToDoPatch&lt;/strong&gt; — Used for partial updates via PATCH requests. All fields are nullable, allowing clients to update only the fields they specify:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;data class ToDoPatch(
    val date: LocalDate? = null,
    val time: LocalTime? = null,
    val title: String? = null,
    val completed: Boolean? = null
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;ToDoBulkDelete&lt;/strong&gt; — Used for bulk deletion operations, accepting a list of IDs to delete multiple todos in a single request:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;data class ToDoBulkDelete(
    val ids: List&amp;#x3C;Long&gt;
)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By using these DTOs, the API remains flexible, secure, and easy to understand for developers consuming it.&lt;/p&gt;
&lt;h1&gt;Application Configuration&lt;/h1&gt;
&lt;h2&gt;application.properties&lt;/h2&gt;
&lt;p&gt;Configure your Spring Boot application by creating or editing the &lt;code&gt;application.properties&lt;/code&gt; file in the &lt;code&gt;src/main/resources&lt;/code&gt; directory:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;# Application name
spring.application.name=todo

# Server port (default is 8080)
server.port=8080

# H2 Database configuration - File-based for data persistence
# Data persists even after server restart in ./data/todo-db directory
spring.datasource.url=jdbc:h2:file:./data/todo-db;AUTO_SERVER=TRUE;DB_CLOSE_DELAY=-1

# Database credentials (empty for H2 default)
spring.datasource.username=
spring.datasource.password=

# Database driver
spring.datasource.driver-class-name=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect

# JPA/Hibernate configuration
# &apos;update&apos; automatically creates/updates tables based on entity classes
spring.jpa.hibernate.ddl-auto=update

# Enable SQL query logging in console (useful for debugging)
spring.jpa.show-sql=true

# H2 Web Console configuration
# Access at: http://localhost:8080/h2
spring.h2.console.enabled=true
spring.h2.console.path=/h2
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Key Configuration Explained:&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;server.port&lt;/strong&gt; — Defines which port the application runs on (default: 8080)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;spring.datasource.url&lt;/strong&gt; — Uses file-based H2 database for persistence; data survives server restarts&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;spring.jpa.hibernate.ddl-auto=update&lt;/strong&gt; — Automatically creates or updates database schema based on entity classes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;spring.h2.console.enabled=true&lt;/strong&gt; — Enables web-based database console for direct SQL queries and table inspection&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;spring.jpa.show-sql=true&lt;/strong&gt; — Logs all SQL statements to console, helpful for learning and debugging&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Running Your Application&lt;/h1&gt;
&lt;h2&gt;Start the Application&lt;/h2&gt;
&lt;p&gt;There are multiple ways to run your Spring Boot application:&lt;/p&gt;
&lt;h3&gt;Method 1: Using IDE (Recommended for Beginners)&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Locate the main application file (usually named &lt;code&gt;TodoApplication.kt&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Look for the &lt;code&gt;main()&lt;/code&gt; function with &lt;code&gt;@SpringBootApplication&lt;/code&gt; annotation&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click the green &lt;strong&gt;Run&lt;/strong&gt; button (▶️) next to the main function or class name&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Alternatively, right-click on the file and select &lt;strong&gt;Run &apos;TodoApplicationKt&apos;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/ls-prabhu/taskbackend/refs/heads/master/images/img.png&quot; alt=&quot;Running the application&quot;&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;Method 2: Using Gradle (Command Line)&lt;/h3&gt;
&lt;p&gt;Open the terminal in your project root directory and run:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;./gradlew bootRun
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For Windows:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-bash&quot;&gt;gradlew.bat bootRun
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Method 3: Using the Gradle Task Panel&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open the &lt;strong&gt;Gradle&lt;/strong&gt; panel on the right side of your IDE&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Navigate to &lt;strong&gt;Tasks → application&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Double-click on &lt;strong&gt;bootRun&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;Verify the Application is Running&lt;/h2&gt;
&lt;p&gt;Once the application starts, you should see console output similar to this:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-kotlin&quot;&gt;Tomcat started on port(s): 8080 (http)
Started TodoApplicationKt in X.XXX seconds
&lt;/code&gt;&lt;/pre&gt;
&lt;h3&gt;Quick Health Check&lt;/h3&gt;
&lt;p&gt;Open your browser and navigate to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;API Base URL:&lt;/strong&gt; &lt;code&gt;http://localhost:8080/&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;H2 Console:&lt;/strong&gt; &lt;code&gt;http://localhost:8080/h2&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If you see a JSON response (likely an empty array &lt;code&gt;[]&lt;/code&gt;) at the base URL, your application is running successfully!&lt;/p&gt;
&lt;h2&gt;Accessing the H2 Database Console&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open your browser and go to &lt;code&gt;http://localhost:8080/h2&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Enter the following connection details:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;JDBC URL:&lt;/strong&gt; &lt;code&gt;jdbc:h2:file:./data/todo-db&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Name:&lt;/strong&gt; (leave empty)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Password:&lt;/strong&gt; (leave empty)&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click &lt;strong&gt;Connect&lt;/strong&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can now run SQL queries directly to view your &lt;code&gt;TO_DO&lt;/code&gt; table and inspect the data.&lt;/p&gt;
&lt;h2&gt;Stopping the Application&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;In IDE:&lt;/strong&gt; Click the red &lt;strong&gt;Stop&lt;/strong&gt; button **** in the Run panel&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;In Terminal:&lt;/strong&gt; Press &lt;code&gt;Ctrl + C&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Testing Your API&lt;/h1&gt;
&lt;p&gt;Now that your application is running, let&apos;s test all the endpoints using Postman or Bruno. Make sure your server is running on &lt;code&gt;http://localhost:8080&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;1. Create a Todo (POST)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;POST http://localhost:8080/&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/ls-prabhu/taskbackend/refs/heads/master/images/postreq.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2&gt;2. Get All Todos (GET)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;GET http://localhost:8080/&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Expected Response (200 OK):&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://raw.githubusercontent.com/ls-prabhu/taskbackend/refs/heads/master/images/getreq.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2&gt;3. Get Todos Sorted by Date and Time (GET)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;GET http://localhost:8080/bytime&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Returns all todos ordered by date and time (earliest first).&lt;/p&gt;
&lt;h2&gt;4. Get Pending Todos (GET)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;GET http://localhost:8080/pending&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Returns only incomplete todos (&lt;code&gt;completed: false&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;5. Get Completed Todos (GET)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;GET http://localhost:8080/completed&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Returns only completed todos (&lt;code&gt;completed: true&lt;/code&gt;).&lt;/p&gt;
&lt;h2&gt;6. Update a Todo (PATCH)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;PATCH http://localhost:8080/1&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request Body (JSON):&lt;/strong&gt; &lt;em&gt;(Include only fields you want to update)&lt;/em&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;completed&quot;: true,
  &quot;title&quot;: &quot;Completed Spring Boot Tutorial&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Expected Response (200 OK):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;id&quot;: 1,
  &quot;title&quot;: &quot;Completed Spring Boot Tutorial&quot;,
  &quot;date&quot;: &quot;2025-12-01&quot;,
  &quot;time&quot;: &quot;14:30&quot;,
  &quot;completed&quot;: true,
  &quot;completedDate&quot;: &quot;2025-11-30&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;7. Delete a Single Todo (DELETE)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;DELETE http://localhost:8080/1&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Expected Response:&lt;/strong&gt; &lt;code&gt;200 OK&lt;/code&gt; (no content)&lt;/p&gt;
&lt;h2&gt;8. Bulk Delete Todos (DELETE)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;DELETE http://localhost:8080/bulkdelete&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Request Body (JSON):&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;ids&quot;: [1, 2, 3]
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Expected Response:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;&quot;3 deleted&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;9. Delete All Todos (DELETE)&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;Endpoint:&lt;/strong&gt; &lt;code&gt;DELETE http://localhost:8080/deleteall&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Expected Response:&lt;/strong&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;&quot;5 todos deleted&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Testing Tips&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Test in Order:&lt;/strong&gt; Start with POST to create data, then test GET, PATCH, and DELETE operations&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check H2 Console:&lt;/strong&gt; After each operation, verify changes in the database console (&lt;code&gt;http://localhost:8080/h2&lt;/code&gt;)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;View Logs:&lt;/strong&gt; Watch the console for SQL queries if &lt;code&gt;spring.jpa.show-sql=true&lt;/code&gt; is enabled&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use Collections:&lt;/strong&gt; In Postman/Bruno, organize these requests in a collection for easy testing&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h1&gt;Next Steps &amp;#x26; Improvements&lt;/h1&gt;
&lt;p&gt;Congratulations on building your first Spring Boot REST API! Here are ways to take it further:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Input Validation&lt;/strong&gt; — Add &lt;code&gt;@NotBlank&lt;/code&gt;, &lt;code&gt;@Size&lt;/code&gt;, and &lt;code&gt;@Valid&lt;/code&gt; annotations to ensure data integrity&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Error Handling&lt;/strong&gt; — Implement &lt;code&gt;@ControllerAdvice&lt;/code&gt; for global exception handling with proper HTTP status codes&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Production Database&lt;/strong&gt; — Migrate from H2 to PostgreSQL, MySQL or MongoDB for production use&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;User Management&lt;/strong&gt; — Add User entity with relationships to todos for multi-user support&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Security&lt;/strong&gt; — Add Spring Security with JWT authentication and role-based access control&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;API Documentation&lt;/strong&gt; — Integrate Swagger/OpenAPI for interactive API documentation&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;You&apos;ve successfully built a fully functional Spring Boot REST API with Kotlin! You learned to create entities, repositories, controllers, configure databases, and test endpoints.&lt;/p&gt;
&lt;p&gt;thanks for reading, if you have any suggestion don’t hesitate to &lt;a href=&quot;https://beacons.ai/prabhuls&quot;&gt;contact me&lt;/a&gt;.&lt;/p&gt;</content:encoded><enclosure url="/_astro/thumbnail.CMwtBNU-.webp" length="0" type="image/webp"/><author>dev@prabhuls.me (Prabhu L S)</author></item><item><title>A Better Way to Access Your Home Network</title><link>https://prabhuls.me/blog/way-to-access-your-home-network</link><guid isPermaLink="true">https://prabhuls.me/blog/way-to-access-your-home-network</guid><description>Securely connect to your devices from anywhere without exposing ports or relying on public services.</description><pubDate>Thu, 14 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;h2&gt;What You Get&lt;/h2&gt;
&lt;p&gt;Before diving in, here&apos;s a quick summary of what this stack gives you:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;No ads or trackers&lt;/strong&gt;: blocks all ads and trackers at the DNS level across every devices even when you are not in home.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remote access to all devices&lt;/strong&gt;: reach any device or service privately from anywhere, without exposing anything to the public internet.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom DNS rewrites&lt;/strong&gt;: use clean local domains like &lt;code&gt;paperless.home&lt;/code&gt;, &lt;code&gt;grafana.lan&lt;/code&gt; or &lt;code&gt;router.local&lt;/code&gt; instead of raw IP:ports.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;How the Stack Fits Together&lt;/h2&gt;
&lt;p&gt;&lt;img src=&quot;./stack-fit.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tailscale&lt;/strong&gt; creates the encrypted tunnel that connects your devices securely.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AdGuard Home&lt;/strong&gt; handles DNS resolution, ad blocking, and custom domain rewrites.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Nginx Proxy Manager&lt;/strong&gt; routes incoming requests to the right service and issues SSL certificates automatically.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Together, they give you a clean, private network that works from anywhere — with no public exposure.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;1. Tailscale&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Tailscale is a mesh VPN built on the &lt;a href=&quot;https://www.wireguard.com/&quot;&gt;WireGuard&lt;/a&gt; protocol. It creates encrypted, peer-to-peer tunnels between your devices.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Unlike traditional VPNs that route all traffic through a central server, Tailscale connects devices directly to each other whenever possible, giving you low-latency, high-performance private networking.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Instead of exposing services directly to the internet or configuring complicated port forwarding rules, Tailscale allows devices to communicate securely over encrypted tunnels.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Why Use TailScale&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Remote Access&lt;/strong&gt;: Access your home network from anywhere without port forwarding or exposing services to the public internet&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Cross-Platform&lt;/strong&gt;: Works on Linux, Windows, macOS, iOS, and Android&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Tailnet&lt;/strong&gt;: Automatically creates a private network with all your devices&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;MagicDNS&lt;/strong&gt;: dedicated custom domain will be provided.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Global DNS Control&lt;/strong&gt;: Set a single DNS server for all connected devices. Point it to &lt;strong&gt;our AdGuard Home&lt;/strong&gt; and every device instantly gets ad blocking and custom domains.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&quot;./tailscale.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Use Case: Private Access to Self-Hosted Services&lt;/h3&gt;
&lt;p&gt;Instead of exposing apps to the public internet using services like ngrok or Cloudflare Tunnel:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;# Public (exposed, risky)
https://myserver.example.com
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can access them privately through Tailscale:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;# Via Tailscale IP
http://100.x.x.x:8080

# Via MagicDNS hostname
http://devicename.tailnet-name.ts.net:8080

# Via custom domain (with AdGuard + NPM — covered below)
http://plex.home
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This dramatically reduces your attack surface while keeping everything accessible from your phone, laptop, or any other enrolled device — anywhere in the world.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;2. Adgaurd Home&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;AdGuard Home&lt;/strong&gt; is a network-wide ad blocker and DNS resolver. Rather than blocking ads in a browser, it blocks them at the DNS level meaning when any device on your network tries to resolve a tracker or ad domain, AdGuard simply returns nothing. The request never leaves your network.&lt;/p&gt;
&lt;h3&gt;Why Use AdGuard?&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reduce Telemetry&lt;/strong&gt;: Many devices (Windows, smart appliances) send telemetry data home. Block these at the DNS level to reduce data leakage.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Privacy Protection&lt;/strong&gt;: Block trackers across all devices (phones, laptops, smart TVs) by &lt;strong&gt;not using ISP&lt;/strong&gt; default resolvers.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;No Client Software&lt;/strong&gt;: Works at the DNS level — no installation needed on individual devices&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Custom Blocklists&lt;/strong&gt;: Add your own domains or use community blocklists&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Adult Content Filtering&lt;/strong&gt;: Family-safe DNS options&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Statistics&lt;/strong&gt;: See what domains are being queried on your network&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;DNS rewriting&lt;/strong&gt;: assign custom domain for rules.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;DNS Rewrites&lt;/h3&gt;
&lt;p&gt;This is what makes the whole stack elegant. In AdGuard Home, you can create DNS rewrite rules like:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-plaintext&quot;&gt;paperless.home  →  100.x.x.x   (your server&apos;s Tailscale IP)
grafana.home    →  100.x.x.x
portainer.home  →  100.x.x.x
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, when you type &lt;code&gt;https://paperless.home&lt;/code&gt; on any device connected to Tailscale (with AdGuard set as the DNS), it resolves to your server&apos;s private IP. NPM then handles routing that request to the right container.&lt;/p&gt;
&lt;hr&gt;
&lt;h2&gt;3. Nginx Proxy Manager(NPM)&lt;/h2&gt;
&lt;p&gt;Nginx Proxy Manager provides a clean web UI for managing Nginx reverse proxy configurations. Instead of writing Nginx config files by hand, you point and click NPM handles SSL certificates, redirects, and proxy rules automatically.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;./nginx-proxy.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3&gt;How It Works with the Stack&lt;/h3&gt;
&lt;p&gt;NPM sits between AdGuard and your actual services. When a request arrives for &lt;code&gt;paperless.home&lt;/code&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;AdGuard resolves &lt;code&gt;paperless.home&lt;/code&gt; → your server&apos;s Tailscale IP.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The request hits NPM on port 80(http)/443(https).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;NPM reads the hostname, finds the matching proxy host, and forwards the request to the right Docker container (e.g., &lt;code&gt;paperless-ngx:8000&lt;/code&gt;).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;NPM handles the SSL termination, so your browser gets a valid HTTPS connection.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;p&gt;To build this setup, all you really need is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;A Linux machine (old PC, mini PC, or VPS)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Docker&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A bit of patience&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;And honestly… ChatGPT helps a lot.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded><enclosure url="/_astro/pasted-image-20260717120702.Cy1UYHh9.png" length="0" type="image/png"/><author>dev@prabhuls.me (Prabhu L S)</author></item></channel></rss>