liveBook · Manning

Chapter 2: Building a legacy modernization framework powered by Vibe Engineering

What you will learn in chapter 2 of Vibe Engineering

The chapter introduces LLM-assisted legacy migration as a way to recover knowledge from unfamiliar code and make understandable, incremental changes.

After this chapter you will be able to

Section by section

Introduction

The chapter introduces LLM-assisted legacy migration as a way to recover knowledge from unfamiliar code and make understandable, incremental changes.

Key terms: legacy applications, knowledge, LLMs, implicit knowledge, small incremental steps, size of the increment, human ability to understand and reason

2.1 Context and application

The section sets up an end-to-end legacy application migration, explains the chosen replacement technologies and AI tool modes, and recommends commits as checkpoints.

Key terms: kitchensink, JBoss, Spring (Boot), end-to-end (e2e), relational database, MongoDB, horizontal scaling, document-oriented data model, Spring Data MongoDB, Chat mode

2.2 Pre-analysis of the application

This section recommends starting legacy-application pre-analysis with an LLM-generated overview, then consulting documentation for specific details.

Key terms: README files, LLM, bigger picture, huge codebases, not entirely deterministic, prompt, similar

2.2.1 Extracting the bigger picture

This section uses an indexed project and broad LLM prompts to establish the application’s purpose before mapping its architecture and features for migration.

Key terms: use case, business value, quickstart, member registration and management system, technology stack, architecture components, key features, JBoss, Jakarta, Spring

2.2.2 Visualizing with Mermaid

The section shows how an AI-generated Mermaid diagram can make an application's high-level architecture visible and useful for migration planning.

Key terms: Mermaid, high-level architecture, version control, migration framework

2.2.3 Deployment models

The section identifies the application's deployment options, chooses JBoss as the migration focus, and points to existing instructions for running the application.

Key terms: non-functional aspects, JBoss EAP, OpenShift, Helm charts, Maven profiles, README, deployment steps, LLM

2.2.4 Decisions and assumptions

This section sets the assumptions that define what the legacy application migration must preserve and what it can leave out.

Key terms: gradually, swapped, backward compatibility, same functionalities, UI style, same functionality, QA/UX, containerized deployment model, specific port, Kubernetes

2.3 Trade-offs: copying the code in place vs a new repo

The section compares starting a new repository with migrating in place and identifies the trade-offs that motivate a hybrid approach.

Key terms: new repository, in-place migration, git history, legacy configuration

2.3.1 A hybrid approach

The section explains why the modernization uses a separate repository containing a copy of the legacy source code, then gives the initial setup steps for that workspace.

Key terms: hybrid approach, new repository, sandbox, AI-assisted refactoring, legacy repository infrastructure, Git metadata, CI/CD workflows, new branch, separate repository, cp -R

2.3.2 Procedure for code increments

The section establishes a Git workflow for preserving the legacy application, reviewing AI-generated changes, and recording migration work as logical increments.

Key terms: git origin, master, migration branch, JBoss legacy version, Cursor, Plan Mode, Composer, unified diff, conventional commit message, migration step

2.4 Testing

The section establishes testing as a safeguard before legacy-code migration and notes that LLM tools can help fill gaps in the test suite.

Key terms: unit tests, integration tests, e2e tests, performance tests, LLM tools

2.4.1 Generate missing tests

This section shows how to fill test gaps before migrating legacy code, verify the AI-generated tests, and retain a REST-based integration test when changing backends.

Key terms: unit/integration tests, UI tests, REST and data layers, AI-generated, false positives, fail-fast, RemoteMemberRegistrationIT, JBoss agnostic, REST, Spring backend

2.4.2 Migrate tightly coupled tests from the old framework

This section shows how to identify and migrate integration tests tied to a legacy framework while removing redundant tests and adopting Spring Boot-compatible test infrastructure.

Key terms: integration tests, tight coupling, legacy JBoss, ITs, JPA/Hibernate/SQL, Spring Boot, MongoDB, JUnit 5, junit-jupiter-engine

2.4.3 Mistake of missing steps in the process

