# 373675032/love-charity architecture

> Architecture diagram of the GitHub repository 373675032/love-charity, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/373675032/love-charity
- Repository: https://github.com/373675032/love-charity

## Overview

##### Project type and purpose
- This is a full-stack Java Web application (an MVC-style “forum” for charity projects) built with Spring Boot, Spring MVC, Thymeleaf, MyBatis and static assets (Bootstrap, jQuery, EditMd).
- Purpose: Provide a public-facing site for browsing and posting help‐articles and charity projects (front-end), plus an admin console for managing users, content, comments, links, feedback, etc.

##### High-level layers & directories
- Presentation layer
- src/main/resources/static/... → Bootstrap-based CSS/JS/third-party libs (DataTables, EditorMd, Ionicons, etc.)
- src/main/resources/templates/... → Thymeleaf HTML templates (background/admin & front).
- Controller layer
- com.charity.controller.* → Spring MVC @Controller classes handling HTTP endpoints.
- com.charity.component.LoginHandlerInterceptor → login/session interceptor.
- Service layer
- com.charity.service.* → interfaces (business logic abstractions)
- com.charity.service.impl.* → implementations invoking DAOs and utils.
- Data-access layer
- com.charity.mapper.* → MyBatis mapper interfaces
- src/main/resources/mybatis/mapper/*.xml → SQL mappings
- Model/DTO/VO
- com.charity.entity → JPA-style domain objects
- com.charity.dto.ResponseResult → API response wrapper
- com.charity.vo.* → view objects returned to template layer
- Configuration & utilities
- com.charity.config.* → Spring Boot Java @Configuration classes (DruidConfig, MvcConfig)
- com.charity.utils.* → OSS upload, Mail, Logging, IP, Bean copy, etc.
- External resources
- application.yml → DB, mail, OSS endpoints
- love-charity.sql → schema
- Aliyun OSS (object storage for user files/avatars)
- SMTP server (email verification/reset password)
- Ehcache (caching layer)
- Druid (DB connection pool + monitoring)

##### Core architectural patterns
- MVC: Thymeleaf templates + static resources (View) ←→ Controllers (Controller) ←→ Services → Mappers/DB (Model).
- Layered architecture (presentation, controller, service, DAO, persistence).
- Interceptor pattern for authentication/authorization.
- DAO pattern via MyBatis.
- External service integration: OSS and SMTP as “side-car” services.
- Caching at DB-access layer (Ehcache).
- Centralized configuration with Spring Boot auto-config + Java @Configuration.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser((Browser)):::external

    subgraph "Spring Boot App Server"
        direction TB
        subgraph "Presentation Layer"
            direction TB
            Static["Static Assets"]:::frontend
            Templates["Thymeleaf Templates"]:::frontend
        end
        LoginInterceptor["LoginHandlerInterceptor"]:::backend
        subgraph "Controller Layer"
            direction TB
            Controllers["Controllers"]:::backend
        end
        subgraph "Service Layer"
            direction TB
            ServiceIface["Service Interfaces"]:::backend
            ServiceImpl["Service Implementations"]:::backend
        end
        subgraph "Data-Access Layer"
            direction TB
            Mappers["MyBatis Mapper Interfaces"]:::backend
            MapperXML["MyBatis XML Mappings"]:::backend
        end
        subgraph "Model / DTO / VO"
            direction TB
            Entities["Entities"]:::backend
            DTO["ResponseResult (DTO)"]:::backend
            VOs["VOs"]:::backend
        end
        subgraph "Config & Utils"
            direction TB
            Config["Config Classes"]:::backend
            Utils["Utilities"]:::backend
            ApplicationYML["application.yml"]:::backend
            SQLScript["love-charity.sql"]:::backend
            CacheConf["ehcache.xml"]:::backend
            MybatisConf["mybatis-config.xml"]:::backend
        end
        Druid["Druid Pool"]:::backend
        Ehcache["Ehcache Cache"]:::backend
        Entry["LoveCharityApplication"]:::backend
    end

    MySQL[(MySQL Database)]:::external
    OSS(("Aliyun OSS")):::external
    SMTP(("SMTP Mail Server")):::external

    Browser -->|"HTTP(S) Requests"| Static
    Browser -->|"HTTP(S) Requests"| Templates
    Templates --> Controllers
    Static --> Controllers
    Controllers -->|"intercept"| LoginInterceptor
    LoginInterceptor --> Controllers
    Controllers -->|"calls Services"| ServiceIface
    ServiceIface -->|"implemented by"| ServiceImpl
    ServiceImpl -->|"uses DAOs"| Mappers
    Mappers -->|"SQL via JDBC"| MySQL
    ServiceImpl -->|"cache read/write"| Ehcache
    ServiceImpl -->|"connections via"| Druid
    ServiceImpl -->|"upload/download via OSS API"| OSS
    ServiceImpl -->|"send emails via SMTP"| SMTP
    Entry --> Controllers
    Config --> Entry

    classDef frontend fill:#f96,stroke:#333,stroke-width:1px
    classDef backend fill:#9cf,stroke:#333,stroke-width:1px
    classDef external fill:#cfc,stroke:#333,stroke-width:1px

    click Static "https://github.com/373675032/love-charity/tree/main/src/main/resources/static"
    click Templates "https://github.com/373675032/love-charity/tree/main/src/main/resources/templates"
    click Controllers "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/controller"
    click LoginInterceptor "https://github.com/373675032/love-charity/blob/main/src/main/java/com/charity/component/LoginHandlerInterceptor.java"
    click ServiceIface "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/service"
    click ServiceImpl "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/service/impl"
    click Mappers "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/mapper"
    click MapperXML "https://github.com/373675032/love-charity/tree/main/src/main/resources/mybatis/mapper"
    click Entities "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/entity"
    click DTO "https://github.com/373675032/love-charity/blob/main/src/main/java/com/charity/dto/ResponseResult.java"
    click VOs "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/vo"
    click Config "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/config"
    click Utils "https://github.com/373675032/love-charity/tree/main/src/main/java/com/charity/utils"
    click Entry "https://github.com/373675032/love-charity/blob/main/src/main/java/com/charity/LoveCharityApplication.java"
    click ApplicationYML "https://github.com/373675032/love-charity/blob/main/src/main/resources/application.yml"
    click SQLScript "https://github.com/373675032/love-charity/blob/main/src/main/resources/love-charity.sql"
    click CacheConf "https://github.com/373675032/love-charity/blob/main/src/main/resources/ehcache.xml"
    click MybatisConf "https://github.com/373675032/love-charity/blob/main/src/main/resources/mybatis/mybatis-config.xml"
```
