Foundation · Prepare

The Spring Boot Journey

Follow one Task API through Modules 0–19 and choose the first outcome you cannot prove.

Primary source: Spring Framework Portfolio Overview

20 min

Lesson 1 of 7

1d streak

The Architectural Question

Jumping straight to Kafka or Kubernetes without container, transaction, and security groundwork turns every incident into guesswork about which layer broke.

What this guide proves

  • Course Structure
  • Dependency Graph
  • Learning Path

The 4-layer backend architecture

Many developers fail when adopting Spring Boot because they jump directly into magic annotations without understanding what those annotations actually replace. Spring Boot is not a programming language; it is an opinionated assembly and configuration framework built on top of four foundational layers.

Architectural Boundary · Do Not Confuse

Concept A

Framework Magic (Blind Annotation Stacking)

Concept B

Layered Competence (Explicit Responsibility)

Blindly stacking @RestController, @Service, and @Transactional without understanding JVM objects, HTTP sockets, and database transactions leaves you helpless during production outages. Real mastery means naming the exact low-level responsibility that each annotation automates.

To build a mental model that lasts, this course anchors every concept to one continuously evolving service: the Task Management API. In Module 0, you write pure Java objects, craft raw HTTP requests, and execute raw SQL statements against PostgreSQL. Later modules introduce Spring Framework concepts such as IoC and beans, then Spring Boot automates configuration around them. Module 0 is only a map of what is ahead; the actual container mechanics begin in Module 2, after the learner has seen one minimal Boot application.

backend-four-layer-model.txt
┌─────────────────────────────────────────────────────────────┐
│ LAYER 4: PERSISTENCE & STORAGE (PostgreSQL, ACID, WAL)       │
├─────────────────────────────────────────────────────────────┤
│ LAYER 3: APPLICATION ASSEMBLY (Spring Boot IoC, Beans, AOP)  │
├─────────────────────────────────────────────────────────────┤
│ LAYER 2: NETWORK & PROTOCOL (TCP Sockets, HTTP/1.1 & HTTP/2) │
├─────────────────────────────────────────────────────────────┤
│ LAYER 1: LANGUAGE RUNTIME (Java 21 LTS, Records, Virtual Th) │
└─────────────────────────────────────────────────────────────┘

Architecture is a map of boundaries, not a rigid checklist

Not every request requires a controller, service, repository, and database table. A health probe returns directly from memory; an event handler consumes from a message broker. Layers exist to isolate distinct reasons for change.

The curriculum as a dependency graph

The 20 modules in this course are structured as an architectural dependency graph. Each mechanism builds on a verified prerequisite. Skipping foundations shifts hidden gaps into frustrating debugging sessions later.

PhaseFocus ModulesArchitectural OutcomeObservable Evidence
1. PrepareModule 0 & Core JavaJava 21, Maven, TCP, HTTP, SQL foundationsA reproducible local toolchain and plain-Java object graph without frameworks.
2. UnderstandModules 1 & 2Spring IoC container and lifecycle; Boot auto-configuration followsTrace exact bean wiring, condition evaluation, and component scanning.
3. BuildModules 3, 4, 5, 6REST APIs, Validation, Spring Data JPA, ArchUnitA tested CRUD API with Flyway migrations and durable PostgreSQL state.
4. HardenModules 7, 8, 9, 10Externalized Config, Structured Logs, Spring Security, TestcontainersJWT authentication, RBAC, slice tests, and controlled failure handling.
5. ScaleModules 11, 12, 13, 14, 15Redis Caching, RabbitMQ/Kafka, Microservices, ResiliencyOutbox pattern, circuit breakers, rate limiting, and distributed tracing.
6. DeliverModules 16, 17, 18, 19Actuator, GraalVM Native, Docker, K8s, Cloud-NativeImmutable container images, Prometheus metrics, and production readiness.

The 5-stage mastery cycle

Passive reading does not produce production competence. Every lesson in this course enforces a deliberate five-stage technical cycle:

mastery-cycle.txt
1. CONCEPT   → Define the architectural problem and mental model.
2. TRACE     → Follow the runtime execution path step-by-step.
3. BUILD     → Review verified Java 21 / Spring Boot code.
4. BREAK     → Intentionally inject a failure condition and observe the diagnostic error.
5. RECALL    → Answer active recall questions to reinforce neural pathways.

Active Recall Checkpoint

A test passes after you copied a snippet, but you cannot explain what happens when the network fails. Is the lesson complete?

Hint: Always execute the deliberate failure lab before moving to the next lesson.

Show answer & explanation

No. The green test proves execution, not understanding. True mastery requires knowing how the component fails, what error message it emits, and how to recover.

Break it deliberately: The illusion of competence

