# zhisheng17/blog architecture

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

- Interactive diagram: https://gitdiagram.com/zhisheng17/blog
- Repository: https://github.com/zhisheng17/blog

## Overview

1. **Project shape**
   - This is a Spring Boot personal blog application with a classic layered MVC architecture.
   - The repo is split into a public-facing blog, an admin back office, shared application services, and MyBatis persistence mapped to a relational database.

2. **Entry point and bootstrapping**
   - `CoreApplication` is the Spring Boot entry class.
   - Runtime configuration lives in `src/main/resources/application.properties` and `application-jdbc.properties`.
   - Schema/data setup is represented by `src/main/resources/sql/tale.sql`.

3. **Request handling layers**
   - HTTP requests enter through controller classes in `controller/`.
   - Controllers are separated into:
     - public site controllers such as `IndexController`
     - admin controllers under `controller/admin/` for articles, pages, comments, categories, links, settings, attachments, and auth.
   - Controllers delegate business logic to services rather than talking to mappers directly.

4. **Service boundary**
   - The service layer is defined by interfaces like `IContentService`, `ICommentService`, `IMetaService`, `IOptionService`, `IUserService`, etc.
   - Implementations in `service/impl/` hold the actual business rules for blog content, metadata/taxonomy, comments, site settings, user/admin auth, logs, and attachments.
   - `SiteServiceImpl` appears to aggregate site-level queries for the public homepage and theme rendering.

5. **Persistence boundary**
   - Data access is handled by MyBatis mappers in `dao/` plus XML mappings in `resources/mapper/`.
   - The domain model is organized as VO objects in `modal/Vo/` such as `ContentVo`, `CommentVo`, `MetaVo`, `UserVo`, `OptionVo`, `AttachVo`, and `LogVo`.
   - The database access pattern is: controller -> service -> mapper -> SQL mapper XML -> relational DB.

6. **Public site vs admin site**
   - The application has two main UI surfaces:
     - `templates/themes/default/` for the public blog theme
     - `templates/admin/` for dashboard and content management
   - Static assets are also split into `static/user/` for public pages and `static/admin/` for admin UI scripts, CSS, plugins, and editor assets.

7. **Cross-cutting request concerns**
   - `interceptor/BaseInterceptor` and `WebMvcConfig` suggest request interception for common concerns such as authentication, session context, or site-wide request enrichment.
   - `controller/GlobalExceptionHandler` centralizes error handling.
   - `TipException` is a domain exception used to signal application-level validation or business failures.
   - `utils/LogAspect` indicates aspect-based logging for operations.

8. **Shared domain and DTOs**
   - `dto/` contains small shared types used across the app, such as `Types`, `ErrorCode`, `LogActions`, and `MetaDto`.
   - `modal/Bo/` contains response/view helper objects like `RestResponseBo`, `BackResponseBo`, `ArchiveBo`, `CommentBo`, and `StatisticsBo`.
   - These objects form the boundary between services and views/API responses without exposing raw persistence models everywhere.

9. **Blog-specific subsystems**
   - Content management is centered around articles/posts, pages, comments, categories/tags, links, attachments, and site options.
   - The metadata/relationship model is explicit: `MetaVo` and `RelationshipVo` support taxonomy and post-to-meta associations.
   - `LogVo` and related services support operational or activity logging.
   - `AttachServiceImpl` and backup utilities indicate file upload and export/backup support are part of the system, not separate services.

10. **Utilities and infrastructure helpers**
   - `utils/` contains reusable helpers for dates, IP parsing, patterns, UUIDs, JSON, maps, archives, and general blog utilities.
   - `utils/backup/` is a dedicated subsystem for database backup/export, with its own table/column model and DB row abstractions.
   - `ZipUtils` and backup classes imply the app can package backups for download or storage.

11. **Presentation model**
   - The frontend is server-rendered with Thymeleaf templates under `templates/`.
   - Common layout fragments live in `templates/comm/` and reusable theme parts in `templates/themes/default/` such as header, footer, post, archive, links, and comment pages.
   - Error pages are handled by dedicated templates for 404 and 500 cases.

12. **Operational and test footprint**
   - Logging is configured with `log4j2.xml`.
   - `banner.txt` indicates custom startup branding.
   - Tests exist for async behavior, transactions, password logic, and controller behavior, which suggests the codebase pays attention to service-layer correctness and web-layer integration.

