Files
aiops/docs/project-structure.md
T
attacker 4e3f8cb306 docs: update README, API reference, dev-log, project structure with Agent monitoring + quick-alarm + latest fixes
- README.md: React 19, default pwd 123456, Docker Compose deploy, correct module list
- api-reference.md: add Agent monitoring section (report/latest/rules/quick-setup/alerts/tasks/kline)
- dev-log.md: new entry documenting hostname/IP fix, system collector, offline detection, quick alarm
- project-structure.md: add agent/ directory, dev-log.md link, React 19
2026-06-18 16:11:13 +00:00

9.7 KiB
Raw Blame History

项目结构

整体结构

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 构建
│
├── agent/                       # 监控 Agent (Go, 独立 module ezops/agent)
│   ├── main.go                  # CLI 入口 (-server/-interval/-token/-hostname)
│   ├── collector/               # CPU/mem/disk/port/system 采集器 (/proc)
│   ├── model/model.go           # 上报数据结构 (Report/CPUStat/MemStat/...)
│   ├── model/model_ext.go       # 扩展类型 (NetworkStat/DiskIOStat/SystemStat)
│   ├── reporter/http.go         # HTTP POST 上报
│   ├── task/                    # 远程任务执行 (云助手模式)
│   ├── deploy/                  # systemd service + install.sh 一键安装
│   ├── Makefile                 # 交叉编译 amd64+arm64+darwin-arm64
│   └── bin/                     # 编译产物 (gitignore)
│
├── docs/                        # 开发文档
│   ├── README.md                # 文档索引
│   ├── dev-log.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 19+ 前端框架
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