The most dangerous state for a junior backend engineer is the "Happy Path Trap"—assuming that code that compiles and responds with 200 OK is production-ready.

The Happy Path Trap

Real production systems spend 80% of their lifecycle handling edge cases: deadlocks, partial network failures, malformed JSON, out-of-memory errors, and broken database connections.

In this course, every single lesson contains a Deliberate Failure Lab. You will purposely misconfigure properties, induce circular dependencies, exhaust connection pools, produce N+1 queries, and break cryptographic signatures. When you see the actual stack trace in a controlled sandbox, production errors lose their mystery.

Use it when

Adopt this course if you want deep, reproducible backend engineering competence backed by tests, metrics, and failure diagnostics.

Reconsider when

Reconsider if you only want quick copy-paste code snippets without understanding runtime internals or failure boundaries.

Readiness assessment & entry point

Beginners should complete Module 0 in sequential order. Experienced developers may use the acceptance criteria of each lesson as a test-out gate:

If you can already construct an immutable domain model using Java 21 records, configure Maven build plugins without IDE assistance, inspect raw HTTP/1.1 message frames, and reproduce a concurrent transaction race condition in PostgreSQL, you may proceed directly to Module 2: Spring from First Principles.

Active Recall Checkpoint

Where should you begin if you are comfortable with Java syntax but unfamiliar with database transactions?

Hint: Identify your earliest unproven boundary and start there.

Show answer & explanation

Begin at Lesson 0.7 (SQL & Transactions) to master ACID guarantees, constraints, and isolation levels before diving into Spring Data JPA.

Runtime Architecture & Flow

Structure under inspection

The Spring Boot Journey

Part 1

Course Structure

Part 2

Dependency Graph

Part 3

Learning Path

The connectors show containment and responsibility—not time or call order.

Guided Hands-On Lab

Code Walkthrough

Read the roadmap flowchart and mark the first module whose outcome you cannot already demonstrate.

RoadmapArchitectureLab.java
public class RoadmapArchitectureLab {
    // Layer 1: Language Runtime (Java 21 records & domain immutability)
    enum TaskStatus { OPEN, COMPLETED }
    record Task(long id, String title, TaskStatus status) {}

    // Layer 4: Storage Contract (Plain Java interface for persistence boundary)
    interface TaskStore {
        Task findById(long id);
        Task save(Task task);
    }

    // Layer 3: Application Assembly (Explicit constructor dependency wiring)
    static final class TaskApp {
        private final TaskStore store;
        TaskApp(TaskStore store) { this.store = store; }

        Task completeTask(long id) {
            Task current = store.findById(id);
            System.out.println("[Layer 3: Assembly] TaskApp delegating to TaskStore");
            return store.save(new Task(current.id(), current.title(), TaskStatus.COMPLETED));
        }
    }

    // Layer 2: Network / Protocol simulation (Raw request/response mapping)
    static String handleRequest(String method, String path, TaskApp app) {
        System.out.println("[Layer 2: HTTP] Dispatching " + method + " " + path);
        if ("POST".equals(method) && path.startsWith("/tasks/")) {
            long id = Long.parseLong(path.substring("/tasks/".length()).replace("/complete", ""));
            Task completed = app.completeTask(id);
            return "HTTP/1.1 200 OK\r\nContent-Type: application/json\r\n\r\n" +
                          "{\"id\":" + completed.id() + ",\"status\":\"" + completed.status() + "\"}";
        }
        return "HTTP/1.1 404 Not Found\r\n\r\n";
    }

    public static void main(String[] args) {
        TaskStore inMemoryStore = new TaskStore() {
            public Task findById(long id) {
                System.out.println("[Layer 4: Storage] TaskStore found task: " + id + " (Read Module 0)");
                return new Task(id, "Read Module 0", TaskStatus.OPEN);
            }
            public Task save(Task task) { return task; }
        };

        TaskApp app = new TaskApp(inMemoryStore);
        String response = handleRequest("POST", "/tasks/42/complete", app);
        System.out.println("[Outcome]\n" + response.trim());
    }
}
The 4-layer model separates runtime language types, protocol decoding, dependency assembly, and persistent storage.
Spring Boot does not alter Java execution semantics; it automates container wiring (Layer 3), HTTP servlet routing (Layer 2), and persistence transaction management (Layer 4).
The curriculum evolves this exact Task API from plain Java into a containerized, secured, and observable service.
Guided LabBuild & Verify Step by Step

