GoWindGoWind
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
Home
Framework
GoWind Toolkit
  • Open Source

    • GoWind Admin (Admin Platform)
    • GoWind CMS (Content Management)
    • GoWind UBA (Behavior Analytics)
    • GoWind Shop (E-commerce)
    • GoWind Kanban (Kanban Boards)
    • GoWind Ledger (Personal Finance)
    • GoWind ShortPlay (Short Drama)
    • GoWind Ops (Operations Platform)
    • RushWind (Rust Ecosystem)
  • Open Core (Community + Enterprise)

    • GoWind OA (Office Collaboration)
    • GoWind ERP (Procure-to-Pay)
    • GoWind WMS (Warehousing)
  • Commercial

    • GoWind IM (Instant Messaging)
    • GoWind IoT (IoT Platform)
    • GoWind Edu (AI Education)
    • GoWind MES (Manufacturing Execution)
    • GoWind CDC (Data Pipeline)
    • GoWind SDP (Zero-Trust Gateway)
    • GoWind Quant (Quant Research)
    • GoWind Trade Radar (Export Sourcing)
    • GoWind Game Radar (Game Greenlight)
  • 简体中文
  • English
GitHub
  • Introduction

    • GoWind Admin Product Introduction
    • GoWind Admin Installation Guide
    • Release Notes
  • Backend

    • Backend Architecture Overview
    • Backend Core Modules in Depth
    • Backend API & Protobuf Definitions
    • Backend Configuration & Deployment
    • Backend Extension Development
  • Frontend

    • Frontend Architecture Overview
    • Frontend Core Features in Depth
  • Secondary-Dev Tutorials

    • Backend Tutorial: Adding a New Business Module
    • Frontend Tutorial: Adding a New Business Page
    • Full-Stack Integration Tutorial
  • Advanced Tutorials

    • Lua Script Extension Tutorial
    • Permission System in Depth
    • Multi-Tenancy Architecture Tutorial
    • Task Scheduling and Asynchronous Processing
    • File Upload and Object Storage
    • Event Bus and Decoupled Architecture
    • Frontend Theming and Internationalization
    • Performance Optimization and Monitoring
    • SSE Real-Time Push
    • Login Policies and Security Hardening
    • Encryption Toolkit in Practice

Backend API & Protobuf Definitions

The GoWind Admin backend follows a Protobuf First API development model: all endpoints are defined in Protobuf, and the Buf toolchain automatically generates the Go server code, TypeScript client code, and OpenAPI documentation.

1. Protobuf Organization

All Protobuf definition files are located under the backend/api/protos/ directory, organized by business domain:

api/protos/
├── admin/service/v1/       # Admin service interface definitions (HTTP routes, request/response messages)
├── audit/                  # Audit log message definitions
├── authentication/         # Authentication message definitions
├── dict/                   # Dictionary management message definitions
├── identity/               # Identity management message definitions (user, role, org, tenant, etc.)
├── internal_message/       # Internal message definitions
├── permission/             # Permission management message definitions
├── storage/                # File storage message definitions
└── task/                   # Task scheduling message definitions

Module Descriptions

Module DirectoryResponsibilities
admin/service/v1/Defines RPC services and HTTP route mappings; the entry-point definitions of the API
authentication/Login request/response, token payload, user credentials, and other messages
identity/Entity messages for User, Role, OrgUnit, Tenant, department, position, etc.
permission/Permission, PermissionGroup, Menu, and other messages
dict/DictType and DictEntry messages
audit/Various audit log messages
internal_message/Internal messages, message categories, message recipients
storage/File upload/download messages
task/Task scheduling messages

2. Service Definition Conventions

Using the authentication service as an example of a standard Service definition:

syntax = "proto3";

package admin.service.v1;

import "gnostic/openapi/v3/annotations.proto";
import "google/api/annotations.proto";
import "google/protobuf/empty.proto";
import "authentication/service/v1/authentication.proto";

// Backend login authentication service
service AuthenticationService {
  // Login
  rpc Login (authentication.service.v1.LoginRequest) returns (authentication.service.v1.LoginResponse) {
    option (google.api.http) = {
      post: "/admin/v1/login"
      body: "*"
    };
    option(gnostic.openapi.v3.operation) = {
      security: {}
    };
  }

  // Logout
  rpc Logout (google.protobuf.Empty) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      post: "/admin/v1/logout"
      body: "*"
    };
  }
}

