How vivo/moonbox works
Main Components
• Frontend Client: Represent the “client” directory and its Vue components, which include the main App, routes, store (Vuex), and other UI elements. This provides the user interface for both flow recording and replay monitoring.
• Backend Services: Clearly show the layered backend architecture:
– The core server (in the moonbox-server module), which is responsible for receiving traffic requests (entry calls) from agents.
– Service modules such as moonbox-service-agent, moonbox-service-console, moonbox-service-data, etc., that implement business logic for recording, replay, configuration management, and analysis.
– The data access layer (DAL) in the moonbox-dal module that uses MyBatis to interact with a MySQL database.
– The integration with Redis, Elasticsearch, or other storage systems (as indicated in folders like “db/mysql” and “docker/redis”, and modules such as moonbox-service-data-es and moonbox-service-data-redis).
• Agent and Plugin Engine:
– The moonbox-agent and its local deployment assets (e.g., local-agent, moonbox-agent, and corresponding Docker images) that capture the traffic from entry points by leveraging Java instrumentation.
– The plugins directory that contains many submodules (dubbo, motan, okhttp, etc.) following an SPI design that intercepts sub-calls during both recording and replay.
• Infrastructure and Deployment:
– The Docker directory with compose files and Dockerfiles shows that each major component (e.g., MySQL, Redis, web server) is containerized.
– The “db” directory that includes the DDL files for the MySQL database.
Architectural Patterns & Design Principles
• Separation of concerns by differentiating between the presentation layer (Vue client), the business/service layer (Java REST/Controller modules, service implementations), and the data layer (DAL and database connectors).
• Use of SPI for extensibility (a plug-in based design) and the micro-modular approach that splits responsibilities among different Maven modules.
• Containerization of the platform using Docker, which separates the runtime environments and supports scalable deployment in production.
Technologies and Frameworks
• Frontend: Vue.js, Vue Router, Vuex, Babel, Gulp.
• Backend: Java (Spring Framework, MyBatis), Maven-based multi-module project, with heavy use of SPI plugins for RPC mocking.
• Database: MySQL (schema in db/mysql and mapping files in moonbox-dal), Redis (docker/redis), ElasticSearch (in moonbox-service-data-es).
• Deployment: Docker and docker-compose for orchestration.