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 UBA Product Introduction
  • Architecture Reference

    • UBA System Architecture
    • UBA Backend Module Overview
    • UBA Backend API Contract
    • UBA Frontend Architecture
  • Developer Guide

    • UBA Installation Guide
    • UBA Code Generation Pipeline Tutorial
    • Adding an External Service Tutorial
    • Adding a Business Entity Tutorial
    • Adding a Frontend Page Tutorial
  • Operations Guide

    • UBA Docker Deployment Guide
    • UBA Configuration Reference & Security Checklist
    • UBA PM2 Deployment Guide
    • UBA Superset BI Deployment Guide
  • Analyst Guide

    • Data Analyst Getting Started Guide
    • Basic Aggregation

      • Event Trend Analysis
      • Active Users Analysis
      • Group By Aggregation
    • Conversion & Paths

      • Funnel Analysis
      • Retention Analysis
      • Top Conversion Paths
      • Behavior Sequence Analysis
    • User Depth

      • Attribution Analysis
      • Distribution Analysis
      • User Segmentation
      • Click Heatmap
      • Interval Analysis
    • Lifecycle

      • User Lifecycle
      • Churn & Reactivation Analysis
      • New vs Returning Users
      • Matrix Quadrant Analysis
    • Revenue & Value

      • Revenue Analysis
      • Whale Tier (Payer Segmentation)
      • Historical LTV Analysis
    • Sessions & Anomalies

      • Session Analysis
      • Period-over-Period Comparison and Anomaly Detection
    • Gaming

      • Level Analysis (Game)
      • Server Retention (Game)
      • Online Stats Analysis (Game)
      • Economy Analysis (Game)
    • OLAP Cookbook
  • SDK Integration

    • Web SDK Integration Guide
    • C# SDK Integration Guide (Unity / Godot / .NET)
  • Appendix

    • UBA Appendix: Ports, Glossary, Known Limitations & FAQ

UBA Backend Module Overview

This document organizes the GoWind UBA backend's code structure, the service layer inventory of the three services, the shared packages (pkg), and a directory quick reference, helping secondary developers locate code quickly.


1. Backend Directory Structure

backend/
├── api/                            # Protobuf API definitions and generated code
│   ├── protos/                     # .proto source files (layered by domain)
│   │   ├── admin/service/v1/       # Admin console HTTP gateway protos (the sole input for the TS client)
│   │   ├── uba/service/v1/         # UBA domain messages + gRPC service contracts
│   │   └── <other domains>/             # authentication / dict / permission / identity ...
│   └── gen/go/                     # Go code generated by buf
├── app/                            # Service applications
│   ├── admin/service/              # Admin service (admin console BFF, thin forwarding)
│   ├── collector/service/          # Collector service (event tracking ingestion BFF)
│   └── core/service/               # Core service (core business logic)
│       └── internal/
│           ├── data/               # Data layer (ent repo / OLAP repo / client)
│           │   ├── ent/schema/     # ent entity definitions (edit here → make ent)
│           │   ├── doris/          # Doris repo (with schema/ fact table definitions)
│           │   └── clickhouse/     # ClickHouse repo (with schema/ fact table definitions)
│           ├── service/            # Business service implementations
│           └── server/             # grpc / rest server registration
├── pkg/                            # Shared packages
├── sql/                            # Database scripts (clickhouse / doris / postgresql)
├── scripts/                        # Deployment scripts (deploy / docker / env)
└── Makefile                        # Code generation / build commands

Each service directory follows the standard kratos layout: cmd/server/ (entry point) + configs/ (YAML configuration) + internal/{conf,data,server,service}/.


2. Core Service (Core Business)

Directory: backend/app/core/service/internal/service/, carrying almost all business logic. Grouped by responsibility:

Data Collection & Events

ServiceCorresponding protoResponsibility
BehaviorEventServicebehavior_event.protoBehavior event ingestion (Create/BatchCreate), List/Get
SessionServicesession.protoSession fact table CRUD
EventPathServiceevent_path.protoUser path fact table CRUD
EventSchemaServiceevent_schema.protoEvent schema management (event name/property validation and registration)
ObjectServiceobject.protoBehavior object (object_type/object_id) management
ApplicationServiceapplication.protoUBA app management (generates appId/appKey/appSecret)

Analytics Modeling

ServiceCorresponding protoResponsibility
AnalyticsServiceanalytics.proto25 analysis models: covering seven major scenario groups — basic aggregations, conversion paths, in-depth user insights, lifecycle, revenue value, session anomalies, and game-specific (see Backend API · Analytics Aggregation Service). Branches to the Doris / ClickHouse repo based on the UseClickHouse compile-time constant

