Commit Graph

27 Commits

Author SHA1 Message Date
hailin 7c72be3ba0 fix(docker): 修复 referral-service Dockerfile 健康检查 URL
修复 referral-service 的健康检查端点配置:
- referral-service: /health -> /api/v1/health

注:backup-service 使用 /health,leaderboard-service 使用 /api/health(这是服务本身实现的端点)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-14 03:05:18 -08:00
hailin 75c49951b7 fix: 修复多个服务的 accountSequence 类型和推荐关系 bug
1. referral-service: 修复 userId 从临时值 0 导致的 "用户ID必须大于0" 错误
   - 从 accountSequence 提取数值部分作为 userId (去掉 "D" 前缀)
   - 避免依赖 identity-service 发送的临时 userId

2. 多服务 migration 修复: accountSequence/inviterSequence 类型从 BIGINT 改为 VARCHAR(12)
   - identity-service: account_sequence, inviter_sequence
   - authorization-service: account_sequence
   - blockchain-service: account_sequence
   - referral-service: account_sequence
   - reward-service: account_sequence
   - backup-service: account_sequence

3. mpc-service 与 backup-service 集成:
   - mpc-service: 添加 BACKUP_SERVICE_URL, BACKUP_SERVICE_ENABLED, SERVICE_JWT_SECRET
   - backup-service: ALLOWED_SERVICES 添加 mpc-service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 12:29:11 -08:00
hailin 4be9c1fb82 refactor!: 重构账户序列号格式 (BREAKING CHANGE)
将 accountSequence 从数字类型改为字符串类型,新格式为:
- 普通用户: D + YYMMDD + 5位序号 (例: D2512120001)
- 系统账户: S + 10位序号 (例: S0000000001)

主要变更:
- identity-service: AccountSequence 值对象改为字符串类型
- identity-service: 序列号生成器改为按日期重置计数
- 所有服务: Prisma schema 字段类型从 BigInt/Int 改为 String
- 所有服务: DTO、Command、Event 中的类型定义更新
- Flutter 前端: 相关数据模型类型更新

涉及服务:
- identity-service (核心变更)
- referral-service
- authorization-service
- wallet-service
- reward-service
- blockchain-service
- backup-service
- planting-service
- mpc-service
- admin-service
- mobile-app (Flutter)

注意: 此为破坏性变更,需要清空数据库并重新运行 migration

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-12 09:11:18 -08:00
hailin b6bc10d680 debug(backup-service): log allowed services on init
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 16:00:29 -08:00
hailin 41af5ef3a3 fix(mpc/backup): add accountSequence to backup share storage
- mpc-service: add accountSequence param to StoreBackupShareParams
- mpc-service: pass accountSequence when calling backup-service
- backup-service: add logging for store request success/failure

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 15:06:00 -08:00
hailin 6451cd6fc3 refactor: unify docker-compose configs to use shared infrastructure
All microservices now use the shared rwa-network and connect to:
- rwa-postgres: Shared PostgreSQL database server
- rwa-redis: Shared Redis cache
- rwa-kafka: Shared Kafka message broker

Each service's docker-compose.yml now only defines the application
container and uses `networks: external: true` to connect to the
shared infrastructure defined in the root docker-compose.yml.

This prevents duplicate infrastructure containers and ensures all
services can communicate via Kafka and share the same Redis/PostgreSQL.

Services updated:
- admin-service
- backup-service
- blockchain-service
- identity-service
- leaderboard-service
- mpc-service
- presence-service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-07 00:35:56 -08:00
hailin 54b9a66041 fix(backup-service): convert deploy.sh line endings from CRLF to LF 2025-12-06 23:29:58 -08:00
hailin 747e4ae8ef refactor(mpc-system): migrate to party-driven architecture with PartyID-based routing
- Remove Address field from PartyEndpoint (parties connect to router themselves)
- Update K8s Discovery to only manage PartyID and Role labels
- Add Party registration and SessionEvent protobuf definitions
- Implement PartyRegistry and SessionEventBroadcaster domain logic
- Add RegisterParty and SubscribeSessionEvents gRPC handlers
- Prepare infrastructure for party-driven MPC coordination

This is the first phase of migrating from coordinator-driven to party-driven
architecture following international MPC system design patterns.
2025-12-05 08:11:28 -08:00
Developer 9dee0d36a5 feat(backup,mpc): 添加 prisma 迁移文件
backup-service 和 mpc-service 缺少 prisma/migrations 目录
导致 prisma migrate deploy 无法执行

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 04:01:47 -08:00
Developer 613d822c46 fix(backup-service): 添加 tsx 支持 Prisma 7 配置文件
- 安装 tsx 以便在生产环境运行 prisma.config.ts
- 复制 prisma.config.ts 到生产镜像
- 移除 --url 参数 (Prisma 7 不再支持)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 03:07:07 -08:00
Developer 9819661693 fix(backup-service): 移除 schema.prisma 中的 url (Prisma 7 配置在 prisma.config.ts)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 02:39:57 -08:00
Developer 62eba58490 fix(backup-service): 添加 datasource url 到 Prisma schema
Prisma migrate/push 需要 datasource 中包含 url 属性。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 02:37:24 -08:00
Developer 9e0adca3d3 fix(backup-service): 使用 printf 替代 echo 创建启动脚本
Alpine 的 sh 不支持 echo 的 \n 转义,改用 printf。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 02:32:07 -08:00
Developer 9898665506 feat(all-services): 添加数据库自动迁移到所有服务启动流程
在每个服务的 Dockerfile 中添加启动脚本:
- 服务启动前先执行 prisma migrate deploy
- 如果迁移失败则回退到 prisma db push
- 确保数据库表在服务启动时自动创建

