feat: Introduce AI Brand Monitoring System V5 technical design document

- Added comprehensive technical design document for AI Brand Monitoring System V5, outlining system architecture, data models, sampling strategies, and monitoring protocols.
- Key changes include a shift to a sampling-based trend monitoring approach, updated data collection and storage strategies, and new metrics for performance evaluation.
- Implemented migration scripts to support the flattening of brand questions and versioning of question texts, ensuring historical data integrity and version control.
This commit is contained in:
2026-04-09 14:43:20 +08:00
parent 41f8e0621e
commit 36451a613d
18 changed files with 2709 additions and 234 deletions
@@ -94,25 +94,15 @@ type BrandKeyword struct {
}
type BrandQuestion struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
BrandID int64 `json:"brand_id"`
KeywordID int64 `json:"keyword_id"`
CurrentVersionID pgtype.Int8 `json:"current_version_id"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type BrandQuestionVersion struct {
ID int64 `json:"id"`
QuestionID int64 `json:"question_id"`
TenantID int64 `json:"tenant_id"`
BrandID int64 `json:"brand_id"`
KeywordID int64 `json:"keyword_id"`
QuestionText string `json:"question_text"`
QuestionHash string `json:"question_hash"`
VersionNo int32 `json:"version_no"`
IsActive bool `json:"is_active"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type Competitor struct {
@@ -146,6 +136,77 @@ type GenerationTask struct {
OperatorID pgtype.Int8 `json:"operator_id"`
}
type KnowledgeChunksMetum struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
KnowledgeItemID int64 `json:"knowledge_item_id"`
ChunkIndex int32 `json:"chunk_index"`
TokenCount int32 `json:"token_count"`
QdrantPointID string `json:"qdrant_point_id"`
ItemVersion int32 `json:"item_version"`
Status string `json:"status"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type KnowledgeGroup struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
Name string `json:"name"`
ParentID pgtype.Int8 `json:"parent_id"`
SortOrder int32 `json:"sort_order"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type KnowledgeItem struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
GroupID int64 `json:"group_id"`
SourceType string `json:"source_type"`
Name string `json:"name"`
SourceUri pgtype.Text `json:"source_uri"`
StorageKey string `json:"storage_key"`
ContentText pgtype.Text `json:"content_text"`
Status string `json:"status"`
SizeBytes int64 `json:"size_bytes"`
ItemVersion int32 `json:"item_version"`
ErrorMessage pgtype.Text `json:"error_message"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
MarkdownContent pgtype.Text `json:"markdown_content"`
}
type KnowledgeParseTask struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
KnowledgeItemID int64 `json:"knowledge_item_id"`
SourceType string `json:"source_type"`
Status string `json:"status"`
ErrorMessage pgtype.Text `json:"error_message"`
StartedAt pgtype.Timestamptz `json:"started_at"`
CompletedAt pgtype.Timestamptz `json:"completed_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type MediaPlatform struct {
ID int64 `json:"id"`
PlatformID string `json:"platform_id"`
Name string `json:"name"`
Category string `json:"category"`
ShortName string `json:"short_name"`
AccentColor string `json:"accent_color"`
LoginUrl pgtype.Text `json:"login_url"`
LogoUrl pgtype.Text `json:"logo_url"`
Status string `json:"status"`
SortOrder int32 `json:"sort_order"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type Plan struct {
ID int64 `json:"id"`
PlanCode string `json:"plan_code"`
@@ -157,6 +218,22 @@ type Plan struct {
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type PlatformAccount struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
PlatformID string `json:"platform_id"`
PlatformUid string `json:"platform_uid"`
Nickname string `json:"nickname"`
AvatarUrl pgtype.Text `json:"avatar_url"`
Status string `json:"status"`
MetadataJson []byte `json:"metadata_json"`
LastCheckAt pgtype.Timestamptz `json:"last_check_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type PlatformUserRole struct {
ID int64 `json:"id"`
UserID int64 `json:"user_id"`
@@ -166,6 +243,40 @@ type PlatformUserRole struct {
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type PluginInstallation struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
InstallationKey string `json:"installation_key"`
InstallationName string `json:"installation_name"`
BrowserName pgtype.Text `json:"browser_name"`
ClientVersion pgtype.Text `json:"client_version"`
InstallationTokenHash string `json:"installation_token_hash"`
Status string `json:"status"`
LastSeenAt pgtype.Timestamptz `json:"last_seen_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type PluginSession struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
PluginInstallationID pgtype.Int8 `json:"plugin_installation_id"`
ActionType string `json:"action_type"`
ResourceType pgtype.Text `json:"resource_type"`
ResourceID pgtype.Int8 `json:"resource_id"`
PlatformAccountID pgtype.Int8 `json:"platform_account_id"`
PlatformID string `json:"platform_id"`
SessionToken string `json:"session_token"`
ClientVersion pgtype.Text `json:"client_version"`
Status string `json:"status"`
ExpireAt pgtype.Timestamptz `json:"expire_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type PromptRule struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
@@ -191,6 +302,44 @@ type PromptRuleGroup struct {
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type PromptRuleKnowledgeGroup struct {
PromptRuleID int64 `json:"prompt_rule_id"`
KnowledgeGroupID int64 `json:"knowledge_group_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
}
type PublishBatch struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
ArticleID int64 `json:"article_id"`
InitiatorUserID int64 `json:"initiator_user_id"`
Status string `json:"status"`
PublishType string `json:"publish_type"`
CoverAssetUrl pgtype.Text `json:"cover_asset_url"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type PublishRecord struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`
PublishBatchID int64 `json:"publish_batch_id"`
ArticleID int64 `json:"article_id"`
PlatformAccountID int64 `json:"platform_account_id"`
PlatformID string `json:"platform_id"`
Status string `json:"status"`
ExternalArticleID pgtype.Text `json:"external_article_id"`
ExternalArticleUrl pgtype.Text `json:"external_article_url"`
ExternalManageUrl pgtype.Text `json:"external_manage_url"`
PublishedAt pgtype.Timestamptz `json:"published_at"`
RequestPayloadJson []byte `json:"request_payload_json"`
ResponsePayloadJson []byte `json:"response_payload_json"`
ErrorMessage pgtype.Text `json:"error_message"`
RetryCount int32 `json:"retry_count"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}
type QuotaReservation struct {
ID int64 `json:"id"`
TenantID int64 `json:"tenant_id"`