Risk & Tags

ServiceCorresponding protoResponsibility
RiskEventServicerisk_event.protoStorage/retrieval of risk event results (Create/BatchCreate/List)
RiskRuleServicerisk_rule.protoRisk rule definition CRUD
TagDefinitionServicetag_definition.protoTag definition CRUD
UserTagServiceuser_tag.protoUser tag associations
IdMappingServiceid_mapping.protoCross-platform ID mapping (identity graph)
UserBehaviorProfileServiceuser_behavior_profile.protoUser behavior profile fact table CRUD
WebhookServicewebhook.protoWebhook configuration (risk alert push)

Organization & Permissions

ServiceResponsibility
TenantServiceMulti-tenant management
UserService / UserCredentialServiceFull user lifecycle, login credentials
RoleService / PermissionService / PermissionGroupServiceRoles, permissions, permission groups
OrgUnitService / PositionServiceOrganization structure, positions
MenuServiceMenu nodes
DictTypeService / DictEntryServiceData dictionaries
LanguageServiceMulti-language
LoginPolicyServiceLogin policy
ApiServiceAPI metadata registration

System Operations

ServiceResponsibility
AuthenticationServiceLogin authentication, token issuance
FileService / FileTransferServiceFile storage (MinIO), file transfer
InternalMessageService (+ Category / Recipient)In-app messages
TaskServiceAsynchronous tasks (Asynq)
Audit logs (5 types)LoginAuditLogService / OperationAuditLogService / ApiAuditLogService / PermissionAuditLogService / DataAccessAuditLogService / PolicyEvaluationLogService

For the complete proto contracts, see Backend API Contract.


3. Admin Service (Admin Console BFF)

Directory: backend/app/admin/service/internal/service/. All implementations are thin forwarding: they implement adminV1.XxxHTTPServer and call the corresponding Core gRPC client (ubaV1.XxxClient) inside method bodies, with no business logic.

Admin services correspond one-to-one with Core services: analytics_service.go, application_service.go, behavior_event_service.go, risk_event_service.go, user_service.go, role_service.go, and about 40+ forwarding implementations in total.

For the complete steps to add a new external HTTP capability, see the Adding an External Service tutorial.


4. Collector Service (Ingestion BFF)

Directory: backend/app/collector/service/. Single responsibility: receives POST /uba/v1/report, performs application authentication and field validation/completion, then publishes to Kafka. It has no business service layer of its own; the logic is concentrated in the transport layer and pkg/topic (Kafka topic management).


5. Shared Packages (pkg)

Directory: backend/pkg/, shared by the three services:

PackageResponsibility
authorizerAuthentication engine wrapper (Casbin / OPA)
constantsConstant definitions
cryptoEncryption utilities (AES-GCM etc.)
jwtJWT utilities (issue/verify)
metadataRequest metadata management (tenantId injection etc.)
middlewareMiddleware (auth/logging/Ent/metadata)
ossObject storage (MinIO / S3 compatible)
serviceidService identity
taskAsynchronous tasks (Asynq wrapper)
topicKafka topic management (uba_events_raw / uba_risk_events)
utilsGeneral utilities
entgoEnt extensions (go-crud generic Repository wrapper, mixins, etc.)

6. Data Layer Essentials

PostgreSQL (Ent)

  • Entity definitions live in app/core/service/internal/data/ent/schema/, with table names declared via entsql.Annotation{Table: ...}.
  • There is no hand-written schema.sql — table structures are generated by make ent; sql/postgresql/ contains only dictionary seed data (default-data.sql) and demo data.
  • Business table prefixes: sys_ (system/RBAC/i18n/dictionaries), uba_ (UBA business), and others such as files, internal_messages.

OLAP (Doris / ClickHouse)

  • Fact table schemas are mirrored in app/core/service/internal/data/{clickhouse,doris}/schema/, consistent with the sql/{clickhouse,doris}/ scripts.
  • Main fact tables: events_fact, sessions_fact, risk_events, path_features; dimension tables: users_dim, objects_dim, id_mapping, user_tags.
  • Aggregation queries use native SQL (not Ent); dimension fields go through a whitelist, metrics go through a switch, and numeric values are strongly cast before concatenation to prevent injection.

7. Related Documentation

  • System Architecture
  • Backend API Contract
  • Frontend Architecture
  • Code Generation Pipeline
Edit this page
Last Updated:: 11/3/26, 2:14 PM
Contributors: Bobo
Prev
UBA System Architecture
Next
UBA Backend API Contract