# chgoh7/paicoding architecture

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

- Interactive diagram: https://gitdiagram.com/chgoh7/paicoding
- Repository: https://github.com/chgoh7/paicoding

## Overview

##### Project type and purpose
- This is a full‑stack, community/forum system. The “pai‑coding‑front” directory is a Vue3 single‑page application (SPA). The remaining modules are a multi‑module Java backend built on Spring Boot 3, MyBatis‑Plus, MySQL, Redis, Elasticsearch, MongoDB, RabbitMQ, Docker, etc.
- It supports article publish/search/comment workflows, real‑time chat via WebSocket, AI integrations (ChatGPT, Xunfei), image uploads (OSS), and background message processing/notifications.

##### File structure
Top‑level modules (per README’s “组织结构”):
a. paicoding-front: Vue3 SPA (assets, components, router, state management, HTTP client).
b. paicoding-api: Shared DTO/VO/enum definitions.
c. paicoding-core: Reusable utilities and auto‑configuration (caching, async, RPC, permission, RabbitMQ config, region lookup, sensitive‑word filtering, ID generation, etc.).
d. paicoding-service: Business logic and data access (MyBatis mappers, DAOs, repositories, converters, service interfaces/implementations across articles, comments, users, config, rank, notify, statistics, AI chat).
e. paicoding-web: HTTP/WebSocket controllers, security, global exception handling, app startup, Liquibase migrations, environment‑specific YAML, RabbitMQ consumers.

Supporting items:
- Docker/Nginx scripts (deploy.sh, launch.sh)
- Configuration files under src/main/resources and resources‑env (dev/test/pre/prod)
- Documentation in docs/
- Maven wrapper, parent pom, individual poms.