13. **Architecture diagram takeaway**
   - The main runtime flow is: browser -> Spring MVC controllers -> service layer -> MyBatis mappers -> database, with interceptors and exception handling applied around the request path.
   - The UI is split between public theme pages and admin pages, both rendered server-side from the same application.
   - Supporting subsystems include attachment handling, logging, backup/export, and shared utility code.

Main entry points: [`src/main/java/com/my/blog/website/dao`](https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/dao) (MyBatis mappers), [`src/main/java/com/my/blog/website/interceptor/WebMvcConfig.java`](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/interceptor/WebMvcConfig.java) (Web config), [`src/main/java/com/my/blog/website/service/impl/SiteServiceImpl.java`](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/SiteServiceImpl.java) (Site service), [`src/main/resources/templates/comm`](https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/comm) (Common views)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_core_app["Core app<br/>Spring Boot entry"]
end

subgraph group_web["Web layer"]
  node_web_config["Web config<br/>MVC config<br/>[WebMvcConfig.java]"]
  node_base_interceptor["Interceptor"]
  node_global_error["Error handler<br/>exception advice"]
  node_public_controller["Public site<br/>MVC controller"]
  node_admin_controllers["Admin console<br/>MVC controllers"]
end

subgraph group_services["Services"]
  node_site_service["Site service<br/>service impl"]
  node_content_service["Content service<br/>service impl"]
  node_taxonomy_service["Taxonomy service<br/>service impl"]
  node_relationship_service["Relation service<br/>service impl"]
  node_comment_service["Comment service<br/>service impl"]
  node_user_service["User service<br/>service impl"]
  node_option_service["Option service<br/>service impl"]
  node_attach_service["Attachment service<br/>service impl"]
  node_log_service["Log service<br/>service impl"]
end

subgraph group_persistence["Persistence"]
  node_dao_mappers["MyBatis mappers<br/>mapper interfaces"]
  node_sql_maps["SQL maps<br/>MyBatis XML"]
  node_domain_models["VO models<br/>domain objects"]
  node_database[("Database<br/>relational store")]
end

subgraph group_presentation["Presentation"]
  node_public_theme["Public theme<br/>Thymeleaf views"]
  node_admin_views["Admin views<br/>Thymeleaf views"]
  node_common_views["Common views<br/>shared templates"]
end

subgraph group_crosscutting["Cross-cutting"]
  node_view_models["BO/DTO<br/>shared view models"]
  node_utilities["Utilities<br/>helpers"]
  node_config_files["Config files<br/>runtime config"]
end

node_core_app -->|"boots"| node_web_config
node_web_config -->|"registers"| node_base_interceptor
node_web_config -->|"pairs with"| node_global_error
node_public_controller -->|"uses"| node_site_service
node_admin_controllers -->|"uses"| node_content_service
node_admin_controllers -->|"uses"| node_taxonomy_service
node_admin_controllers -->|"uses"| node_comment_service
node_admin_controllers -->|"uses"| node_user_service
node_admin_controllers -->|"uses"| node_option_service
node_admin_controllers -->|"uses"| node_attach_service
node_admin_controllers -->|"uses"| node_log_service
node_site_service -->|"aggregates"| node_content_service
node_site_service -->|"aggregates"| node_taxonomy_service
node_taxonomy_service -->|"coordinates"| node_relationship_service
node_content_service -->|"persists via"| node_dao_mappers
node_comment_service -->|"persists via"| node_dao_mappers
node_user_service -->|"persists via"| node_dao_mappers
node_attach_service -->|"persists via"| node_dao_mappers
node_log_service -->|"persists via"| node_dao_mappers
node_dao_mappers -->|"mapped by"| node_sql_maps
node_sql_maps -->|"executes on"| node_database
node_view_models -->|"feeds"| node_public_theme
node_view_models -->|"feeds"| node_admin_views
node_common_views -->|"supports"| node_public_theme
node_common_views -->|"supports"| node_admin_views
node_global_error -->|"renders"| node_common_views
node_utilities -->|"supports"| node_attach_service
node_utilities -->|"supports"| node_log_service
node_config_files -->|"configures"| node_database

