Backend Development 23 min read

Design Principles and Module Structure for a Spring Boot Backend Project (XiaoLe)

This article outlines essential backend design principles such as single responsibility, high cohesion, low coupling, reusability, clear boundaries, moderate modularity, layered architecture, dependency inversion, testability and future adaptability, and demonstrates their application in a multi‑module Spring Boot project with detailed Maven configurations.

Top Architect
Top Architect
Top Architect
Design Principles and Module Structure for a Spring Boot Backend Project (XiaoLe)

In this article the author, a senior architect, shares a personal experience of building a backend management system called XiaoLe using Spring Boot, and presents a comprehensive set of design principles for structuring backend modules.

Key Design Principles

Single Responsibility Principle (SRP) : each module should focus on one well‑defined function to reduce complexity.

High Cohesion : related classes and components stay together, improving understandability and maintainability.

Low Coupling : dependencies between modules are minimized so changes in one module do not affect others.

Reusability : modules are built as reusable components that can be shared across projects.

Clear Boundaries and Interfaces : module interfaces are explicit, making interactions obvious for team members.

Moderate Modularity : group related functionality without over‑fragmentation to avoid unnecessary complexity.

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

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

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

Adaptability for Future Extension : anticipate future requirements so new features can be added with minimal impact.

Project Structure Overview

The project is managed with Maven and consists of several modules: le-admin , le-business , le-common , le-core , le-gen-code , le-tripartite , and a parent POM that aggregates them.

Module Details

Core Module – provides common configuration and foundational services (e.g., Spring Boot core settings, global interceptors, exception handling).

<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 for the whole project.

<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-common</artifactId>
    <description>common</description>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
    </dependencies>
</project>

genCode Module – a code‑generation tool that uses Velocity templates to accelerate development.

<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-gen-code</artifactId>
    <name>le-gen-code</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
        </dependency>
    </dependencies>
</project>

Business Module – contains the core business logic, services, domain models and data access (MyBatis, Redis, etc.).

<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-business</artifactId>
    <name>le-business</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-common</artifactId>
        </dependency>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-tripartite</artifactId>
        </dependency>
    </dependencies>
</project>

Tripartite Module – handles integration with third‑party services such as payment gateways or external APIs.

<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-tripartite</artifactId>
    <name>le-tripartite</name>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-common</artifactId>
        </dependency>
    </dependencies>
</project>

Admin Module – provides the management UI and related backend services for administrators.

<?xml version="1.0" encoding="UTF-8"?>
<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-admin</artifactId>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <dependencies>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-gen-code</artifactId>
        </dependency>
        <dependency>
            <groupId>com.le</groupId>
            <artifactId>le-core</artifactId>
        </dependency>
    </dependencies>
</project>

Parent POM – aggregates all modules and manages common dependency versions via dependencyManagement .

<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>
    <groupId>com.xiaole</groupId>
    <artifactId>XiaoLe</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>xiaole</name>
    <description>小乐</description>
    <modules>
        <module>le-admin</module>
        <module>le-common</module>
        <module>le-core</module>
        <module>le-business</module>
        <module>le-gen-code</module>
        <module>le-tripartite</module>
    </modules>
    <properties>
        <spring-boot.version>2.5.8</spring-boot.version>
        <xiaole.version>1.0.0</xiaole.version>
        <velocity.version>2.3</velocity.version>
        <mybatis.version>2.2.0</mybatis.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>${spring-boot.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
            <dependency>
                <groupId>org.apache.velocity</groupId>
                <artifactId>velocity-engine-core</artifactId>
                <version>${velocity.version}</version>
            </dependency>
            <dependency>
                <groupId>com.le</groupId>
                <artifactId>le-core</artifactId>
                <version>${xiaole.version}</version>
            </dependency>
            <dependency>
                <groupId>com.le</groupId>
                <artifactId>le-admin</artifactId>
                <version>${xiaole.version}</version>
            </dependency>
            <dependency>
                <groupId>com.le</groupId>
                <artifactId>le-common</artifactId>
                <version>${xiaole.version}</version>
            </dependency>
            <dependency>
                <groupId>com.le</groupId>
                <artifactId>le-business</artifactId>
                <version>${xiaole.version}</version>
            </dependency>
            <dependency>
                <groupId>com.le</groupId>
                <artifactId>le-gen-code</artifactId>
                <version>${xiaole.version}</version>
            </dependency>
            <dependency>
                <groupId>com.le</groupId>
                <artifactId>le-tripartite</artifactId>
                <version>${xiaole.version}</version>
            </dependency>
            <dependency>
                <groupId>org.mybatis.spring.boot</groupId>
                <artifactId>mybatis-spring-boot-starter</artifactId>
                <version>${mybatis.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
</project>

Why Use import in Spring Boot

The import element in a Maven POM allows a parent project to bring in dependency management and plugin configurations from another POM, enabling modular project organization, version control, and consistent configuration across all modules.

Source Reference

Original article: juejin.cn/post/7319027307578540047

Javabackend architecturemavenSpring BootModule 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.