Commit Graph

114 Commits

Author SHA1 Message Date
Developer c3931255d3 fix(reward-service): 优化 Dockerfile 和添加 .dockerignore
问题:
1. Dockerfile 使用 COPY . . 会复制 node_modules 导致构建极慢
2. CMD 路径错误:dist/src/main.js 应该是 dist/main.js

修复:
- 添加 .dockerignore 排除 node_modules, dist 等
- 优化 Dockerfile 只复制必要文件 (COPY src ./src)
- 修正 CMD 路径为 dist/main.js
- 添加构建验证步骤 (test -f dist/main.js)
- 添加非 root 用户运行
- 添加健康检查

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 06:50:24 -08:00
Developer fc26575693 fix(leaderboard-service): 删除 Dockerfile 中的 test stage
问题:Dockerfile 中的 test stage 放在最后,导致 docker build 默认使用
test stage 而不是 production stage。容器启动时运行 npm test 而不是
node dist/src/main.js。

修复:删除 test stage,只保留 builder 和 production stages。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 06:48:54 -08:00
Developer b224e209a6 fix(mpc-service): 修复PostgreSQL兼容性问题
1. Dockerfile: 将DATABASE_URL协议从mysql改为postgresql
2. schema.prisma: 重命名索引以满足PostgreSQL全局唯一性要求
   - idx_party_id -> idx_ps_party_id (party_shares)
   - idx_session_id -> idx_ps_session_id (party_shares)
   - idx_status -> idx_ps_status (party_shares)
   - idx_session_id -> idx_ss_session_id (session_states)
   - idx_party_id -> idx_ss_party_id (session_states)
   - idx_status -> idx_ss_status (session_states)

已在WSL2中验证Docker构建成功。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 06:09:16 -08:00
Developer a9594ef15e fix(mpc-service): 修复数据库provider从mysql改为postgresql
mpc-service错误配置为mysql,与项目统一使用的postgresql不一致,
导致服务启动时Prisma验证DATABASE_URL失败。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 05:54:07 -08:00
Developer 1150d7e514 fix(wallet,referral): correct build output path to dist/main.js
These services build to dist/main.js (no src subdirectory).
Added build verification steps.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 05:38:36 -08:00
Developer efd1156739 fix(mpc-service): correct build output path to dist/main.js
NestJS with tsconfig outDir: ./dist builds to dist/main.js, not dist/src/main.js.
Added build verification step to catch this earlier.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 04:41:29 -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 a23b786797 fix(identity-service): fix Dockerfile build and add .dockerignore
- Add .dockerignore to exclude unnecessary files from Docker context
- Explicitly copy tsconfig, nest-cli.json, and src directory
- Add build verification step (test -f dist/main.js)
- Change CMD from npm run to direct node command
- Add health check and non-root user for security

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 03:44:11 -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 2a449aff3c fix(identity-service): add DATABASE_URL for Prisma generate in Dockerfile
Fix build failure caused by missing DATABASE_URL environment variable
during prisma:generate step. Changed from npm run prisma:generate to
direct npx prisma generate with dummy DATABASE_URL.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 03:13:33 -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 b39344a604 fix(wallet-service): use npm install instead of npm ci
wallet-service doesn't have package-lock.json, npm ci requires it.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 02:28:24 -08:00
Developer 3dd561bd24 fix(services): comment out admin-service (not yet implemented)
- Comment out admin-service in docker-compose.yml
- Simplify admin-service Dockerfile to placeholder
- Fixes build error due to missing source files

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 02:19:54 -08:00
Developer f99cac21cf feat(services): add unified Docker deployment system
- Add docker-compose.yml for all 11 backend services
- Add deploy.sh automation script with install/build/up/down commands
- Add init-databases.sh for PostgreSQL multi-database initialization
- Add .env.example template with secure key placeholders
- Fix empty Dockerfiles for admin/referral/reporting/wallet services

Services included:
- identity-service (:3000)
- wallet-service (:3001)
- backup-service (:3002)
- planting-service (:3003)
- referral-service (:3004)
- reward-service (:3005)
- mpc-service (:3006)
- leaderboard-service (:3007)
- reporting-service (:3008)
- authorization-service (:3009)
- admin-service (:3010)

