feat!: backend-only architecture, remove frontend/nginx (v1.2.0)

- Remove frontend/ and nginx/ from core (each customer owns their frontend)
- Update docker-compose.yml to backend-only (postgres + redis + backend)
- Update docker-compose.prod.yml to backend-only
- Add CLAUDE.md with dev guidelines
- Update README.md with new architecture diagram

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Du Wenbo
2026-04-05 23:39:31 +08:00
parent 2b9797d61b
commit 139ca4c128
120 changed files with 64 additions and 21756 deletions

View File

@@ -21,29 +21,23 @@
## 系统架构
```
──────────────┐
│ Nginx
│ 反向代理
:80 / :443
└──────┬───────┘
┌───────────────┼───────────────┐
│ │
┌──────▼──────┐ ┌────────▼────────┐
│ Frontend │ │ Backend │
│ React 19 │ FastAPI
│ Ant Design │ :8000
│ ECharts │
│ Three.js │ │ /api/v1/* │
└─────────────┘ └───────┬──────────┘
┌──────────────┼──────────────┐
│ │
┌──────▼──────┐ ┌───────▼───────┐
│ TimescaleDB │ │ Redis │
│ PostgreSQL │ │ 缓存/队列 │
│ :5432 │ │ :6379 │
└─────────────┘ └───────────────┘
┌────────────────────┐
│ Backend (Core)
│ FastAPI
:8000
│ /api/v1/* │
└─────────┬──────────┘
┌────────────┼────────────┐
┌──────▼──────┐ ┌───────▼───────┐
│ TimescaleDB Redis
│ PostgreSQL │缓存/队列
│ :5432│ :6379
└─────────────┘ └───────────────┘
Note: Frontend and Nginx are NOT part of ems-core.
Each customer repo provides its own frontend and reverse proxy.
```
---
@@ -52,10 +46,6 @@
| 层级 | 技术 |
|------|------|
| 前端框架 | React 19 + TypeScript |
| UI 组件库 | Ant Design 5 + ProComponents |
| 数据可视化 | ECharts 6 |
| 3D 渲染 | Three.js + React Three Fiber |
| 后端框架 | FastAPI (Python 3.11) |
| ORM | SQLAlchemy 2.0 (async) |
| 数据库 | TimescaleDB (PostgreSQL 16) |
@@ -101,7 +91,6 @@ bash scripts/quick-start.sh
| 服务 | 地址 |
|------|------|
| 前端页面 | http://localhost:3000 |
| 后端 API | http://localhost:8000 |
| API 文档 (Swagger) | http://localhost:8000/docs |
| 健康检查 | http://localhost:8000/health |
@@ -134,18 +123,6 @@ pip install -r requirements.txt
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
```
### 前端开发
```bash
cd frontend
# 安装依赖
npm install
# 启动开发服务器
npm run dev
```
### 仅启动基础设施
```bash
@@ -162,49 +139,28 @@ docker-compose up -d postgres redis
docker-compose -f docker-compose.prod.yml up -d
```
生产环境使用 Nginx 反向代理,前端编译为静态文件,后端使用 Gunicorn + Uvicorn workers。
生产环境后端使用 Gunicorn + Uvicorn workers。Nginx 和前端由各客户项目自行提供。
---
## 项目结构
```
tianpu-ems/
├── backend/ # 后端服务
ems-core/
├── backend/ # 后端服务 (Backend-only core)
│ ├── app/
│ │ ├── api/ # API 路由
│ │ │ └── v1/ # v1 版本接口
│ │ ├── collectors/ # 数据采集器
│ │ ├── core/ # 核心配置
│ │ ├── hooks/ # 客户插件系统
│ │ ├── models/ # 数据模型
│ │ ├── services/ # 业务逻辑
│ │ ├── tasks/ # 后台任务
│ │ └── main.py # 应用入口
│ ├── alembic/ # 数据库迁移
│ ├── Dockerfile
│ └── requirements.txt
├── frontend/ # 前端应用
│ ├── src/
│ │ ├── components/ # 公共组件
│ │ ├── layouts/ # 布局组件
│ │ ├── pages/ # 页面组件
│ │ │ ├── BigScreen/ # 数据大屏
│ │ │ ├── BigScreen3D/ # 3D 大屏
│ │ │ ├── Dashboard/ # 仪表盘
│ │ │ ├── Monitoring/ # 实时监控
│ │ │ ├── Devices/ # 设备管理
│ │ │ ├── Analysis/ # 能耗分析
│ │ │ ├── Carbon/ # 碳排放管理
│ │ │ ├── Alarms/ # 告警中心
│ │ │ ├── Reports/ # 报表中心
│ │ │ ├── System/ # 系统管理
│ │ │ └── Login/ # 登录页
│ │ ├── services/ # API 服务
│ │ └── utils/ # 工具函数
│ ├── Dockerfile
│ └── package.json
├── nginx/ # Nginx 配置
│ ├── nginx.conf
│ └── Dockerfile
├── scripts/ # 脚本工具
│ ├── init_db.py # 数据库初始化
│ ├── seed_data.py # 种子数据
@@ -234,16 +190,9 @@ tianpu-ems/
---
## 截图预览
## 说明
> 截图待补充
| 页面 | 说明 |
|------|------|
| 数据大屏 | 园区能源全景概览 |
| 3D 园区 | 三维可视化园区模型 |
| 仪表盘 | 关键能耗指标看板 |
| 设备监控 | 设备运行状态实时监控 |
ems-core 是后端核心库,不包含前端代码。每个客户项目(如 tianpu-ems拥有自己的前端仓库独立部署和定制 UI。
---