Spring Boot Architecture — Spring Technical Interview Questions & Answers

Presentation, business, persistence and database layers.

Spring Boot Architecture

  • A typical Boot app is split into layers so code stays clean.
  • Controller / presentation: Receives HTTP requests and returns responses.
  • Service / business: Contains rules and use-cases (the real logic).
  • Repository / persistence: Talks to the database.
  • Database: Stores data (MySQL, PostgreSQL, H2, etc.).
  • Flow: Request → Controller → Service → Repository → DB → back with a response.
  • Putting SQL and business rules inside the controller.
  • Describe the 3–4 layers and one responsibility each.

Technical Interview Tip: Draw request flow across layers in 10 seconds.

Code Examples for Spring Boot Architecture

Spring Boot Architecture — working example

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication // config + auto-config + component scan
public class DemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }
}

@RestController
class HelloController {
  @GetMapping("/api/hello")
  String hello() {
    return "Hello Spring Boot";
  }
}

Spring Boot Architecture — spring Boot is opinionated Spring: starters + auto-configuration + embedded server for fast apps.

How to Explain Spring Boot Architecture to an Interviewer

What is Boot Architecture (sb)?

Used for a short Boot Architecture sb example a small REST app Not just the heading

Give one small example of Boot Architecture (sb).

the smallest Boot Architecture sb example you can type Presentation, business, persistence and database layers

What mistake do beginners make with Boot Architecture (sb)?

only saying “Boot Architecture sb” with no example Show the fix

Where do you use Boot Architecture (sb)?

a small REST app a short Boot Architecture sb example