A clean directory, JDK 21 LTS installed, and RoadmapArchitectureLab.java. No third-party libraries or frameworks required.

  1. 01

    Trace the 4-layer architecture

    Compile and execute RoadmapArchitectureLab.java to observe how raw HTTP, application assembly, domain records, and storage contracts connect.

    Check: The terminal prints output across all 4 architectural boundaries ending with HTTP 200 OK.

  2. 02

    Map manual responsibilities to Spring Boot

    Identify which Spring Boot starter replaces each manual layer: spring-boot-starter-web for Layer 2, Spring Core IoC for Layer 3, and spring-boot-starter-data-jpa for Layer 4.

    Check: You can name the specific Spring component that automates each plain Java responsibility.

  3. 03

    Simulate an unhandled boundary failure

    Throw a RuntimeException from inside TaskStore and observe how an unhandled storage defect bubbles up to the caller.

    Check: You can explain why centralized error handling (ControllerAdvice) is needed to prevent 500 error leaks.

Command

javac --release 21 RoadmapArchitectureLab.java
java RoadmapArchitectureLab

Expected Output

[Layer 2: HTTP] Dispatching POST /tasks/42/complete
[Layer 3: Assembly] TaskApp delegating to TaskStore
[Layer 4: Storage] TaskStore found task: 42 (Read Module 0)
[Outcome]
HTTP/1.1 200 OK
Content-Type: application/json

{"id":42,"status":"COMPLETED"}
Simulated terminal replay — matched to lesson verificationJDK 21 / Maven 3.9
spring-boot-lab@localhost:~
$javac --release 21 RoadmapArchitectureLab.java java RoadmapArchitectureLab#failingCondition
[INFO] Scanning for projects...
[INFO] -------------------< com.example:order-service >-------------------
[INFO] Building order-service 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-surefire-plugin:3.2.5:test (default-test) @ order-service ---
[INFO] Running com.example.OrderServiceTest
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.284 s <<< FAILURE! -- in com.example.OrderServiceTest
[ERROR] com.example.OrderServiceTest.testOrderCreation -- Time elapsed: 0.041 s <<< ERROR!
java.lang.NullPointerException: Cannot invoke "com.example.OrderRepository.save(Object)" because "this.repository" is null
	at com.example.OrderService.createOrder(OrderService.java:18)
	at com.example.OrderServiceTest.testOrderCreation(OrderServiceTest.java:24)

[INFO] Results:
[INFO]
[ERROR] Errors:
[ERROR]   OrderServiceTest.testOrderCreation:24 » NullPointer Cannot invoke "com.example...
[INFO]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:3.2.5:test on project order-service: There are test failures.
[ERROR] -> [Help 1]
[ERROR] BUILD FAILURE
Exit Code: 1
BUILD FAILURE

Synthesis & Production Verification

Production Acceptance Criteria

  • State what each module adds and which earlier module it depends on
  • Describe how the Task API grows from plain Java to an operated service

Architectural & Technical Review

Core Interview Questions

Q01Why is understanding the four architectural layers (Language Runtime, Network/Protocol, Application Assembly, Persistence) critical before using Spring Boot annotations?Show answer

Spring Boot annotations are opinions and automation applied over foundational layers. Annotations like @RestController, @Service, and @Transactional automate socket handling, bean wiring, and JDBC transactions. Without understanding the underlying JVM memory, TCP/HTTP protocols, and ACID database boundaries, developers cannot diagnose production failures such as socket exhaustion, proxy bypass, or unexpected transaction rollbacks.

Q02Why does the curriculum enforce deliberate failure drills before considering a concept mastered?Show answer

Relying solely on green "happy path" tests creates an illusion of competence. Production systems spend most of their lifecycle coping with edge cases: connection pool starvation, proxy bypass, circular dependencies, serialization errors, and deadlocks. Reproducing deliberate failures under controlled conditions teaches the diagnostic symptoms, log signatures, and recovery mechanisms needed during real outages.

Q03How does structuring backend learning as an architectural dependency graph prevent knowledge gaps?Show answer

Each backend tier relies on guarantees from the tier below it. For example, understanding Spring Data JPA requires understanding raw SQL transactions and connection pools; understanding microservices and event streaming requires understanding transactional outboxes and HTTP boundaries. Skipping prerequisite layers transforms predictable framework mechanics into guesswork when unexpected behaviors arise.

Production Pitfalls

Critical Anti-Patterns

  • Pitfall: Jumping straight to Kafka or Kubernetes — Distributed tools amplify whatever foundation exists. Missing transaction, probe, and security groundwork turns every incident into guesswork.
  • Pitfall: Learning features in isolation — Features only make sense relative to the flow they join. Always connect new material to the Controller → Service → Repository model.
  • Pitfall: Reading without completing failure exercises — Recognition feels like knowledge but collapses under pressure. The deliberate-failure drills are what convert reading into skill.

Primary Documentation & Specifications