# 201206030/novel-cloud architecture

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

- Interactive diagram: https://gitdiagram.com/201206030/novel-cloud
- Repository: https://github.com/201206030/novel-cloud

## Overview

##### Project type and purpose
- This is a full‐stack, microservice‐based novel portal platform (“novel-cloud”) built on Spring Cloud (Alibaba), Spring Boot 3, Vue 3.  It provides novel home page, news, book management, user/member center, author center, resource upload, search capabilities, and monitoring.

##### Main components
- API Gateway (novel-gateway)
- Config & Discovery (Nacos, Spring Cloud Config)
- Business microservices:
- novel-home – homepage recommendations, friend links
- novel-news – news publishing
- novel-book – book/catalog/chapter/comment services
- novel-user – user registration, login, profile, bookshelf, reading history
- novel-author – author registration, income, author dashboard
- novel-resource – file uploads (images, captchas)
- novel-search – scheduled indexing to Elasticsearch, search API
- Infrastructure services:
- novel-monitor – Spring Boot Admin based health/metrics dashboard
- RabbitMQ – async messaging (e.g., events, notifications)
- MySQL (with ShardingSphere‐JDBC) – persistent storage
- Redis/Caffeine – cache layers
- Elasticsearch – full‐text search engine
- XXL-JOB – scheduled tasks for reindexing
- Shared libraries (novel-core): common DTOs, auth utilities, constants, config wrappers

##### Interactions & data flows
a. All external requests enter through novel-gateway (Spring Cloud Gateway).
b. novel-gateway uses service discovery (Nacos) to route to individual services.
c. Each service loads shared config from Nacos/Spring Config.
d. Services call one another via Feign clients (e.g., home calls book/user APIs; author calls book API; user and book emit/read messages via RabbitMQ).
e. Business services persist to MySQL (with sharding if configured) and cache frequent lookups in Redis/Caffeine.
f. novel-search polls or listens to change events (via RabbitMQ or XXL-JOB) to index data into Elasticsearch.
g. novel-monitor periodically polls all services’ /actuator endpoints for health and metrics.
h. novel-resource handles file uploads, stores metadata in Redis (e.g., captcha codes), and relays files to blob store or CDN.

##### Architectural patterns & principles
- Microservices with single‐responsibility service per domain
- API Gateway for unified entrypoint, authentication, CORS, rate‐limiting
- Service Discovery + Config Center (Nacos) for dynamic topology and centralized configuration
- Shared “core” libraries for consistency (auth, DTOs, constants)
- Declarative REST via Feign for inter-service calls
- Asynchronous messaging (RabbitMQ) for loose coupling and event propagation
- Cache Aside pattern: Redis/Caffeine for read‐heavy endpoints
- Scheduled tasks (XXL-JOB) for bulk operations (e.g., rebuild search index)
- Monitoring & alerting via Spring Boot Admin

##### Main business services & their communication
- home → book, home → news, home → user
- book → user, book → author
- author → book
- Search consuming book/user/author updates via MQ or scheduler.
- At bottom, show MySQL cluster, Redis/Caffeine cache, Elasticsearch, RabbitMQ, XXL-JOB, Nacos/Config.
- At top or side, show novel-monitor polling each service.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Entry Point"
        NG["novel-gateway"]:::gateway
    end

    subgraph "Business Services"
        NH["novel-home"]:::business
        NN["novel-news"]:::business
        NB["novel-book"]:::business
        NU["novel-user"]:::business
        NA["novel-author"]:::business
        NR["novel-resource"]:::business
        NS["novel-search"]:::business
    end

    NG -->|"REST/Feign"| NH
    NG -->|"REST/Feign"| NN
    NG -->|"REST/Feign"| NB
    NG -->|"REST/Feign"| NU
    NG -->|"REST/Feign"| NA
    NG -->|"REST/Feign"| NR
    NG -->|"REST/Feign"| NS

    NH -->|"REST/Feign"| NB
    NH -->|"REST/Feign"| NN
    NH -->|"REST/Feign"| NU

    NB -->|"REST/Feign"| NU
    NB -->|"REST/Feign"| NA

    NA -->|"REST/Feign"| NB

    NB -.->|"RabbitMQ"| NS
    NU -.->|"RabbitMQ"| NS
    NA -.->|"RabbitMQ"| NS

    click NG "https://github.com/201206030/novel-cloud/blob/master/novel-gateway/src/main/java/io/github/xxyopen/novel/gateway/NovelGatewayApplication.java"
    click NH "https://github.com/201206030/novel-cloud/blob/master/novel-home/src/main/java/io/github/xxyopen/novel/home/NovelHomeApplication.java"
    click NN "https://github.com/201206030/novel-cloud/blob/master/novel-news/novel-news-service/src/main/java/io/github/xxyopen/novel/news/NovelNewsApplication.java"
    click NB "https://github.com/201206030/novel-cloud/blob/master/novel-book/novel-book-service/src/main/java/io/github/xxyopen/novel/book/NovelBookApplication.java"
    click NU "https://github.com/201206030/novel-cloud/blob/master/novel-user/novel-user-service/src/main/java/io/github/xxyopen/novel/user/NovelUserApplication.java"
    click NA "https://github.com/201206030/novel-cloud/blob/master/novel-author/novel-author-service/src/main/java/io/github/xxyopen/novel/author/NovelAuthorApplication.java"
    click NR "https://github.com/201206030/novel-cloud/blob/master/novel-resource/src/main/java/io/github/xxyopen/novel/resource/NovelResourceApplication.java"
    click NS "https://github.com/201206030/novel-cloud/blob/master/novel-search/src/main/java/io/github/xxyopen/novel/search/NovelSearchApplication.java"

    classDef gateway fill:#a2f5a2,stroke:#333,stroke-width:1px;
    classDef business fill:#a2d1f2,stroke:#333,stroke-width:1px;
    class NG gateway
    class NH,NN,NB,NU,NA,NR,NS business
```