修改的服务:
- identity-service
- wallet-service
- backup-service
- planting-service
- referral-service
- reward-service
- leaderboard-service
- reporting-service
- authorization-service
- admin-service
- presence-service

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 01:50:01 -08:00
Developer 62dcc37b28 fix(backup-service): 添加 DATABASE_URL 用于 Prisma generate
构建时需要 dummy DATABASE_URL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 10:17:43 -08:00
Developer 9088b1a9ee fix(backup-service): 修正启动路径和健康检查等待时间
- start-period: 5s -> 40s (给予足够启动时间)
- CMD: dist/main.js -> dist/src/main.js (修正实际路径)
- 保持使用 wget (Alpine 原生支持)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 10:11:37 -08:00
Developer 781619e2ff revert: 恢复 backup-service 和 mpc-service 原始 Dockerfile
回滚到纯 Alpine 版本(最初可用的版本)
- backup-service: 66199cc
- mpc-service: 6fa4d7a

之前的修改(slim/openssl/curl)导致问题

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 10:10:22 -08:00
Developer 0388aee2d4 fix(backup-service): 修复 builder stage 使用 Alpine 导致 Prisma 失败
问题:
- Builder stage 使用 node:20-alpine
- Prisma 在 Alpine 上下载二进制文件时网络错误
- linux-musl-openssl 兼容性问题

解决:
- Builder 和 Production 都使用 node:20-slim
- 统一使用 Debian base image
- 在 builder stage 安装 OpenSSL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 10:07:05 -08:00
Developer 53943636ea fix(backup-service): 修复健康检查配置不一致问题
- 将 Dockerfile 从 wget 改为 curl
- 统一 Dockerfile 和 docker-compose.yml 健康检查工具
- 增加 start_period 从 5s 到 40s,给予服务更多启动时间

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 09:57:32 -08:00
Developer 9b4a1d119c fix(services): switch from Alpine to Debian slim for Prisma OpenSSL
Alpine 3.22 removed openssl1.1-compat package which Prisma needs.
Switched production stage from node:20-alpine to node:20-slim (Debian)
which has proper OpenSSL support.

Changes:
- Use node:20-slim for production stage (keep Alpine for build)
- Install openssl and wget via apt-get
- Update user creation from Alpine (addgroup/adduser) to Debian (groupadd/useradd)

Validated identity-service build and startup in WSL2:
- Build passes successfully
- NestJS starts and loads all routes
- Prisma client connects without OpenSSL errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 04:12:27 -08:00
Developer c2b44eef29 fix(services): add OpenSSL 1.1 compatibility for Prisma in Alpine
Prisma engine requires libssl.so.1.1 which is not available in Alpine
Linux by default (Alpine uses OpenSSL 3.x). Added openssl1.1-compat
package to all service Dockerfiles.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 04:03:15 -08:00
Developer 7bb4259290 fix(services): correct NestJS build output path in all Dockerfiles
NestJS with sourceRoot: "src" outputs to dist/src/main.js not dist/main.js.
Fixed CMD paths in all service Dockerfiles:
- identity-service: dist/src/main.js (verified in WSL2)
- wallet-service: dist/src/main.js
- backup-service: dist/src/main.js
- planting-service: dist/src/main.js
- referral-service: dist/src/main.js
- reward-service: dist/src/main.js
- mpc-service: dist/src/main.js
- leaderboard-service: dist/src/main.js
- reporting-service: dist/src/main.js
- authorization-service: dist/src/main.js

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 03:56:02 -08:00
Developer 0a0b7eb886 feat(services): add individual deploy scripts for each service
Add deploy.sh script to each service directory for independent
deployment and management:
- identity-service, wallet-service, backup-service
- planting-service, referral-service, reward-service
- mpc-service, leaderboard-service, reporting-service
- authorization-service

Each script supports:
- build / build-no-cache
- start / stop / restart
- logs / logs-tail
- status / health
- migrate / shell

Also updated main deploy.sh with build-no-cache command.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 03:36:50 -08:00
Developer 77db1009dd fix(services): add DATABASE_URL for Prisma generate in Dockerfiles
Add dummy DATABASE_URL environment variable prefix to all npx prisma
generate commands in Dockerfiles. Prisma requires DATABASE_URL at
build time to generate the client, but the actual value is only used
at runtime.

Services updated:
- authorization-service (postgresql)
- backup-service (postgresql)
- leaderboard-service (postgresql)
- mpc-service (mysql)
- planting-service (postgresql)
- referral-service (postgresql)
- reporting-service (postgresql)
- reward-service (postgresql)
- wallet-service (postgresql + npm install fix)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 02:54:31 -08:00
Developer adf52ae130 . 2025-11-29 22:25:57 -08:00
Developer 66199cc93e feat(backup-service): Implement MPC backup share storage service
- Add DDD + Hexagonal architecture with NestJS 11.x
- Implement store/retrieve/revoke backup share endpoints
- Add AES-256-GCM double encryption for secure storage
- Add service-to-service JWT authentication
- Add rate limiting (3 retrieves per user per day)
- Add comprehensive audit logging
- Add test suite (37 unit + 21 mock E2E + 20 real DB E2E = 78 tests)
- Add documentation (architecture, API, development, testing, deployment)
- Add Docker and Kubernetes deployment configuration
- Add Prisma 7.x with @prisma/adapter-pg for PostgreSQL

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 22:12:41 -08:00
Developer 083db83c96 . 2025-11-29 19:22:42 -08:00