Infrastructure: PostgreSQL, Redis, Kafka/Zookeeper

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 02:12:49 -08:00
Developer 7d257cd35f fix(tproxy): detect clash process with any name (clash-linux-amd64, etc.)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 01:28:17 -08:00
Developer b00cec6b3b feat(scripts): add transparent proxy script for gateway
Script to enable/disable transparent proxy on 192.168.1.100, allowing
192.168.1.111 to access internet through Clash proxy without any
client-side configuration.

Usage:
  sudo bash scripts/tproxy.sh on      # Enable
  sudo bash scripts/tproxy.sh off     # Disable
  sudo bash scripts/tproxy.sh status  # Check status
  sudo bash scripts/tproxy.sh config  # Show required Clash config

Features:
- Redirects TCP traffic from specified clients to Clash redir port
- Optional DNS redirect to Clash DNS
- Bypasses local/private networks
- Easy on/off switching

Prerequisites:
- Clash running with redir-port and allow-lan enabled
- 192.168.1.100 configured as gateway for 192.168.1.111

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 01:16:01 -08:00
Developer ad2790e95e fix(deploy): remove global port settings from mpc.env to fix port conflicts
Problem: message-router and other services were using wrong ports (50051/8080)
instead of their configured ports (50052/8082) because mpc.env contained:
  MPC_SERVER_HTTP_PORT=8080
  MPC_SERVER_GRPC_PORT=50051

These global settings in mpc.env were overriding the per-service Environment=
settings in systemd unit files, causing port conflicts.

Solution:
- Remove MPC_SERVER_HTTP_PORT and MPC_SERVER_GRPC_PORT from mpc.env template
- Add fix-ports command to remove these settings from existing installations
- Add comments explaining per-service port configuration

Port assignments:
  - session-coordinator: gRPC 50051, HTTP 8081
  - message-router: gRPC 50052, HTTP 8082
  - server-party-1/2/3: HTTP 8083/8084/8085
  - account-service: HTTP 8080

To fix existing installation:
  sudo bash scripts/deploy.sh fix-ports
  sudo bash scripts/deploy.sh restart

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 01:02:40 -08:00
Developer dfefd343b0 fix: improve regenerate_keys() to replace any existing key values
Changed sed patterns from matching specific placeholder strings to
matching entire lines (^KEY=.*), ensuring keys are properly replaced
regardless of current value.

Tested in WSL2 - generates valid 64-char hex master key.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:47:59 -08:00
Developer ee398534bb fix: auto-generate secure keys and add regenerate-keys command
- create_env_config() now auto-generates random secure keys:
  - PostgreSQL password (32 char alphanumeric)
  - RabbitMQ password (32 char alphanumeric)
  - JWT secret (32 char alphanumeric)
  - API key (32 char alphanumeric)
  - Master key (64 hex chars = 256-bit)
- Add regenerate-keys command to fix placeholder key issues
- Fixes "Invalid master key format" error for server-party services

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:39:12 -08:00
Developer ec9366186c fix(mpc-system): 修复服务 gRPC/HTTP 端口冲突
问题:
- session-coordinator 和 message-router 都默认使用 gRPC 50051
- 端口冲突导致 message-router 无法启动
- server-party 因无法连接 message-router 而失败

修复:
为每个服务分配独立的端口:
- account-service: HTTP 8080
- session-coordinator: gRPC 50051, HTTP 8081
- message-router: gRPC 50052, HTTP 8082
- server-party-1: HTTP 8083
- server-party-2: HTTP 8084
- server-party-3: HTTP 8085

服务器修复步骤:
  git pull
  sudo bash scripts/deploy.sh build   # 重新生成 systemd 服务文件
  sudo bash scripts/deploy.sh restart
  sudo bash scripts/deploy.sh status

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:23:14 -08:00
Developer 959fc3910c feat(mpc-system): 添加 debug 命令用于故障排查
新增 debug 命令,显示以下信息:
- 环境变量配置状态
- PostgreSQL 连接测试(使用 mpc.env 中的密码)
- Redis 连接测试
- RabbitMQ 状态检查
- 端口监听状态(5432, 6379, 5672, 50051, 50052, 8080)
- 各服务最近 10 条日志
- 手动测试命令提示

