Files
aiops/docs/project-structure.md
T
attacker 73b5a48df9 refactor: 全局代码模块化重构 — 所有文件<700行
后端 handler 拆分:
- automation.go(1067→4文件), server.go(1011→5文件), ldap.go(815→3文件), user.go(704→2文件)

前端组件拆分:
- SystemManager(1782→569), AlertManager(1133→220), K8sClusters(1062→4文件)
- Dashboard(941→4文件), ServerManager(905→640), ApprovalFlow(830→548)
- AlertCenter(775→693), AIPredictiveAnalytics(760→670)
- CloudBilling(728→663), GrafanaDashboard(717→643), sidebar(726→689)

Mock 数据模块化:
- mocks/data.ts(2552行→barrel+11个domain模块)

新增 CLAUDE.md 项目全局开发规范

修复: AlertCenter/LogManager ListResponse.data→.list 类型不匹配
验证: go build ✅ + tsc --noEmit ✅ + npm run build ✅
2026-06-15 01:32:15 +08:00

174 lines
8.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 项目结构
## 整体结构
```
aiops/
├── frontend/ # 前端 (React 18 + TypeScript + Vite)
│ ├── src/
│ │ ├── components/ # 业务组件(每个 <700行,超限已模块化拆分)
│ │ │ ├── agent/ # Agent 监控
│ │ │ ├── aiops/ # AI 智能运维(AIPredictiveAnalytics 含 PredictiveCapacityTab)
│ │ │ ├── approval/ # 审批流程(ApprovalFlow + Process/Template Tab)
│ │ │ ├── audit/ # SQL 审计
│ │ │ ├── automation/ # 自动化运维(CronJob/Script/Ansible)
│ │ │ ├── cloud/ # 云平台管理(CloudBilling + Helpers 子组件)
│ │ │ ├── dashboard/ # 仪表盘(Charts/Recent/Stats 子组件)
│ │ │ ├── deploy/ # CI/CD 部署
│ │ │ ├── k8s/ # K8s 集群管理(Detail/Dialog/Topology 子组件)
│ │ │ ├── layout/ # 布局组件
│ │ │ ├── monitor/ # 监控告警(AlertManager + Events/Rules Tab + Dialog 子组件)
│ │ │ │ ├── alert-center/ # 告警中心(AlertCenter + Detail 子组件)
│ │ │ │ ├── dashboard/ # Grafana 仪表盘(GrafanaPanelContent 子组件)
│ │ │ │ ├── logs/ # 日志管理
│ │ │ │ └── trace/ # 链路追踪
│ │ │ ├── navigation/ # 导航管理
│ │ │ ├── server/ # 服务器管理(ServerManager + Form/BatchImport 子组件)
│ │ │ ├── system/ # 系统管理(SystemManager + User/Settings/Logs/Roles/LDAP Tab 子组件)
│ │ │ └── ui/ # shadcn/ui 基础组件(sidebar.tsx + sidebar-context.tsx)
│ │ ├── hooks/ # 自定义 Hooks
│ │ ├── lib/ # 工具库
│ │ ├── mocks/ # Mock 数据(按 domain 模块化,barrel 统一导出)
│ │ │ ├── data.ts # Barrel re-export(统一入口)
│ │ │ └── modules/ # 按业务域分组
│ │ │ ├── servers.ts # 服务器/机柜
│ │ │ ├── cloud.ts # 云平台
│ │ │ ├── k8s.ts # K8s
│ │ │ ├── alerts.ts # 告警
│ │ │ ├── dashboard.ts # 仪表盘
│ │ │ ├── cicd.ts # CI/CD
│ │ │ ├── automation.ts # 自动化
│ │ │ ├── system.ts # 系统
│ │ │ ├── approval.ts # 审批
│ │ │ ├── monitor.ts # 监控
│ │ │ └── misc.ts # SQL审计/Ansible/导航等
│ │ ├── services/ # API 封装
│ │ ├── store/ # Zustand 状态管理
│ │ ├── types/ # TypeScript 类型定义
│ │ ├── App.css # 全局样式
│ │ ├── App.tsx # 根组件
│ │ ├── index.css # 基础样式
│ │ └── main.tsx # 应用入口
│ ├── package.json
│ ├── vite.config.ts # Vite 配置(含 API 代理)
│ ├── tailwind.config.js # Tailwind CSS 配置
│ └── tsconfig.json
│
├── backend/ # 后端 (Go + Gin + GORM)
│ ├── cmd/
│ │ └── main.go # 应用入口
│ ├── internal/
│ │ ├── api/
│ │ │ ├── handlers/ # HTTP 处理器(模块化拆分)
│ │ │ │ ├── agent.go # Agent 管理
│ │ │ │ ├── agent_task.go # Agent 任务分发
│ │ │ │ ├── alert.go # 告警管理
│ │ │ │ ├── alert_engine.go # 告警引擎
│ │ │ │ ├── ansible.go # Ansible Playbook
│ │ │ │ ├── approval.go # 审批流程
│ │ │ │ ├── audit.go # 审计日志
│ │ │ │ ├── automation.go # 自动化运维(入口)
│ │ │ │ ├── automation_cron.go # 定时任务
│ │ │ │ ├── automation_script.go # 脚本管理
│ │ │ │ ├── automation_playbook.go # Playbook
│ │ │ │ ├── billing.go # 云账单
│ │ │ │ ├── cloud_accounts.go # 云账号
│ │ │ │ ├── cloud_domain.go # 域名
│ │ │ │ ├── cloud_platform.go # 云平台
│ │ │ │ ├── cloud_region.go # 区域
│ │ │ │ ├── dashboard.go # 仪表盘
│ │ │ │ ├── k8s.go # K8s 管理
│ │ │ │ ├── ldap.go # LDAP(入口)
│ │ │ │ ├── ldap_ou.go # LDAP OU 管理
│ │ │ │ ├── ldap_users.go # LDAP 用户同步
│ │ │ │ ├── log.go # 日志管理
│ │ │ │ ├── navigation.go # 导航管理
│ │ │ │ ├── pipeline.go # CI/CD 流水线
│ │ │ │ ├── resource_model.go # 资源模型
│ │ │ │ ├── server.go # 服务器管理(入口)
│ │ │ │ ├── user.go # 用户认证
│ │ │ │ ├── user_admin.go # 用户管理(管理员)
│ │ │ │ └── webshell.go # Web 终端
│ │ │ ├── middleware/ # 中间件
│ │ │ │ └── auth.go # JWT 认证 + RBAC
│ │ │ └── routes/
│ │ │ └── routes.go # 路由注册
│ │ ├── config/
│ │ │ └── config.go # 配置加载 (Viper)
│ │ └── models/ # 数据模型
│ │ ├── alert.go # 告警模型
│ │ ├── approval.go # 审批模型
│ │ ├── audit.go # 审计日志模型
│ │ ├── automation.go # 自动化运维模型
│ │ ├── cicd.go # CI/CD 模型
│ │ ├── common.go # 通用模型 (Response/List/Page)
│ │ ├── k8s.go # K8s 模型
│ │ ├── navigation.go # 导航模型
│ │ ├── server.go # 服务器模型
│ │ └── user.go # 用户模型
│ ├── pkg/
│ │ ├── database/
│ │ │ └── database.go # 数据库连接 + AutoMigrate
│ │ └── logger/
│ │ └── logger.go # Zap 日志
│ ├── scripts/
│ │ ├── init.sql # 初始化 SQL
│ │ └── mock.go # Mock 数据生成
│ ├── config.yaml # 配置文件(SQLite 默认)
│ ├── go.mod # Go 模块定义
│ └── Dockerfile # Docker 构建
│
├── docs/ # 开发文档
│ ├── README.md # 文档索引
│ ├── project-structure.md # 本文件
│ ├── quick-start.md # 快速开始
│ ├── api-reference.md # API 接口
│ ├── database-schema.md # 数据库设计
│ ├── development-guide.md # 开发规范
│ ├── deployment.md # 部署指南
│ ├── ROADMAP.md # 项目路线图
│ ├── PDD_PLAN.md # 产品开发计划
│ ├── PROJECT_SUMMARY.md # 项目概述
│ └── BACKEND_SUMMARY.md # 后端摘要
│
├── run.sh # 一键启动脚本
├── Makefile # 快捷命令
├── .env.example # 环境变量模板
├── .gitignore
└── README.md
```
## 技术栈
### 前端
| 技术 | 版本 | 用途 |
|------|------|------|
| React | 18+ | 前端框架 |
| TypeScript | 5+ | 类型安全 |
| Vite | 7+ | 构建工具 |
| Tailwind CSS | 3+ | 样式框架 |
| shadcn/ui | - | UI 组件库 |
| Zustand | - | 状态管理 |
| TanStack Query | - | 数据请求 |
### 后端
| 技术 | 版本 | 用途 |
|------|------|------|
| Go | 1.21+ | 编程语言 |
| Gin | v1.10+ | Web 框架 |
| GORM | v1.25+ | ORM 框架 |
| JWT | v5 (golang-jwt) | 认证 |
| Viper | - | 配置管理 |
| Zap | - | 结构化日志 |
| SQLite/MySQL/PostgreSQL | - | 数据库 |
## 端口分配
| 服务 | 端口 | 说明 |
|------|------|------|
| 前端 (Vite dev) | 5173 | http://localhost:5173 |
| 后端 (Gin) | 8080 | http://localhost:8080 |
| 健康检查 | 8080 | http://localhost:8080/health |