How rushteam/beauty works
Project Overview – Identify Major Architectural Blocks
• Core Application: The framework’s central build (starting with beauty.go) and its factory functions (e.g., beauty.New) that wire together various services.
• Service Types: Mark distinct service entries for HTTP servers (web server), gRPC servers (gRPC Server), and Cron jobs.
• Infrastructure Modules: Identify supporting modules such as configuration (pkg/conf), logging (pkg/logger), tracing (pkg/tracing), and unique utilities (pkg/xgo, pkg/uuid, pkg/libs).
• Discovery & Registry: Include registry/discovery components that support etcd (pkg/discover/etcdv3) and nacos (pkg/discover/nacos) integrations.
• Tools and CLI: Represent the CLI tool (tools/cmd/beauty) and supporting parser/template utilities. They are used for creating new projects and scaffolding code.
• Application Entry Point: Start with a “Beauty Application Bootstrap” component. Indicate that it initializes lifecycle hooks and service registrations.
• Service Layer(s): Create separate nodes for each type of service:
• HTTP Server: This node uses an underlying router (e.g., using chi or gin in example usage) and is configured via YAML files.
• gRPC Server: Display a node with API components including the Protocol Buffers generated files (service.pb.go, service_grpc.pb.go, etc.) showing how service definitions are turned into server implementations.
• Cron Services: Include the cron job execution component (pkg/service/cron) with scheduling patterns.
• Supporting Infrastructure:
• Configuration: A node for YAML configuration files (config/config.yaml) and related loaders (pkg/conf/nacos_loader.go).
• Discovery & Registry: Nodes for etcdv3 and nacos-based service discovery modules.
• Tracing & Metrics: A block representing OpenTelemetry/Prometheus integration and the dedicated tracer (pkg/tracing).
• Logging: Represent logging frameworks from pkg/logger.
• Utility and Client Modules: Add components for auxiliary functions such as UUID generation, address handling, and load balancing for gRPC (pkg/client/grpcclient).
Relationships and Interactions
• That configuration data flows from YAML files into the configuration modules which in turn influence runtime behavior.
• Demonstrate that the discovery modules (etcd, nacos) interact with the service components to register and discover service endpoints.
• Tracing and logging as cross-cutting concerns that pipe into each service component.
• For the CLI and toolchain, show them feeding into new project creation processes; they generate configurations and scaffolding (e.g., templates in tools/tpls).
Architectural Patterns and Technologies
• Microservices Pattern: Emphasize how the framework enables running different service types (HTTP, gRPC, Cron) under a unified process.
• Dependency Injection: Illustrate that initialization options (e.g., beauty.WithWebServer, beauty.WithRegistry) are used to wire dependencies.
• Extensibility: Mark extension points such as lifecycle hooks and differentiation between core functionalities and infrastructure (for example, signal handling and graceful shutdown via pkg/signals).
• Key Technologies and Libraries: Note the use of Go’s native modules (go.mod, go.sum), buf for Protocol Buffers, third-party routers (chi, gin), grpc and grpc-gateway, and OpenTelemetry for metrics/tracing.