使用方法:
  sudo ./scripts/deploy.sh debug

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:19:13 -08:00
Developer 0604255ba8 fix(mpc-system): 修复 PostgreSQL 认证配置问题
问题原因:
- 部署脚本使用 POSTGRES_PASSWORD 环境变量
- Go 代码使用 MPC_DATABASE_PASSWORD 环境变量 (Viper 前缀)
- 变量名不匹配导致数据库认证失败

修复内容:
- configure_postgres() 改用 MPC_DATABASE_* 环境变量
- 添加 pg_hba.conf 配置,将 peer/scram-sha-256 改为 md5 认证
- 添加 GRANT ALL ON SCHEMA public 权限
- 使用 127.0.0.1 而非 localhost 进行连接
- 新增 reconfigure 命令用于修复现有安装

服务器修复步骤:
  sudo ./scripts/deploy.sh reconfigure
  sudo ./scripts/deploy.sh restart

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-02 00:13:24 -08:00
Developer 70e6391691 feat(mpc-system): 添加原生部署脚本,替代 Docker 部署
由于中国网络环境无法正常使用 Docker,添加原生部署方案:

新增文件:
- backend/mpc-system/scripts/deploy.sh - 一键部署脚本

脚本功能:
- install: 安装 Go 1.21、PostgreSQL、Redis、RabbitMQ
- build: 编译 Go 服务并配置基础设施
- start/stop/restart: 服务控制
- status: 查看服务状态
- logs: 查看服务日志
- uninstall: 卸载服务

更新文档:
- 更新 DEPLOYMENT_GUIDE.md 第 4 节为原生部署方式
- 添加 systemd 服务管理说明
- 添加 Nginx/iptables 端口映射配置
- 更新故障排查指南

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 23:24:16 -08:00
Developer 42735e41ef docs: 更新 MPC-System 部署指南为 Docker Compose 一键部署
根据实际的 mpc-system/docker-compose.yml 更新部署文档:

- 更新系统要求 (Docker 24.0+, 4GB RAM)
- 添加服务架构说明 (account-service, session-coordinator 等)
- 提供一键部署步骤 (clone -> .env -> docker compose up)
- 添加 .env 配置模板
- 更新服务端口说明 (仅暴露 4000 端口)
- 更新 API 端点说明
- 添加运维命令参考

部署路径: /home/ceshi/rwadurian/backend/mpc-system

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 22:03:07 -08:00
Developer c63be04322 feat(mpc-system): 优化 Docker 部署配置适配生产环境
部署位置: 192.168.1.100 (Nginx + MPC 服务器)

主要修改:
- 对外仅暴露端口 4000 (account-service)
- 移除基础设施服务的外部端口暴露
- 默认使用 production 环境
- 添加 MPC_API_KEY 和 ALLOWED_IPS 安全配置
- 新增 .env.example 生产环境配置模板
- 移除 Consul 服务发现 (简化部署)
- 优化 Redis 内存配置

架构说明:
- account-service:4000 为对外 API 入口
- 后端服务器 (192.168.1.111) 的 mpc-service 通过此端口调用

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 21:59:01 -08:00
Developer 01e192ea17 fix(nginx): 修复 CORS 配置,将 add_header 移出 if 块
nginx 不允许在 if 块中使用 add_header 指令,
将 CORS 配置提取到独立的 snippets/cors-params.conf 文件。

修改内容:
- 新增 cors-params.conf 配置文件
- 在每个 location 块中引入 cors-params.conf
- 从 server 块移除内联的 CORS 配置
- 更新目录结构说明和部署步骤

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 21:48:52 -08:00
Developer 6da6dba3f9 docs: 修复部署步骤顺序,SSL证书获取优先于站点配置
对于全新系统部署,必须先获取 Let's Encrypt 证书,
然后才能配置引用这些证书的 Nginx 站点配置。

