How hamster-yhz/city-bag works
Main Components
• Frontend (city-bag-web): This module contains controllers, DTOs, static resources (like index.html), and REST endpoints. It serves as the public API layer and handles user interactions.
• Backend Service (city-bag-service): This module encapsulates the core business logic. It includes service interfaces, implementation classes, data mappers, domain models (entities/VOs), and integration components (e.g., with third-party APIs like Pexels and AI features). It also shows the use of message consumers (for RabbitMQ), exception handling, and other aspects.
• Application Starter (city-bag-start): This module is responsible for application bootstrapping. It includes configuration classes (AOP for logging, token verification, scheduling, thread pools, Redis, Mybatis Plus, etc.), main application startup, and integration configurations. It coordinates the system’s initialization and external resource connectivity.
• Data Sources & External Services:
• Database: SQL scripts in docs/dev-ops/mysql indicate a MySQL database for storing travel-related data (cities, dormitories, foods, scenic spots, user information, etc.).
• Cache: Redis is integrated (with packages for Redis service and configuration) for caching and perhaps session storage.
• Message Broker: RabbitMQ is set up (with configuration classes) for handling asynchronous messaging (e.g., like message and user visit record consumers).
• File Storage & OSS: There is an OSS service implementation to handle cloud storage or file management.
• External APIs: Modules such as demos/Pexels and demos/AI suggest integration with external services for images and chat features.
• Supporting Tools & Infrastructure:
• Docker / Kubernetes: Dockerfiles and docker-compose files in both city-bag-start and docs/dev-ops point to containerization and orchestration.
Relationships and Data Flow
• Client/Browser requests hit the city-bag-web module. These HTTP requests (RESTful API calls) are directed to corresponding controllers.
• The controllers in city-bag-web then make calls to the service layer (either directly or via API calls to city-bag-start, if the latter is acting as a gateway).
• The city-bag-start module acts as the application starter, loading core configurations (AOP, thread pools, scheduling, Redis, Mybatis configurations) and then invoking services from city-bag-service for actual business logic.
• Within the service layer (city-bag-service), business logic is executed, which may involve:
• Database interactions via mappers (MyBatis)
• Use of caching via Redis and Redisson
• Asynchronous messaging via RabbitMQ for tasks such as like-message processing and user visit record handling
• File and image processing using OSS services and photo building strategies
• Integration with third-party APIs, like Pexels for images and AI modules for chat functionality.
• The persistence layer is backed by a MySQL database, with supporting SQL scripts provided in the docs.
• External services like OSS, RabbitMQ, and Redis are clearly separated and connected to the main business layer.
Architectural Patterns and Design Principles
• Modularization: Each module has a defined responsibility (API handling, business logic, configuration/startup) and communicates through clearly defined interfaces.
• Use of AOP: There is cross-cutting concern management (logging, token verification) via aspects.
• Containerization & DevOps: Include a container (Docker) layer and deployment orchestration to show how the application is packaged and launched.