How iggzq/ahut_forum works
Project Type and Purpose
• This is a full-stack, distributed microservices campus forum application (“桃李山屋”).
• Frontend: Vue3 SPA (UserWeb) served via Nginx.
• Backend: Spring Boot 3 + Spring Cloud microservices (user_mod, article_mod, chat_room, search_mod), plus a shared/common library.
• Data stores: MySQL (users, articles, comments, likes), Redis (sessions/cache), Elasticsearch (search index).
• Real-time chat: WebFlux WebSocket.
File Structure Highlights
• Top-level: Dockerfile, .github workflows, root pom.xml (multi-module Maven).
• UserWeb/: Vue3 frontend with Nginx config, CSS assets, router/store, env files for dev/prod/test.
• user_mod/: Spring Boot user service (MyBatis, Sa-Token auth, Redis).
• article_mod/: Article service (controllers, services, mappers, Feign clients to user_mod & search_mod, Redis config).
• chat_room/: WebFlux WebSocket chat service.
• search_mod/: Elasticsearch-backed search service (document model, repository, Feign endpoint for article_mod).
• common/: Shared entities & result wrappers.
• sqls/: DDL scripts for MySQL schemas.
Core Components
a. Frontend Layer
• Vue3 SPA (UserWeb) deployed behind Nginx (serving static assets + reverse proxy).
b. API Layer (could be an API Gateway or Nginx routing)
• Routes HTTP/REST calls from SPA to microservices.
c. Microservices
• User Service (user_mod): user registration, login, profile, auth via Sa-Token + Redis.
• Article Service (article_mod): CRUD articles/comments/likes, Feign→User Service for user info, Feign→Search Service to index articles.
• Chat Service (chat_room): real-time chat over WebFlux WebSocket.
• Search Service (search_mod): indexes article documents in Elasticsearch, exposes search REST endpoints, Feign→Article Service for sync.
• Common Library: shared DTOs/entities used by all services.
d. Data Stores
• MySQL instance(s): separate schemas or databases per service (users, articles, comments, likes).
• Redis cluster: session storage, caching, Sa-Token session store.
• Elasticsearch cluster: article search index.
e. External / DevOps
• Docker containers for each service & frontend.
• CI/CD via GitHub Actions (docker-publish.yml).
• Configuration profiles: application-dev/prod/test YAMLs.
Interactions & Data Flows
1. UserWeb → HTTP/REST → API Gateway/Nginx → appropriate service endpoint.
2. Article Service → Feign → User Service (to fetch author info).
3. Article Service → Feign → Search Service (to create/update ArticleDocument in Elasticsearch).
4. Search Service ↔ Elasticsearch (index & query).
5. All services ↔ MySQL (via MyBatis mappers & XML).
6. All services ↔ Redis (session, cache).
7. UserWeb ↔ WebSocket → Chat Service (for real-time chat rooms).
Architectural Patterns & Design Principles
• Microservices: each bounded context in its own module & DB.
• Shared library for common cross-cutting models (common/).
• API Gateway (or Nginx reverse proxy) for routing and CORS.
• Service-to-service calls via Spring Cloud OpenFeign.
• Eventual consistency between Article Service and Search Service (via synchronous Feign).
• Real-time comms with WebFlux WebSocket in a separate service.
• Configuration & profiles for different environments.
• Containerization: Docker for each module, orchestrated via CI/CD.
Diagramming Conventions
• Use clear, descriptive labels on each node (e.g., “Article Service (SpringBoot+MyBatis)”).
• Frontend (blue)
• API Gateway (orange)
• Microservices (green shades)
• Datastores (red)
• Search (purple)
• Rectangles for services and frontend
• Parallelograms for API Gateway/Nginx