修改内容:
- 将 SSL 证书获取移到步骤 3(配置站点之前)
- 提供 standalone 和 webroot 两种证书获取方式
- 添加清晰的步骤注释说明
- 移除不需要的 /etc/nginx/ssl 目录创建

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 21:21:25 -08:00
Developer b94a9b3d25 docs: 更新文档索引,区分开发/生产环境部署指南
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 21:00:56 -08:00
Developer c421a06f16 fix: 使用 Let's Encrypt 默认证书路径
- SSL 证书直接引用 /etc/letsencrypt/live/rwaapi.szaiai.com/
- 移除不必要的软链接创建步骤
- 添加 certbot 自动续期说明
- 更新 SSL 证书问题排查命令

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:59:59 -08:00
Developer 2ece6328ba refactor: 重组 identity-service 文档目录结构
文档重组:
- 创建 docs/ 目录,移动所有 .md 文档
- 添加 docs/README.md 文档索引

Nginx 配置更新:
- 改用 sites-available/sites-enabled 标准结构
- 添加 snippets/ 目录存放可复用配置
  - proxy-params.conf - 代理参数
  - ssl-params.conf - SSL 安全参数
- 更新部署步骤,包含站点启用/禁用命令

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:58:40 -08:00
Developer 3f612448ff . 2025-12-01 20:48:31 -08:00
Developer e082cda8b7 docs: 更新部署指南,MPC-System 部署在 Nginx 服务器 192.168.1.100
架构更新:
- Nginx + MPC-System 服务器 (192.168.1.100)
  - Nginx 反向代理 (80/443)
  - MPC-System Go 服务 (4000)
- 后端微服务服务器 (192.168.1.111)
  - 所有 NestJS 微服务
  - mpc-service 调用 192.168.1.100:4000

新增内容:
- MPC-System 部署指南 (systemd/Docker 两种方式)
- MPC-System API 端点说明
- 防火墙配置 (只允许后端服务器访问)
- MPC 相关故障排查
- 健康检查命令更新

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:47:34 -08:00
Developer a9dc2b441e docs: 更新部署指南,添加完整 Nginx 配置
更新内容:
- 明确后端服务部署在 192.168.1.111 服务器
- 添加完整的 Nginx 配置文件结构
  - nginx.conf 主配置
  - proxy_params.conf 代理参数
  - rwaapi.conf API 网关配置
- 所有 upstream 指向 192.168.1.111 内网地址
- 添加 Docker Compose 完整配置 (10个微服务)
- 添加数据库初始化脚本
- 添加环境变量配置示例
- 添加部署步骤和验证命令
- 添加监控运维和常见问题

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:41:50 -08:00
Developer 2d50ad32a9 docs: 添加系统部署指南和更新 API 配置
添加 DEPLOYMENT_GUIDE.md:
- 完整的 Nginx 反向代理配置 (rwaapi.szaiai.com)
- Docker Compose 生产环境部署配置
- 后端服务端口规划和 API 路由映射
- 前端 API 调用对照表
- SSL/HTTPS 配置说明
- 部署步骤和常见问题

更新前端 API 配置:
- api_endpoints.dart: 更新 baseUrl 为 https://rwaapi.szaiai.com
- api_endpoints.dart: 添加 /api/v1 前缀到所有端点
- api_endpoints.dart: 添加 telemetry 遥测端点
- api_client.dart: 更新默认 baseUrl 为生产环境地址

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:39:11 -08:00
Developer acb424a2da chore(identity-service): 完善 Docker Compose 配置
- 移除过时的 version 属性
- 补充完整环境变量 (Redis, Kafka, MPC, Backup Service)
- 添加健康检查 (healthcheck) 配置
- 添加自动重启策略 (restart: unless-stopped)
- 修复 Kafka broker 内部地址 (kafka:29092)
- 配置 Zookeeper 健康检查和依赖条件

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 20:15:12 -08:00
Developer 769a33b9b0 . 2025-12-01 19:37:08 -08:00
Developer 00c47f22e0 . 2025-12-01 19:33:05 -08:00
Developer 9944f86174 . 2025-12-01 19:24:46 -08:00
Developer 6f2ff2d9b3 . 2025-12-01 19:19:00 -08:00
Developer 097396bb93 build: 配置 Android Release 签名和构建优化
- 添加 Release 签名配置 (build.gradle.kts)
- 配置 ProGuard 混淆规则 (proguard-rules.pro)
- 优化 Gradle 内存配置 (gradle.properties)
- 更新 .gitignore 排除签名密钥文件