Key Conventions

  1. HTTP route mapping: the HTTP method and path are specified via the google.api.http annotation
  2. Unified prefix: all Admin API routes are prefixed with /admin/v1/
  3. OpenAPI security annotation: endpoints that require no authentication are annotated with security: {} (e.g. login, captcha)
  4. Package naming: admin.service.v1 is used for Service definitions; other messages are packaged by domain

3. API Endpoint List

1. Authentication Service (AuthenticationService)

MethodRouteDescription
POST/admin/v1/loginUser login
POST/admin/v1/logoutUser logout
POST/admin/v1/registerUser registration
POST/admin/v1/refresh-tokenRefresh token
GET/admin/v1/captchaGenerate captcha
POST/admin/v1/captcha/verifyVerify captcha

2. User Management Service

MethodRouteDescription
POST/admin/v1/userCreate user
PUT/admin/v1/user/{id}Update user
DELETE/admin/v1/user/{id}Delete user
GET/admin/v1/user/{id}Get user details
GET/admin/v1/userUser list query

3. Tenant Management Service

MethodRouteDescription
POST/admin/v1/tenantCreate tenant
PUT/admin/v1/tenant/{id}Update tenant
DELETE/admin/v1/tenant/{id}Delete tenant
GET/admin/v1/tenant/{id}Get tenant details
GET/admin/v1/tenantTenant list query

4. Role Management Service

MethodRouteDescription
POST/admin/v1/roleCreate role
PUT/admin/v1/role/{id}Update role
DELETE/admin/v1/role/{id}Delete role
GET/admin/v1/role/{id}Get role details
GET/admin/v1/roleRole list query

5. Permission Management Service

MethodRouteDescription
POST/admin/v1/permissionCreate permission
PUT/admin/v1/permission/{id}Update permission
DELETE/admin/v1/permission/{id}Delete permission
GET/admin/v1/permission/{id}Get permission details
GET/admin/v1/permissionPermission list query

6. Menu Management Service

MethodRouteDescription
POST/admin/v1/menuCreate menu
PUT/admin/v1/menu/{id}Update menu
DELETE/admin/v1/menu/{id}Delete menu
GET/admin/v1/menu/{id}Get menu details
GET/admin/v1/menuMenu list query

7. Organization Management Service

MethodRouteDescription
POST/admin/v1/org-unitCreate org unit
PUT/admin/v1/org-unit/{id}Update org unit
DELETE/admin/v1/org-unit/{id}Delete org unit
GET/admin/v1/org-unit/{id}Get org unit details
GET/admin/v1/org-unitOrg unit list query

8. Dictionary Management Service

MethodRouteDescription
POST/admin/v1/dict-typeCreate dict type
PUT/admin/v1/dict-type/{id}Update dict type
DELETE/admin/v1/dict-type/{id}Delete dict type
GET/admin/v1/dict-typeDict type list query
POST/admin/v1/dict-entryCreate dict entry
PUT/admin/v1/dict-entry/{id}Update dict entry
DELETE/admin/v1/dict-entry/{id}Delete dict entry
GET/admin/v1/dict-entryDict entry list query

9. File Management Service

MethodRouteDescription
POST/admin/v1/fileCreate file record
PUT/admin/v1/file/{id}Update file record
DELETE/admin/v1/file/{id}Delete file
GET/admin/v1/file/{id}Get file details
GET/admin/v1/fileFile list query
POST/admin/v1/file/uploadUpload file
GET/admin/v1/file/download/{id}Download file

10. Internal Message Service

MethodRouteDescription
POST/admin/v1/internal-messageCreate message
PUT/admin/v1/internal-message/{id}Update message
DELETE/admin/v1/internal-message/{id}Delete message
GET/admin/v1/internal-message/{id}Get message details
GET/admin/v1/internal-messageMessage list query
POST/admin/v1/internal-message-categoryCreate message category
GET/admin/v1/internal-message-categoryMessage category list

11. Task Scheduling Service

