How suyuan32/simple-admin-core works
Main Components
• API Service:
– Located in the “api” directory, it includes a “core.go” entry point, a collection of API descriptions, configuration files (e.g., “core.yaml”), and a well-defined layered structure comprising the “internal/handler” (controller layer) and “internal/logic” (business logic layer).
– Also includes middleware (e.g., authority_middleware) and internationalization (i18n) support.
• RPC Service:
– Found under the “rpc” directory. It contains similar layered subdirectories (logic, internal/server, internal/svc) that expose functionalities through protocol buffers (e.g., “core.proto”, “api.proto”, etc.).
– The RPC service leverages Ent for database operations as seen in the “rpc/ent” directory.
• Database:
– The project deploys databases (MySQL, PostgreSQL, MongoDB in some deploy directories) using containers and Kubernetes configurations.
– Database schema management is handled via Ent (schema definitions in “rpc/ent/schema” and similar files in “api/etc”).
• External Integrations & Tools:
– Casbin for RBAC and permission control
– Code generation utilities are integrated to produce consistent CRUD APIs across different modules.
– Docker and Kubernetes artifacts (docker-compose files in “deploy” and Kubernetes YAMLs in “deploy/k8s”) indicate containerized deployments with service discovery among the modules.
• Service Deployment and Monitoring:
– Several Dockerfiles (Dockerfile-api and Dockerfile-rpc) and deployment configurations are included, suggesting separate containerized services with built-in logging, tracing (jaeger deployment), and monitoring (Prometheus integration).
Relationships and Interactions
• The business logic layers in both API and RPC services communicate with the underlying Ent-based database layer.
• On the RPC side, show the use of protocol buffers and the connection to external systems or services (if, for example, a microservices architecture is used to decouple parts of the system).
• Deployment orchestration components to show that Docker Compose and Kubernetes are used to manage containers and service discovery.
Architectural Patterns and Design Principles
• Layered Architecture: Clearly reflect multiple layers – for API: routes → handlers → logic → data access; for RPC: similar breakdown with gRPC endpoints elaborated.
• Separation of Concerns: API endpoints and RPC calls each have their own packages (handlers, logic, internal service context) to enforce modularity.
• Microservice/Service-Oriented Approach: The clear separation of API and RPC into different Docker containers (as indicated by separate Dockerfiles and deployment directories) suggests loosely-coupled services.
• Use of modern frameworks (Go-Zero, Casbin) which themselves dictate patterns such as dependency injection and centralized error-handling.