签名密钥存放于 publish/ 目录 (已排除版本控制)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 18:37:27 -08:00
Developer 1fe66f34fd feat(reporting-service): Implement complete reporting service with DDD architecture
- Domain layer: ReportDefinition/ReportSnapshot aggregates, value objects (DateRange, ReportPeriod, etc.)
- Application layer: CQRS commands/queries, ReportingApplicationService
- Infrastructure layer: Prisma repositories, Redis cache, export services (Excel/CSV/PDF)
- API layer: REST controllers, DTOs with validation
- Testing: Unit tests, integration tests, E2E tests, Docker test environment
- Documentation: Architecture, API, Development, Testing, Deployment, Data Model docs
- Supports scheduled report generation, multi-format export, and data caching

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 08:12:57 -08:00
Developer ea03df9059 feat(authorization-service): Implement complete authorization service with DDD architecture
## Features
- Province/City Company authorization (省代/市代授权)
- Community authorization (社区授权)
- Monthly assessment with ladder targets (月度阶梯考核)
- Team validation for referral chain conflicts (推荐链授权冲突检测)
- First place ranking rewards (区域第一名奖励)

## Architecture
- Domain Layer: Aggregates, Entities, Value Objects, Domain Events, Services
- Application Layer: Commands, Services, Schedulers
- Infrastructure Layer: Prisma ORM, Redis Cache, Kafka Events
- API Layer: Controllers, DTOs, Guards

## Testing
- Unit tests: 33 tests (aggregates, entities, value objects)
- Integration tests: 30 tests (domain services)
- E2E tests: 6 tests (API endpoints)
- Docker test environment with PostgreSQL, Redis, Kafka

## Documentation
- ARCHITECTURE.md: System design and DDD patterns
- API.md: REST API endpoints reference
- DEVELOPMENT.md: Development guide
- TESTING.md: Testing strategies and examples
- DEPLOYMENT.md: Docker/Kubernetes deployment

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 06:30:07 -08:00
Developer 9ab7ff3ef1 . 2025-12-01 03:54:55 -08:00
Developer 29cf03c1d2 feat(leaderboard-service): Implement complete leaderboard service with DDD architecture
## Features
- Daily/Weekly/Monthly leaderboard management
- Ranking score calculation (effectiveScore = totalTeamPlanting - maxDirectTeamPlanting)
- Virtual ranking system for display purposes
- Real-time ranking updates via scheduled tasks
- Redis caching for hot data
- Kafka messaging for event-driven updates

## Architecture
- Domain-Driven Design (DDD) with Hexagonal Architecture
- NestJS 10.x + TypeScript 5.x
- PostgreSQL 15 + Prisma ORM
- Redis (ioredis) for caching
- Kafka (kafkajs) for messaging
- JWT + Passport for authentication
- Swagger for API documentation

## Domain Layer
- Aggregates: LeaderboardRanking, LeaderboardConfig
- Entities: VirtualAccount
- Value Objects: LeaderboardType, LeaderboardPeriod, RankingScore, RankPosition, UserSnapshot
- Domain Events: LeaderboardRefreshedEvent, ConfigUpdatedEvent, RankingChangedEvent
- Domain Services: LeaderboardCalculationService, VirtualRankingGeneratorService, RankingMergerService

## Infrastructure Layer
- Prisma repositories implementation
- Redis cache service
- Kafka event publisher/consumer
- External service clients (ReferralService, IdentityService)

## Testing
- Unit tests: 72 tests passed (88% coverage on core domain)
- Integration tests: 7 tests passed
- E2E tests: 11 tests passed
- Docker containerized tests: 79 tests passed

