# keyu98/askme architecture

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

- Interactive diagram: https://gitdiagram.com/keyu98/askme
- Repository: https://github.com/keyu98/askme

## Overview

##### Project Type and Purpose
- The project is a full-stack web application fulfilling a Q&A or blogging-style functionality.
- It leverages SpringBoot + SpringMVC for the web layer, MyBatis for persistence, MySQL as the relational database, Redis for caching (including hot data caching and MyBatis second-level cache), and Solr as a search engine.
- It also implements asynchronous event processing for enhancing responsiveness.

##### Analyzing the File Structure
- Top-level Maven project structure with files like pom.xml, Maven wrapper scripts (mvnw) and a .mvn directory.
- The solr-config directory indicates custom configurations and installation of Solr extensions (e.g., ik-analyzer for Chinese tokenization, data import handlers, and MySQL connector).
- The main source files under src/main/java/site/keyu/askme show a clear segregation of responsibilities:
- Controllers for handling HTTP requests.
- Services encapsulating business logic.
- DAO layer for data persistence (with MyBatis).
- Asynchronous processing components (event types, producers, consumers, and handlers).
- Cache utilities that work with Redis.
- Configuration files and interceptors.
- There are static resources (CSS, JavaScript, images) and Thymeleaf templates under src/main/resources which point to the presentation layer.
- Test files are organized under src/test, covering both application and service testing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        staticResources("Static Resources"):::client
        templates("Thymeleaf Templates"):::client
    end

    %% Web Layer
    subgraph "Web Layer"
        controllers("Controllers (Home,Login,Question,Comment,Like,Search)"):::controller
    end

    %% Service Layer
    subgraph "Service Layer"
        services("Service Layer (Question,Comment,Like,Message,Search,User,LastedView)"):::service
    end

    %% Data Access Layer
    subgraph "DAO Layer"
        daos("DAO Layer (User,Question,Comment,Message,LoginTicket)"):::dao
    end

    %% Caching Layer
    subgraph "Caching Layer"
        cacheUtils("Cache Utilities (MyBatisRedisCache,etc)"):::cache
        cacheHelpers("Cache Helpers (RedisCacheUtil,RedisKeyUtil,JedisAdapter)"):::cache
    end

    %% Configurations
    subgraph "Configurations"
        webConfig("Web Configuration"):::config
        mybatisConfig("MyBatis Configuration"):::config
        appProperties("Application Properties"):::config
    end

    %% Other Components
    database("MySQL Database"):::database
    search("Solr Search Engine"):::search
    async("Async Processing (EventProducer,Consumer,Handlers)"):::async
    interceptors("Interceptors (NeedLogin,Passport)"):::interceptors

    %% Connections
    staticResources --> controllers
    templates --> controllers
    controllers --> services
    services --> daos
    daos --> database
    
    services --> cacheUtils
    services --> cacheHelpers
    services --> search

    controllers --> async
    services --> async

    webConfig --> controllers
    mybatisConfig --> daos
    appProperties --> services

    interceptors --> controllers

    %% Click Events
    click staticResources "https://github.com/keyu98/askme/tree/master/src/main/resources/static"
    click templates "https://github.com/keyu98/askme/tree/master/src/main/resources/templates"
    click controllers "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/controller"
    click services "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/service"
    click daos "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/dao"
    click cacheUtils "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/cache"
    click cacheHelpers "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/utils"
    click search "https://github.com/keyu98/askme/tree/master/solr-config"
    click async "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/async"
    click webConfig "https://github.com/keyu98/askme/blob/master/src/main/java/site/keyu/askme/configuration/WebConfiguration.java"
    click mybatisConfig "https://github.com/keyu98/askme/blob/master/src/main/resources/mybatis-config.xml"
    click appProperties "https://github.com/keyu98/askme/blob/master/src/main/resources/application.properties"
    click interceptors "https://github.com/keyu98/askme/tree/master/src/main/java/site/keyu/askme/interceptor"

    %% Styles
    classDef client fill:#ffebcd,stroke:#8b4513,stroke-width:2px;
    classDef controller fill:#add8e6,stroke:#00008b,stroke-width:2px;
    classDef service fill:#98fb98,stroke:#006400,stroke-width:2px;
    classDef dao fill:#ffdead,stroke:#d2691e,stroke-width:2px;
    classDef cache fill:#fffacd,stroke:#cccc00,stroke-width:2px;
    classDef database fill:#ffcccb,stroke:#ff0000,stroke-width:2px;
    classDef search fill:#d0e6a5,stroke:#6b8e23,stroke-width:2px;
    classDef async fill:#b0e0e6,stroke:#4682b4,stroke-width:2px;
    classDef config fill:#e6e6fa,stroke:#483d8b,stroke-width:2px;
    classDef interceptors fill:#f5deb3,stroke:#a0522d,stroke-width:2px;
```