MethodRouteDescription
POST/admin/v1/taskCreate task
PUT/admin/v1/task/{id}Update task
DELETE/admin/v1/task/{id}Delete task
GET/admin/v1/task/{id}Get task details
GET/admin/v1/taskTask list query

12. Dashboard Service (AdminPortalService)

MethodRouteDescription
GET/admin/v1/portal/dashboardGet dashboard data

13. Audit Log Service

MethodRouteDescription
GET/admin/v1/login-audit-logLogin log list query
GET/admin/v1/api-audit-logAPI audit log list query
GET/admin/v1/operation-audit-logOperation log list query
GET/admin/v1/data-access-audit-logData access log list query

4. Code Generation

1. Buf Configuration

Buf configuration files are located in the api/ directory:

FileDescription
buf.yamlModule definition
buf.gen.yamlGo code generation configuration
buf.admin.openapi.gen.yamlOpenAPI documentation generation configuration
buf.vue-vben.admin.typescript.gen.yamlTypeScript generation configuration for the Vue Vben edition
buf.vue-element.admin.typescript.gen.yamlTypeScript generation configuration for the Vue Element edition
buf.react.admin.typescript.gen.yamlTypeScript generation configuration for the React edition

2. Generation Commands

# Generate Go server code (HTTP handlers, message types, error codes)
make api

# Generate OpenAPI v3 documentation
make openapi

# Generate TypeScript client code (Vue Vben + Vue Element + React)
make ts

# Generate everything in one go (Ent + Wire + API + OpenAPI)
make gen

3. Generated Code Output

api/gen/go/              # Go code
├── admin/service/v1/    # Admin service generated code (HTTP handlers, interface definitions)
├── audit/service/v1/    # Audit service generated code
├── authentication/      # Authentication message code
├── dict/                # Dictionary message code
├── identity/            # Identity message code
├── internal_message/    # Internal message code
├── permission/          # Permission message code
├── storage/             # Storage message code
└── task/                # Task message code

5. Swagger UI

Swagger UI is enabled by default in the development environment, accessible at: http://localhost:7788/docs/

Swagger UI is integrated via kratos-swagger-ui and registered in rest_server.go:

if cfg.GetServer().GetRest().GetEnableSwagger() {
    swaggerUI.RegisterSwaggerUIServerWithOption(
        srv,
        swaggerUI.WithTitle("GoWind Admin"),
        swaggerUI.WithMemoryData(assets.OpenApiData, "yaml"),
    )
}

OpenAPI documentation URLs:

  • Swagger UI: http://localhost:7788/docs/
  • OpenAPI YAML: http://localhost:7788/docs/openapi.yaml

6. Error Code Definitions

Error codes are defined in Protobuf and automatically generate Go error types. The error code definition file is admin_error.proto:

enum ErrorReason {
  option (errors.default_code) = 500;

  INTERNAL_SERVER_ERROR = 0;
  INVALID_GRANT_TYPE = 1;
  INCORRECT_REFRESH_TOKEN = 2;
  FORBIDDEN = 3;
  // ...
}

The generated error types support HTTP status code mapping and can be used directly in the Service layer:

return nil, authenticationV1.ErrorInvalidGrantType("invalid grant type")

7. Adding a New API

Step 1: Define the Protobuf

Create or modify a .proto file under the corresponding directory in api/protos/:

syntax = "proto3";
package admin.service.v1;

import "google/api/annotations.proto";

service MyNewService {
  rpc GetMyData (GetMyDataRequest) returns (GetMyDataResponse) {
    option (google.api.http) = {
      get: "/admin/v1/my-data"
    };
  }
}

message GetMyDataRequest {
  uint32 id = 1;
}

message GetMyDataResponse {
  string name = 1;
}

Step 2: Generate the Code

make api

Step 3: Implement the Service

Create my_new_service.go under internal/service/, implementing the generated interface.

Step 4: Register with the Server

Register the new Service Handler in internal/server/rest_server.go.

Step 5: Regenerate Wire

cd app/admin/service/cmd/server
wire

8. Related Documents

  • Backend Architecture Overview
  • Backend Core Modules in Depth
  • Backend Configuration & Deployment
Edit this page
Last Updated:: 11/3/26, 2:14 PM
Contributors: Bobo
Prev
Backend Core Modules in Depth
Next
Backend Configuration & Deployment