## Documentation
- docs/ARCHITECTURE.md - Architecture design
- docs/API.md - API specification
- docs/DEVELOPMENT.md - Development guide
- docs/TESTING.md - Testing guide
- docs/DEPLOYMENT.md - Deployment guide

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 03:11:03 -08:00
Developer cc33d01be3 . 2025-12-01 02:08:24 -08:00
Developer 9769012795 feat(reward-service): Implement complete reward service with DDD architecture
## Core Features
- 6 types of reward calculation (Share Right 500U, Province Team 20U,
  Province Area 15U+1% hashpower, City Team 40U, City Area 35U+2% hashpower,
  Community Right 80U)
- 24-hour countdown mechanism for pending rewards
- Reward settlement with multi-currency support (BNB/OG/USDT/DST)
- Automatic reward expiration with scheduled tasks

## Domain Layer
- RewardLedgerEntry aggregate root with state machine
  (PENDING -> SETTLEABLE -> SETTLED, PENDING -> EXPIRED)
- RewardSummary aggregate for user reward overview
- Value objects: Money, Hashpower, RewardSource, RewardStatus, RightType
- Domain events: RewardCreated, RewardClaimed, RewardSettled, RewardExpired
- Domain services: RewardCalculationService, RewardExpirationService

## Application Layer
- RewardApplicationService for orchestrating business workflows
- RewardExpirationScheduler for automatic expiration processing

## Infrastructure Layer
- PostgreSQL persistence with Prisma ORM
- Redis caching integration
- Kafka event publishing/consuming
- External service clients (Referral, Authorization, Wallet)

## API Layer
- REST endpoints: /health, /rewards/summary, /rewards/details,
  /rewards/pending, /rewards/settle
- JWT authentication with Passport.js
- Swagger/OpenAPI documentation

## Testing (77 tests, 100% pass rate)
- 43 unit tests for domain logic (Money, Hashpower, aggregates)
- 20 integration tests for application services
- 14 E2E tests for API endpoints
- Docker Compose test infrastructure (PostgreSQL, Redis, Kafka)

## Documentation
- docs/ARCHITECTURE.md - DDD architecture overview
- docs/API.md - REST API documentation
- docs/DEVELOPMENT.md - Developer guide
- docs/TESTING.md - Testing guide
- docs/DEPLOYMENT.md - Deployment guide

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 01:57:40 -08:00
Developer 85c820b5af . 2025-12-01 00:32:30 -08:00
Developer 7ae98c7f5b feat(referral-service): Implement complete referral service with DDD architecture
Implement the referral service microservice with comprehensive features:

## Domain Layer
- ReferralRelationship aggregate: manages user referral relationships
- TeamStatistics aggregate: tracks team statistics and leaderboard scores
- Value Objects: UserId, ReferralCode, ReferralChain, LeaderboardScore, ProvinceCityDistribution
- Domain Services: ReferralChainService, LeaderboardCalculationService
- Domain Events: ReferralRelationshipCreated, TeamStatisticsUpdated

## Application Layer
- ReferralService: create relationships, get user info, validate codes
- TeamStatisticsService: update statistics, get leaderboard, province/city distribution
- Commands: CreateReferralRelationship, UpdateTeamStatistics
- Queries: GetUserReferralInfo, GetDirectReferrals, GetLeaderboard, GetProvinceCityDistribution
- Event Handlers: UserRegisteredHandler, PlantingCreatedHandler

## Infrastructure Layer
- Prisma repositories with PostgreSQL
- Redis caching for leaderboard
- Kafka messaging for domain events
- JWT authentication guard

## API Layer
- REST endpoints for referral management
- Leaderboard endpoints with pagination
- Team statistics endpoints
- Health check endpoints

## Testing (127 unit + 35 integration + 16 E2E tests)
- Domain layer unit tests (100% coverage)
- Integration tests with mocks
- E2E tests with supertest
- Docker test environment with PostgreSQL, Redis, Redpanda

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 00:18:20 -08:00