# zhaopei0418/springboot architecture

> Architecture diagram of the GitHub repository zhaopei0418/springboot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/zhaopei0418/springboot
- Repository: https://github.com/zhaopei0418/springboot

## Overview

1. This repository is a single Spring Boot application that acts as a small integration/demo platform. It combines REST APIs, two MyBatis-backed databases, Redis pub/sub, RabbitMQ messaging, and a bit of Spring Integration/Jersey support in one deployable service.

2. The application entry point is `Application.java`, and the project is built with Maven (`pom.xml`). The app runs as an embedded server on port `8081` via `mvn spring-boot:run`, so the whole architecture is packaged and started as one process.

3. The primary HTTP API layer lives under `controller/`. These Spring MVC controllers expose the main endpoints for cities, users, Redis publishing, and queue actions. The README confirms a simple root/home response and a Redis publish test endpoint at `/redis/publish`.

4. There is also a Jersey-based REST layer in `jerseyservice/` and `resource/`, wired by `config/JerseyConfig.java`. That means the repo supports two REST styles side by side: Spring MVC controllers and JAX-RS resources.

5. Persistence is split across two databases. `PrimaryDatabaseConfiguration.java` and `SecondDatabaseConfig.java` set up separate MyBatis data sources, with mapper packages divided into `mapper/primary` and `mapper/second`. This is an important architectural boundary: `City` data is isolated from `UserTest` data.

6. The domain/model layer is very small and purpose-built. `domain/City.java` and `domain/UserTest.java` map to the two persistence areas. Service interfaces and implementations (`service/`, `service/impl/`) sit between controllers and mappers, so controllers do not talk to MyBatis directly.

7. SQL is organized with provider classes in `sqlprovide/` rather than only static XML mappers. `CitySqlProvide.java` and `UserTestProvide.java` indicate dynamic SQL generation for at least part of the persistence layer.

8. Redis is used for publish/subscribe messaging. `RedisConfigation.java` configures the Redis client and `IntegrationConfiguration.java` appears to wire the subscription side. The README shows the main flow: an HTTP call publishes a message, and the app logs the received subscription message.

9. RabbitMQ is the second messaging path. `RabbitMQConfigration.java`, `service/Sender.java`, `service/Receiver.java`, and `controller/QueueController.java` together form a queue example. The README also highlights broker credentials in `application.yml`, so RabbitMQ is an external runtime dependency, not an in-memory demo.

10. Spring Integration is present as an integration boundary, not just plain messaging. `src/main/resources/application-integration-redis.xml` and `config/spring-integration-file-context.xml`, plus classes like `QueueReadingMessageSource` and `DefaultFileNameGenerator`, suggest file/message flow examples wired through Spring Integration channels and adapters.

11. The repo includes some API documentation assets under `src/main/resources/static/apidocs/`. The README points to `/apidocs/index.html`, so Swagger-style documentation is served as static content from the application itself.

12. There are utility and test-only pieces that are not part of the main request flow. `util/QRCodeUtil.java` is a standalone helper with a corresponding unit test, and `CXFClientTest.java` suggests a client/integration test for an external service style endpoint.

13. Architecturally, the application boundary is: HTTP requests enter through Spring MVC or Jersey, business logic runs in service classes, data access goes through MyBatis to one of two databases, and asynchronous/integration flows go out through Redis or RabbitMQ. External services are Redis, RabbitMQ, and the configured relational databases.

14. If you draw this repo, the main diagram should show one Spring Boot monolith with three notable subsystems beneath it: REST/API delivery, dual-database persistence, and messaging/integration. The strongest repo-specific detail is that these subsystems are intentionally demonstrated in parallel rather than abstracted behind a single unified infrastructure layer.