click node_core_app "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/CoreApplication.java"
click node_web_config "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/interceptor/WebMvcConfig.java"
click node_base_interceptor "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/interceptor/BaseInterceptor.java"
click node_global_error "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/controller/GlobalExceptionHandler.java"
click node_public_controller "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/controller/IndexController.java"
click node_site_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/SiteServiceImpl.java"
click node_content_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/ContentServiceImpl.java"
click node_taxonomy_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/MetaServiceImpl.java"
click node_relationship_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/RelationshipServiceImpl.java"
click node_comment_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/CommentServiceImpl.java"
click node_user_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/UserServiceImpl.java"
click node_option_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/OptionServiceImpl.java"
click node_attach_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/AttachServiceImpl.java"
click node_log_service "https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/LogServiceImpl.java"
click node_dao_mappers "https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/dao"
click node_sql_maps "https://github.com/zhisheng17/blog/tree/master/src/main/resources/mapper"
click node_domain_models "https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/modal/Vo"
click node_view_models "https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/modal/Bo"
click node_utilities "https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/utils"
click node_public_theme "https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/themes/default"
click node_admin_views "https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/admin"
click node_common_views "https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/comm"
click node_config_files "https://github.com/zhisheng17/blog/tree/master/src/main/resources"

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_core_app toneBlue
class node_web_config,node_base_interceptor,node_global_error,node_public_controller,node_admin_controllers toneAmber
class node_site_service,node_content_service,node_taxonomy_service,node_relationship_service,node_comment_service,node_user_service,node_option_service,node_attach_service,node_log_service toneMint
class node_dao_mappers,node_sql_maps,node_domain_models,node_database toneRose
class node_public_theme,node_admin_views,node_common_views toneIndigo
class node_view_models,node_utilities,node_config_files toneTeal
```

## Components

### Runtime

Spring Boot entry point and request orchestration

- [Core app](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/CoreApplication.java): Spring Boot entry · Application bootstrap and runtime entry point · `src/main/java/com/my/blog/website/CoreApplication.java`

### Web layer

MVC controllers, interceptors, and exception handling

- [Web config](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/interceptor/WebMvcConfig.java): MVC config · Registers request interception and web MVC settings · `src/main/java/com/my/blog/website/interceptor/WebMvcConfig.java`
- [Interceptor](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/interceptor/BaseInterceptor.java): request interceptor · Common request pre-processing for auth and context · `src/main/java/com/my/blog/website/interceptor/BaseInterceptor.java`
- [Error handler](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/controller/GlobalExceptionHandler.java): exception advice · Centralized MVC exception handling · `src/main/java/com/my/blog/website/controller/GlobalExceptionHandler.java`
- [Public site](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/controller/IndexController.java): MVC controller · Main blog-facing request handler · `src/main/java/com/my/blog/website/controller/IndexController.java`
- **Admin console**: MVC controllers · Back-office controllers for articles, pages, comments, links, categories, settings, attachments, and auth

### Services

Business logic and application orchestration

- [Site service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/SiteServiceImpl.java): service impl · Homepage and theme-oriented query aggregation · `src/main/java/com/my/blog/website/service/impl/SiteServiceImpl.java`
- [Content service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/ContentServiceImpl.java): service impl · Articles and pages business rules · `src/main/java/com/my/blog/website/service/impl/ContentServiceImpl.java`
- [Taxonomy service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/MetaServiceImpl.java): service impl · Metadata, categories, tags, and relationships · `src/main/java/com/my/blog/website/service/impl/MetaServiceImpl.java`
- [Relation service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/RelationshipServiceImpl.java): service impl · Post-to-meta association logic · `src/main/java/com/my/blog/website/service/impl/RelationshipServiceImpl.java`
- [Comment service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/CommentServiceImpl.java): service impl · Comment lifecycle and moderation logic · `src/main/java/com/my/blog/website/service/impl/CommentServiceImpl.java`
- [User service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/UserServiceImpl.java): service impl · User accounts and admin authentication · `src/main/java/com/my/blog/website/service/impl/UserServiceImpl.java`
- [Option service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/OptionServiceImpl.java): service impl · Site settings and configuration values · `src/main/java/com/my/blog/website/service/impl/OptionServiceImpl.java`
- [Attachment service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/AttachServiceImpl.java): service impl · Uploads, file handling, and related storage operations · `src/main/java/com/my/blog/website/service/impl/AttachServiceImpl.java`
- [Log service](https://github.com/zhisheng17/blog/blob/master/src/main/java/com/my/blog/website/service/impl/LogServiceImpl.java): service impl · Operational and activity logging · `src/main/java/com/my/blog/website/service/impl/LogServiceImpl.java`

### Persistence

MyBatis mappers and relational data model

- [MyBatis mappers](https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/dao): mapper interfaces · Data access interfaces for content, comments, users, options, attachments, metadata, relationships, and logs · `src/main/java/com/my/blog/website/dao`
- [SQL maps](https://github.com/zhisheng17/blog/tree/master/src/main/resources/mapper): MyBatis XML · Mapper XML statements and result mappings · `src/main/resources/mapper`
- [VO models](https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/modal/Vo): domain objects · Persistence-facing content, user, comment, metadata, option, attachment, and log records · `src/main/java/com/my/blog/website/modal/Vo`
- **Database**: relational store · Persistent relational data store behind the MyBatis layer

### Presentation

Server-rendered public and admin templates

- [Public theme](https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/themes/default): Thymeleaf views · Server-rendered blog pages for the public site · `src/main/resources/templates/themes/default`
- [Admin views](https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/admin): Thymeleaf views · Dashboard and content management templates · `src/main/resources/templates/admin`
- [Common views](https://github.com/zhisheng17/blog/tree/master/src/main/resources/templates/comm): shared templates · Reusable fragments and error pages · `src/main/resources/templates/comm`

### Cross-cutting

Shared configuration, aspects, and utilities

- [BO/DTO](https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/modal/Bo): shared view models · Response wrappers, archives, stats, and shared constants · `src/main/java/com/my/blog/website/modal/Bo`
- [Utilities](https://github.com/zhisheng17/blog/tree/master/src/main/java/com/my/blog/website/utils): helpers · Common helpers, logging aspect, backup tooling, and general-purpose utilities · `src/main/java/com/my/blog/website/utils`
- [Config files](https://github.com/zhisheng17/blog/tree/master/src/main/resources): runtime config · Application properties, logging, banner, and database bootstrap SQL · `src/main/resources`

## Connections

- Core app → Web config: boots · Initializes web configuration during application startup
- Web config → Interceptor: registers · Installs request interception on the MVC pipeline
- Web config → Error handler: pairs with · Works alongside centralized exception handling
- Public site → Site service: uses · Delegates homepage and public-site queries to the service layer
- Admin console → Content service: uses · Admin article and page actions flow through content services
- Admin console → Taxonomy service: uses · Category and tag management uses metadata services
- Admin console → Comment service: uses · Comment moderation flows through comment services
- Admin console → User service: uses · Login and admin auth rely on user services
- Admin console → Option service: uses · Settings pages read and persist site options
- Admin console → Attachment service: uses · Attachment management uses the upload service
- Admin console → Log service: uses · Admin operations can surface operational logs
- Site service → Content service: aggregates · Homepage queries combine content-oriented results
- Site service → Taxonomy service: aggregates · Public pages also need taxonomy and archive data
- Taxonomy service → Relation service: coordinates · Metadata operations depend on post relationship handling
- Content service → MyBatis mappers: persists via · Business logic reaches data access through mapper interfaces
- Comment service → MyBatis mappers: persists via · Comment changes are written through mappers
- User service → MyBatis mappers: persists via · User and auth state are loaded through mappers
- Attachment service → MyBatis mappers: persists via · Attachment records are stored through the mapper layer
- Log service → MyBatis mappers: persists via · Logs are written via MyBatis persistence
- MyBatis mappers → SQL maps: mapped by · Interfaces are implemented by XML SQL mappings
- SQL maps → Database: executes on · SQL statements run against the relational database
- BO/DTO → Public theme: feeds · Shared response shapes support public rendering
- BO/DTO → Admin views: feeds · Back-office screens consume shared response models
- Common views → Public theme: supports · Fragments are reused by the public theme
- Common views → Admin views: supports · Common layout pieces support the admin UI too
- Error handler → Common views: renders · Error conditions resolve to dedicated error templates
- Utilities → Attachment service: supports · Backup and archive utilities complement file handling
- Utilities → Log service: supports · Logging aspect and helpers cross-cut service execution
- Config files → Database: configures · Runtime properties and SQL bootstrap the persistence environment
