How zhisheng17/blog works
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: dao MyBatis mappers · WebMvcConfig.java Web config · SiteServiceImpl.java Site service · comm Common views
Components 25
Runtime
Spring Boot entry point and request orchestration
- Core app · 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 · Registers request interception and web MVC settings
src/main/java/com/my/blog/website/interceptor/WebMvcConfig.java - Interceptor · Common request pre-processing for auth and context
src/main/java/com/my/blog/website/interceptor/BaseInterceptor.java - Error handler · Centralized MVC exception handling
src/main/java/com/my/blog/website/controller/GlobalExceptionHandler.java - Public site · Main blog-facing request handler
src/main/java/com/my/blog/website/controller/IndexController.java - Admin console · Back-office controllers for articles, pages, comments, links, categories, settings, attachments, and auth
Services
Business logic and application orchestration
- Site service · Homepage and theme-oriented query aggregation
src/main/java/com/my/blog/website/service/impl/SiteServiceImpl.java - Content service · Articles and pages business rules
src/main/java/com/my/blog/website/service/impl/ContentServiceImpl.java - Taxonomy service · Metadata, categories, tags, and relationships
src/main/java/com/my/blog/website/service/impl/MetaServiceImpl.java - Relation service · Post-to-meta association logic
src/main/java/com/my/blog/website/service/impl/RelationshipServiceImpl.java - Comment service · Comment lifecycle and moderation logic
src/main/java/com/my/blog/website/service/impl/CommentServiceImpl.java - User service · User accounts and admin authentication
src/main/java/com/my/blog/website/service/impl/UserServiceImpl.java - Option service · Site settings and configuration values
src/main/java/com/my/blog/website/service/impl/OptionServiceImpl.java - Attachment service · Uploads, file handling, and related storage operations
src/main/java/com/my/blog/website/service/impl/AttachServiceImpl.java - Log service · Operational and activity logging
src/main/java/com/my/blog/website/service/impl/LogServiceImpl.java
Persistence
MyBatis mappers and relational data model
- MyBatis mappers · Data access interfaces for content, comments, users, options, attachments, metadata, relationships, and logs
src/main/java/com/my/blog/website/dao - SQL maps · Mapper XML statements and result mappings
src/main/resources/mapper - VO models · Persistence-facing content, user, comment, metadata, option, attachment, and log records
src/main/java/com/my/blog/website/modal/Vo - Database · Persistent relational data store behind the MyBatis layer
Presentation
Server-rendered public and admin templates
- Public theme · Server-rendered blog pages for the public site
src/main/resources/templates/themes/default - Admin views · Dashboard and content management templates
src/main/resources/templates/admin - Common views · Reusable fragments and error pages
src/main/resources/templates/comm
Cross-cutting
Shared configuration, aspects, and utilities
- BO/DTO · Response wrappers, archives, stats, and shared constants
src/main/java/com/my/blog/website/modal/Bo - Utilities · Common helpers, logging aspect, backup tooling, and general-purpose utilities
src/main/java/com/my/blog/website/utils - Config files · Application properties, logging, banner, and database bootstrap SQL
src/main/resources
Connections 29
- 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