跪拜 Guibai
← All articles
Full-Stack · Backend · Frontend

A Frontend Dev's First Map of a Spring Boot Project

By swipe ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Frontend developers are increasingly expected to read, debug, and even extend backend code, but Java project structure remains a foreign landscape. This walkthrough provides a direct translation layer—Controller equals route handler, Facade equals composable, Mapper equals ORM query builder—so a frontend engineer can navigate a real Spring Boot codebase without first memorizing the entire Java ecosystem.

Summary

Opening a Java backend project for the first time is disorienting: `pom.xml`, multi-module builds, and layers like Controller, Facade, DbService, and Mapper look like unnecessary ceremony. This walkthrough of a second-hand e-commerce learning project maps each backend concept directly onto familiar frontend equivalents—`pom.xml` as `package.json`, Controller as a server-side route handler, DTOs as runtime TypeScript interfaces, and Redis as a shared server-side cache rather than browser-local state.

The core lesson is a reading strategy: start from a single HTTP request, trace it from Controller through Facade to the database, and only expand outward from there. The project's `contract` module holds the API surface that both frontend and backend should care about; the `service` module contains the orchestration, caching, and persistence logic that the frontend never sees but must trust.

Several concrete mistakes are flagged—treating Redis as a database, trusting frontend validation alone, reading the most complex business logic first—along with the mindset shift that separates frontend work from backend work: the backend must guarantee correctness across all users, all requests, and all failure modes, not just the happy path visible in the browser.

Takeaways
Start reading any Spring Boot project from a single GET endpoint, not from the most complex business logic or the database schema.
`pom.xml` is the backend equivalent of `package.json`, but it also manages compilation, testing, and multi-module relationships.
Controller handles HTTP concerns only—parameter binding and response wrapping—and delegates all business rules to a Facade layer.
The `contract` module holds Request/Response DTOs and Facade interfaces; it is the API surface that frontend and backend share.
Redis is a performance cache in front of MySQL, not a database; the backend must decide whether to fail or degrade when Redis is unavailable.
Backend validation and database constraints are the only reliable guards—frontend form validation can always be bypassed by calling the API directly.
Follow the call chain Controller → Facade interface → Facade implementation → DbService/CacheService → Mapper → SQL to understand any feature.
Conclusions

The article's central insight is a reading strategy, not a technical trick: always start from a user action and follow the HTTP request downstream, asking only three questions at each unfamiliar concept—what problem does it solve, where is it in the project, and what would the frontend see if it broke.

Mapping backend layers to frontend equivalents (Controller = route handler, Facade = composable, Mapper = ORM) is an effective bridge, but the article is careful to flag where the analogy breaks—Java DTOs are runtime objects with validation behavior, not compile-time-only types.

The emphasis on failure modes (what happens when Redis is down, when a product is unlisted, when a payment callback arrives twice) is the real dividing line between frontend and backend thinking, and the article treats it as a skill to practice, not an afterthought.

Concepts & terms
Maven `pom.xml`
The Maven Project Object Model file, roughly equivalent to `package.json` in Node.js projects. It declares dependencies, build plugins, and in multi-module projects, defines parent-child module relationships. Unlike `package.json`, Maven also manages compilation, testing, and packaging steps.
Spring Boot Controller
A Java class annotated with `@RestController` that serves as the HTTP entry point for a set of related endpoints. It handles request parameter binding and response wrapping but should delegate business logic to a Facade or Service layer.
Facade layer
A business orchestration layer that sits between the Controller and data access code. It coordinates permissions checks, cache lookups, database queries, and response assembly. In this project, Facade interfaces live in the `contract` module while implementations live in `service`.
DTO (Data Transfer Object)
A plain Java object used to carry data between processes—specifically, Request DTOs bind incoming JSON to typed Java objects with validation, and Response DTOs define the shape of JSON returned to the client. Unlike TypeScript interfaces, DTOs exist at runtime and participate in serialization.
MyBatis-Plus Mapper
A data-access interface that provides CRUD operations on a database table without writing SQL. It maps database rows to Java Entity objects. In this project, each Mapper extends `BaseMapper<Entity>` to inherit standard query methods.
Redis fail-open degradation
A resilience pattern where a service continues to operate (possibly with reduced performance) when Redis is unavailable, rather than failing entirely. In this project, product detail requests fall back to querying MySQL directly when the Redis cache is down.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