Main entry points: [`src/main/java/online/zhaopei/myproject/controller`](https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/controller) (Spring APIs), [`src/main/java/online/zhaopei/myproject/Application.java`](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/Application.java) (Application), [`src/main/java/online/zhaopei/myproject/config/JerseyConfig.java`](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/JerseyConfig.java) (Jersey Config), [`src/main/java/online/zhaopei/myproject/service/impl/CityServiceImpl.java`](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/service/impl/CityServiceImpl.java) (City Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Boot app"]
  node_app(("Application<br/>boot entry<br/>[Application.java]"))
end

subgraph group_api["API layer"]
  node_mvc_controllers["Spring APIs<br/>mvc controllers"]
  node_jersey_config["Jersey Config<br/>jax-rs config<br/>[JerseyConfig.java]"]
  node_jersey_resources["Jersey APIs<br/>jax-rs resources"]
  node_apidocs["API Docs<br/>static docs<br/>[index.html]"]
end

subgraph group_data["Persistence"]
  node_primary_db_cfg[("Primary DB<br/>mybatis config")]
  node_secondary_db_cfg[("Second DB<br/>mybatis config")]
  node_city_service["City Service"]
  node_user_service["User Service"]
  node_city_mapper["City Mapper<br/>mybatis mapper<br/>[CityMapper.java]"]
  node_user_mapper["User Mapper<br/>mybatis mapper"]
end

subgraph group_messaging["Messaging"]
  node_redis_cfg[("Redis Config")]
  node_redis_integration["Redis Integration<br/>integration config"]
  node_rabbit_cfg["RabbitMQ Config<br/>amqp config"]
  node_queue_flow["Queue Flow<br/>messaging service"]
  node_spring_integration["Integration Flow"]
end

node_app -->|"starts"| node_mvc_controllers
node_app -->|"enables"| node_jersey_config
node_jersey_config -->|"registers"| node_jersey_resources
node_mvc_controllers -->|"uses"| node_city_service
node_mvc_controllers -->|"uses"| node_user_service
node_city_service -->|"persists"| node_city_mapper
node_user_service -->|"persists"| node_user_mapper
node_city_mapper -->|"binds to"| node_primary_db_cfg
node_user_mapper -->|"binds to"| node_secondary_db_cfg
node_mvc_controllers -->|"publishes"| node_redis_cfg
node_redis_cfg -->|"subscribes"| node_redis_integration
node_mvc_controllers -->|"triggers"| node_rabbit_cfg
node_rabbit_cfg -->|"wires"| node_queue_flow
node_spring_integration -->|"adapts"| node_queue_flow
node_app -->|"serves"| node_apidocs

click node_app "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/Application.java"
click node_mvc_controllers "https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/controller"
click node_jersey_config "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/JerseyConfig.java"
click node_jersey_resources "https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/resource"
click node_primary_db_cfg "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/PrimaryDatabaseConfiguration.java"
click node_secondary_db_cfg "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/SecondDatabaseConfig.java"
click node_city_service "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/service/impl/CityServiceImpl.java"
click node_user_service "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/service/impl/UserTestServiceImpl.java"
click node_city_mapper "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/mapper/primary/CityMapper.java"
click node_user_mapper "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/mapper/second/UserTestMapper.java"
click node_redis_cfg "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/RedisConfigation.java"
click node_redis_integration "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/IntegrationConfiguration.java"
click node_rabbit_cfg "https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/RabbitMQConfigration.java"
click node_queue_flow "https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/service"
click node_spring_integration "https://github.com/zhaopei0418/springboot/blob/master/src/main/resources/application-integration-redis.xml"
click node_apidocs "https://github.com/zhaopei0418/springboot/blob/master/src/main/resources/static/apidocs/index.html"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app toneBlue
class node_mvc_controllers,node_jersey_config,node_jersey_resources,node_apidocs toneAmber
class node_primary_db_cfg,node_secondary_db_cfg,node_city_service,node_user_service,node_city_mapper,node_user_mapper toneMint
class node_redis_cfg,node_redis_integration,node_rabbit_cfg,node_queue_flow,node_spring_integration toneRose
```

## Components

### Boot app

Single Spring Boot deployable runtime and entry point.

- [Application](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/Application.java): boot entry · Spring Boot launcher and embedded server entry point. · `src/main/java/online/zhaopei/myproject/Application.java`

### API layer

HTTP delivery through Spring MVC and Jersey.

- [Spring APIs](https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/controller): mvc controllers · Primary REST endpoints for cities, users, Redis publishing, and queue actions. · `src/main/java/online/zhaopei/myproject/controller`
- [Jersey Config](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/JerseyConfig.java): jax-rs config · Wires the Jersey REST layer into the application. · `src/main/java/online/zhaopei/myproject/config/JerseyConfig.java`
- [Jersey APIs](https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/resource): jax-rs resources · JAX-RS endpoints exposed alongside Spring MVC. · `src/main/java/online/zhaopei/myproject/resource`
- [API Docs](https://github.com/zhaopei0418/springboot/blob/master/src/main/resources/static/apidocs/index.html): static docs · Swagger-style documentation served from static resources. · `src/main/resources/static/apidocs/index.html`

### Persistence

Dual MyBatis-backed database access.

- [Primary DB](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/PrimaryDatabaseConfiguration.java): mybatis config · Primary datasource and MyBatis setup for city data. · `src/main/java/online/zhaopei/myproject/config/PrimaryDatabaseConfiguration.java`
- [Second DB](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/SecondDatabaseConfig.java): mybatis config · Secondary datasource and MyBatis setup for user data. · `src/main/java/online/zhaopei/myproject/config/SecondDatabaseConfig.java`
- [City Service](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/service/impl/CityServiceImpl.java): service · Business layer for city operations. · `src/main/java/online/zhaopei/myproject/service/impl/CityServiceImpl.java`
- [User Service](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/service/impl/UserTestServiceImpl.java): service · Business layer for user-test operations. · `src/main/java/online/zhaopei/myproject/service/impl/UserTestServiceImpl.java`
- [City Mapper](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/mapper/primary/CityMapper.java): mybatis mapper · Primary database mapper for city persistence. · `src/main/java/online/zhaopei/myproject/mapper/primary/CityMapper.java`
- [User Mapper](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/mapper/second/UserTestMapper.java): mybatis mapper · Secondary database mapper for user-test persistence. · `src/main/java/online/zhaopei/myproject/mapper/second/UserTestMapper.java`

### Messaging

Redis, RabbitMQ, and Spring Integration flows.

- [Redis Config](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/RedisConfigation.java): redis config · Redis client and publish/subscribe setup. · `src/main/java/online/zhaopei/myproject/config/RedisConfigation.java`
- [Redis Integration](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/IntegrationConfiguration.java): integration config · Spring Integration wiring for Redis subscription handling. · `src/main/java/online/zhaopei/myproject/config/IntegrationConfiguration.java`
- [RabbitMQ Config](https://github.com/zhaopei0418/springboot/blob/master/src/main/java/online/zhaopei/myproject/config/RabbitMQConfigration.java): amqp config · RabbitMQ broker and queue configuration. · `src/main/java/online/zhaopei/myproject/config/RabbitMQConfigration.java`
- [Queue Flow](https://github.com/zhaopei0418/springboot/tree/master/src/main/java/online/zhaopei/myproject/service): messaging service · Sender and receiver pair for RabbitMQ messaging. · `src/main/java/online/zhaopei/myproject/service`
- [Integration Flow](https://github.com/zhaopei0418/springboot/blob/master/src/main/resources/application-integration-redis.xml): integration flow · File and message-flow support via Spring Integration resources and helpers. · `src/main/resources/application-integration-redis.xml`

## Connections

- Application → Spring APIs: starts · Boot application exposes the Spring MVC API layer.
- Application → Jersey Config: enables · Boot application loads the Jersey REST configuration.
- Jersey Config → Jersey APIs: registers · Jersey configuration binds JAX-RS resources.
- Spring APIs → City Service: uses · City endpoints delegate to the city service.
- Spring APIs → User Service: uses · User endpoints delegate to the user service.
- City Service → City Mapper: persists · City service reads and writes through the primary mapper.
- User Service → User Mapper: persists · User service reads and writes through the secondary mapper.
- City Mapper → Primary DB: binds to · City mapper is attached to the primary datasource.
- User Mapper → Second DB: binds to · User mapper is attached to the secondary datasource.
- Spring APIs → Redis Config: publishes · Redis publish endpoint sends messages through the Redis setup.
- Redis Config → Redis Integration: subscribes · Integration config handles Redis subscription flow.
- Spring APIs → RabbitMQ Config: triggers · Queue-related controller actions go through RabbitMQ setup.
- RabbitMQ Config → Queue Flow: wires · RabbitMQ configuration supports sender/receiver messaging.
- Integration Flow → Queue Flow: adapts · Spring Integration resources participate in message/file flow examples.
- Application → API Docs: serves · Application exposes static API documentation assets.
