# go-server-center **Repository Path**: netbycom/go-server-center ## Basic Information - **Project Name**: go-server-center - **Description**: GoServerCenter (GSC) 是一个轻量级、无侵入式的微服务管理与监控系统,采用 Go 语言开发。它提供了一个强大的控制平面,支持服务注册发现、实时监控、集中化配置管理以及 API 网关功能。 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-03-22 - **Last Updated**: 2026-03-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # GoServerCenter (GSC) 🚀 GoServerCenter is a lightweight, non-intrusive service management and monitoring system written in Go. It provides a robust control plane for microservices with built-in persistence, real-time monitoring, and centralized configuration. ![alt text](image.png) ## ✨ Features - **Layered Architecture**: Clean separation of concerns (Models -> Data Access -> Service Logic -> HTTP Handlers). - **MySQL Persistence**: Service status, configurations, and call logs are stored in MySQL via GORM. - **Secure Management Console**: Premium dashboard protected by bcrypt-hashed authentication. - **Dynamic Configuration**: Centralized `config.yaml` for system settings. - **Auto Registration**: Services register themselves via the SDK on startup. - **API Gateway**: Centralized routing and load balancing for all service-to-service calls. - **Full Traceability**: Real-time visualization of the service dependency graph and call logs. ## 🏗️ Project Structure - `cmd/registry`: The Control Plane (Entry point for the Service Registry). - `cmd/gateway`: The Data Plane (API Proxy & Load Balancer). - `pkg/registry`: Core business logic for service management. - `pkg/models`: Shared domain models and GORM entities. - `pkg/db`: Database connection and ORM initialization. - `pkg/config`: Configuration loading system (YAML). - `pkg/sdk`: Client-side SDK for seamless integration. - `ui`: Modern, glassmorphism-style React management console. ## 🚀 Quick Start ### 1. Database Setup Ensure you have a MySQL server running. By default, GSC uses the `registry_center` database. You can customize the credentials in `config.yaml`. ```sql CREATE DATABASE IF NOT EXISTS registry_center; ``` ### 2. Configuration Review and edit `config.yaml` in the root directory: ```yaml server: port: 8312 gateway: port: 9100 database: dsn: "root:password@tcp(127.0.0.1:3306)/registry_center?charset=utf8mb4&parseTime=True&loc=Local" auth: default_admin: username: "admin" password: "admin_password" # Will be hashed on first run ``` ### 3. Run Components **Build & Run Registry**: ```bash go build -o bin/registry.exe ./cmd/registry ./bin/registry.exe ``` > Accessible at `http://localhost:8312`. Log in with `admin` / `admin_password`. **Run API Gateway**: ```bash go run cmd/gateway/main.go ``` > Accessible at `http://localhost:9100`. **Run Demo Service**: ```bash # Power Shell example $env:PORT=8081; $env:SERVICE_NAME="order-service"; go run cmd/demo-app/main.go ``` ## 🛠️ Usage in Your App Import the SDK and initialize the client: ```go import "go-server-center/pkg/sdk" client := sdk.NewClient(sdk.Config{ ServiceName: "user-service", Port: 8080, RegistryURL: "http://localhost:8312", GatewayURL: "http://localhost:9100", Version: "1.0.0", }) _ = client.Start() ``` **Call Another Service via Gateway**: ```go resp, err := client.CallService("order-service", "/api/v1/orders", "GET", nil) ``` ## 🔒 Security - Dashboards and sensitive APIs are protected by **Token-based Authentication**. - User passwords are encrypted using **bcrypt** (salt cost: 10). - Default credentials can be customized in the configuration file before the first launch. --- Built with ❤️ for Modern Microservices.