An overlooked legacy import in a migrated test shows why each migration step needs review, a targeted correction, and test verification before production-code migration.

Key terms: legacy library, legacy dependencies, isolated step, JBoss-related libraries, package imports, Jupiter (Junit 5), more context

2.5 Production code migration trade-offs

The section explains how to size AI-assisted production-code migration increments to balance automation payoff against human review risk.

Key terms: change-set size, AI payoff, human review, balanced range

2.5.1 Applying a minimal set of changes

This section applies a minimal Spring Boot and Java 21 migration, shows why related application layers must change together, and checks that the resulting application starts and passes its tests.

Key terms: minimal set of changes, over-engineering, Spring Boot, Java 21, KitchensinkApplication, spring-boot-starter-data-jpa, MemberResourceRESTService, ApplicationEventPublisher, event service, mvn spring-boot:run

2.6 Cleanup stage

The section shows how to clean up obsolete JBoss artifacts during an incomplete migration and explains the test-based judgment used to move on.

Key terms: JBoss, cleanup stage, dependencies, configuration files, test coverage, tests, UI layer

2.7 UI layer migration

The section starts the UI and controller migration, explains how to reset AI chat context between steps, and shows why the resulting UI still needs human comparison with the legacy application.

Key terms: UI migration, controller/UI part, manual testing, let’s clean the context, New Chat, conversational chat history, persistent file, core guardrails, MemberController, template engine

2.7.1 Taking a step back when AI tools did too much

The section shows how to correct an AI tool that changed too much during UI migration while retaining a useful compatibility change it anticipated.

Key terms: UI, registered members, CSS changes, prompt, backward compatible, web URL, index.jsf

2.7.2 Trade-off between LLM inferring too much vs too little

Explains the trade-off between an LLM that requires detailed instructions and one that infers too much, and how prompts can help set the desired balance.

Key terms: context, over-engineering, backward compatibility, edge cases, precise prompts, explicit guidance, over-assume

2.7.3 Fixing bugs with AI tools

The section shows how QA findings and application logs can guide an AI tool to fix a post-migration UI bug, with tests and QA retesting confirming the result.

Key terms: Q/A, e2e testing, logs, Cursor IDE, unit tests, re-testing

2.8 Cleanup - the 2nd stage

This section uses a codebase search to check what remains of JBoss after an initial, high-level cleanup.

Key terms: grep, JBoss library, package names, static files

2.8.1 Mistake of overusing LLMs over static code refactoring tools

A failed AI-assisted package rename shows why language-aware IDE refactoring is preferable for changes that static analysis can fully determine.

Key terms: static analysis, IDE refactoring, package name, references, LLMs, static code analysis, refactoring tools, tokens

2.9 Adding documentation

The section shows how to use an AI tool to turn knowledge in a migrated application's code into a useful README.

Key terms: code, LLMs, documentation, README, build, run, endpoints, features, iterate

2.10 Migrating the persistence layer

This section separates production-code changes for a database migration from the runtime work of moving existing customer data.

Key terms: persistence layer, runtime, production code, migrating the data

2.10.1 Adding Mongo support

A prompt-driven MongoDB migration changes the application’s persistence layer, and the section explains why the AI tool handled this step well.

Key terms: MemberRepository, MongoDB, DataInitializer, repository test, open-source resources, Spring, code patterns, JBoss

2.10.2 Improving tests not to require a manual step

The section removes a manual MongoDB startup step from integration testing and documents the Docker requirement for running the revised tests.

Key terms: RemoteMemberRegistrationIT, MongoDBContainer, testcontainers framework, continuous delivery pipeline, README, Docker, integration tests, mvn

2.11 Conclude with merge pull requests

The section explains how to package a completed legacy migration for review, adjusting pull-request size to the project and combining human and AI review.

Key terms: migration branch, commit, pull request, migration step, human engineers, AI tool, review, legacy codebase

2.12 Summary

Where this is used later

Concepts explained in this chapter

← Chapter 1: Building on quicksand: the challenges of vibe engineering Chapter 3: Context fabric: optimizing context for AI agents →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.