feat: complete Phase 1 infrastructure

- erp-core: error types, shared types, event bus, ErpModule trait
- erp-server: config loading, database/Redis connections, migrations
- erp-server/migration: tenants table with SeaORM
- apps/web: Vite + React 18 + TypeScript + Ant Design 5 + TailwindCSS
- Web frontend: main layout with sidebar, header, routing
- Docker: PostgreSQL 16 + Redis 7 development environment
- All workspace crates compile successfully (cargo check passes)
This commit is contained in:
iven
2026-04-11 01:07:31 +08:00
parent eb856b1d73
commit 5901ee82f0
36 changed files with 4542 additions and 221 deletions

57
wiki/infrastructure.md Normal file
View File

@@ -0,0 +1,57 @@
# infrastructure (Docker 与开发环境)
## 设计思想
开发环境使用 Docker Compose 提供基础设施服务,应用服务在宿主机运行。这种设计允许:
- 后端 Rust 服务快速重启(无需容器化构建)
- 前端 Vite 热更新直接在宿主机
- 数据库和缓存服务标准化,团队成员环境一致
## 代码逻辑
### 服务配置
| 服务 | 镜像 | 端口 | 用途 |
|------|------|------|------|
| erp-postgres | postgres:16-alpine | 5432 | 主数据库 |
| erp-redis | redis:7-alpine | 6379 | 缓存 + 会话 |
### 连接信息
```
PostgreSQL: postgres://erp:erp_dev_2024@localhost:5432/erp
Redis: redis://localhost:6379
```
### 健康检查
- PostgreSQL: `pg_isready` 每 5 秒5 次重试
- Redis: `redis-cli ping` 每 5 秒5 次重试
### 数据持久化
- `postgres_data` — 命名卷PostgreSQL 数据
- `redis_data` — 命名卷Redis 数据
### 环境变量
通过 `docker/.env.example` 文档化,使用默认值即可启动开发环境。
## 关联模块
- **[[erp-server]]** — 连接 PostgreSQL 和 Redis
- **[[database]]** — 迁移在 PostgreSQL 中执行
- **[[frontend]]** — Vite 代理 API 到后端
## 关键文件
| 文件 | 职责 |
|------|------|
| `docker/docker-compose.yml` | 服务定义 |
| `docker/.env.example` | 环境变量模板 |
| `crates/erp-server/config/default.toml` | 默认连接配置 |
## 常用命令
```bash
cd docker && docker compose up -d # 启动服务
docker compose -f docker/docker-compose.yml ps # 查看状态
docker compose -f docker/docker-compose.yml down # 停止
docker exec -it erp-postgres psql -U erp # 连接数据库
```