Backend Development 17 min read

Designing a Modular Backend Architecture with Spring Boot: A Case Study of the XiaoLe Project

This article presents a comprehensive Spring Boot backend architecture for the XiaoLe project, detailing design principles, a ten‑module Maven structure, key pom configurations, and the rationale for using Maven import to manage dependencies.

Top Architect
Top Architect
Top Architect
Designing a Modular Backend Architecture with Spring Boot: A Case Study of the XiaoLe Project

Recently, I decided to apply my knowledge to build a comprehensive backend management project named XiaoLe. After reviewing several open‑source projects, I summarized a modular model design.

The design is my own, for reference only.

Key elements of an excellent Spring Boot module design include:

Single Responsibility Principle (SRP): Each module should focus on a clear, well‑defined function to reduce complexity.

High Cohesion: Components within a module should be closely related, improving understandability and maintainability.

Low Coupling: Dependencies between modules should be minimized so changes in one module do not affect others.

Reusability: Modules should be built as reusable components that can be shared across projects.

Clear Boundaries and Interfaces: Interfaces between modules must be explicit, making interactions obvious.

Moderate Modularity: Group related components together without over‑fragmentation.

Layered Architecture: Separate layers such as controller, service, and data‑access to organize code.

Dependency Inversion Principle (DIP): Modules should depend on abstractions rather than concrete implementations.

Testability: Design modules to be easily unit‑tested, integration‑tested, and end‑to‑end tested.

Future Adaptability: Consider extensibility so new features can be added with minimal effort.

Opening IDEA and Creating the Project

The current architecture is a Maven‑managed project.

The overall structure looks like this:

Project directory overview (incomplete):

├─.idea
├─le-admin
│  └─src
│     ├─main
│     │  ├─java
│     │  │  └─com
│     │  │     └─le
│     │  │        └─admin
│     │  └─resources
│     │     └─META-INF
│     └─test
│        └─java
│           └─com
│              └─le
│                 └─test
├─le-business
│  └─src
│     └─main
│        └─java
│           └─com
│              └─le
│                 └─business
├─le-common
│  └─src
│     └─main
│        └─java
│           └─com
│              └─le
│                 └─common
├─le-core
│  └─src
│     └─main
│        └─java
│           └─com
│              └─le
│                 └─core
├─le-gen-code
│  └─src
│     └─main
│        ├─java
│        │  └─com
│        │     └─le
│        │        └─code
│        │           ├─config
│        │           ├─controller
│        │           ├─domain
│        │           ├─mapper
│        │           ├─service
│        │           └─util
│        └─resources
│           ├─mapper
│           └─vm
└─le-tripartite
   └─src
      └─main
         └─java
            └─com
               └─le
                  └─tripartite

core module:

Overview: Provides common configuration and basic services for the whole project.

Main functions: Core Spring Boot configuration, common interceptors, global exception handling, etc.

Role: No business logic; supplies infrastructure for other modules.

POM snippet:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.xiaole</groupId>
        <artifactId>XiaoLe</artifactId>
        <version>1.0.0</version>
    </parent>
    <groupId>com.le</groupId>
    <artifactId>le-core</artifactId>
    <name>le-core</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <!-- MyBatis -->
        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
        </dependency>
        <!-- MySQL driver -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-business</artifactId>
        </dependency>
    </dependencies>
</project>

common module: Stores utility classes and shared configuration, providing a foundation for other modules.

genCode module: A code‑generation tool that assists development by producing boiler‑plate code from templates. It depends on the common module and the Velocity engine.

business module: Contains the core business logic, services, domain models, and data access (MyBatis, Redis, etc.). Depends on common and tripartite modules.

tripartite module: Handles integration with third‑party services such as payment gateways or external APIs.

admin module: Provides the management UI and monitoring capabilities for administrators.

Parent POM: Aggregates all modules, manages versions of Spring Boot, Velocity, MyBatis, and defines dependencyManagement for consistent versions across the project.

Why Use import to Bring in Spring Boot

The import statement in Maven allows a parent POM to import dependency management from another Maven project, enabling modular project management, version control, and unified configuration across multiple modules.

Source Reference

Repository: https://gitee.com/paper_cup_cake/xiao-le

Feel free to discuss, ask questions, or share opinions.

Javabackend architectureMavenSpring Bootmodular design
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.