##### README for additional insights
- Details of environment profiles and how to switch (Maven profiles).
- Tech stack summary: Spring/SpringMVC, MyBatis‑Plus + PageHelper, Redis, Elasticsearch, MongoDB, RabbitMQ, JWT, WebSocket, OSS, Docker, Vue3, etc.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        SPA["Vue3 SPA"]:::frontend
    end

    %% Web/API Layer
    subgraph "API/Web Layer"
        WebModule["Spring Boot Web Module\n(REST Controllers & WebSocket Endpoints)"]:::web
        WsConfig["WebSocket Chat Config"]:::web
        WebConsumers["RabbitMQ Consumers"]:::web
        Liquibase["Database Migrations\n(Liquibase Changelogs)"]:::web
        EnvConfig["Env-Specific Configurations"]:::web
        CacheWebConfig["Redis Cache Config"]:::web
    end

    %% Service Layer
    subgraph "Service Layer"
        Services["Business Services"]:::service
        MyBatisJS["MyBatis-Plus Repositories & Mappers"]:::service
        ESConfig["Elasticsearch Integration Config"]:::service
        OSSWrapper["Image Upload (OSS Wrapper)"]:::service
        AIChat["AI Chat Integrations"]:::service
        RabbitServiceConfig["RabbitMQ Auto-Config"]:::service
    end

    %% Core & API Models
    subgraph "Core Library"
        APIModels["Shared API Models\n(DTO/VO/Enums)"]:::core
        CoreUtils["Core Utilities & Auto-Configuration"]:::core
        RabbitCoreConfig["RabbitMQ Core Config"]:::core
        CacheCore["Redis Cache Utilities & Annotations"]:::core
    end

    %% Data Stores & External
    subgraph "Data Stores & External Services"
        MySQL["MySQL"]:::data
        Redis["Redis"]:::data
        ES["Elasticsearch"]:::data
        Mongo["MongoDB"]:::data
        RabbitMQ["RabbitMQ"]:::infra
        OSS["Alibaba OSS"]:::external
        ChatGPT["ChatGPT API"]:::external
        Xunfei["Xunfei Spark API"]:::external
    end

    %% Infrastructure
    subgraph "Infrastructure"
        Scripts["Deploy & Launch Scripts"]:::infra
    end

    %% Relationships
    SPA -->|"HTTP(S) REST"| WebModule
    SPA <-->|"WebSocket Chat"| WsConfig
    WebModule -->|"calls"| Services
    WebModule -->|"consumes events"| WebConsumers
    WebModule -->|"loads migrations"| Liquibase
    WebModule -->|"loads profiles"| EnvConfig
    WebModule -->|"configures cache"| CacheWebConfig

    Services -->|"uses DTOs"| APIModels
    Services -->|"uses utils"| CoreUtils
    Services -->|"publish/subscribe"| RabbitMQ
    Services -->|"calls repositories"| MyBatisJS
    Services -->|"indexes/search"| ES
    Services -->|"upload/download"| OSS
    Services -->|"calls external AI"| ChatGPT
    Services -->|"calls external AI"| Xunfei
    Services -->|"cache aside"| Redis
    Services -->|"consumes events"| RabbitServiceConfig

    RabbitMQ -->|"delivers to"| WebConsumers
    RabbitMQ -->|"delivers to"| Services

    MyBatisJS -->|"XML files"| Liquibase
    CacheCore -->|"provides annotations"| CacheWebConfig

    Scripts -->|"deploys containers"| SPA
    Scripts -->|"deploys containers"| WebModule
    Scripts -->|"deploys containers"| Services

    %% Click Events
    click SPA "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/pai-coding-front/"
    click APIModels "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-api/src/main/java/com/github/paicoding/forum/api/"
    click CoreUtils "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-core/src/main/java/com/github/paicoding/forum/core/"
    click Services "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-service/src/main/java/com/github/paicoding/forum/service/"
    click MyBatisJS "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-service/src/main/resources/mapper/"
    click MyBatisJS "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-service/src/main/java/com/github/paicoding/forum/service/*/repository/mapper/"
    click WebModule "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-web/src/main/java/com/github/paicoding/forum/web/"
    click RabbitCoreConfig "https://github.com/chgoh7/paicoding/blob/springboot3&vue3/paicoding-core/src/main/java/com/github/paicoding/forum/core/rabbitmq/RabbitMqConfig.java"
    click RabbitServiceConfig "https://github.com/chgoh7/paicoding/blob/springboot3&vue3/paicoding-service/src/main/java/com/github/paicoding/forum/service/notify/config/RabbitMqAutoConfig.java"
    click WebConsumers "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-web/src/main/java/com/github/paicoding/forum/web/mq/"
    click CacheCore "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-core/src/main/java/com/github/paicoding/forum/core/cache/"
    click CacheWebConfig "https://github.com/chgoh7/paicoding/blob/springboot3&vue3/paicoding-web/src/main/java/com/github/paicoding/forum/web/config/cache/CacheConfig.java"
    click ESConfig "https://github.com/chgoh7/paicoding/blob/springboot3&vue3/paicoding-service/src/main/java/com/github/paicoding/forum/service/config/es/ElasticsearchConfig.java"
    click OSSWrapper "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-service/src/main/java/com/github/paicoding/forum/service/image/oss/"
    click AIChat "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-service/src/main/java/com/github/paicoding/forum/service/chatai/"
    click WsConfig "https://github.com/chgoh7/paicoding/blob/springboot3&vue3/paicoding-web/src/main/java/com/github/paicoding/forum/web/controller/chat/ws/SimpleWsConfig.java"
    click Liquibase "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-web/src/main/resources/liquibase/changelog/"
    click EnvConfig "https://github.com/chgoh7/paicoding/tree/springboot3&vue3/paicoding-web/src/main/resources-env/"
    click Scripts "https://github.com/chgoh7/paicoding/blob/springboot3&vue3/deploy.sh"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085;
    classDef web fill:#d4edda,stroke:#155724,color:#155724;
    classDef service fill:#fdfd96,stroke:#856404,color:#856404;
    classDef core fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef data fill:#ffe5b4,stroke:#cc7a00,color:#cc7a00;
    classDef infra fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef external fill:#d1ecf1,stroke:#0c5460,color:#0c5460;
```
