Commit Graph

31 Commits

Author SHA1 Message Date
hailin df0a041faa chore(docker): 为 mpc-system、api-gateway、infrastructure 添加时区配置
统一所有 Docker 服务时区为 Asia/Shanghai:

mpc-system:
- docker-compose.yml: postgres, session-coordinator, message-router, server-party-1/2/3, server-party-api, account-service
- docker-compose.prod.yml: postgres, message-router, session-coordinator, account-service, server-party-api
- docker-compose.party.yml: postgres, server-party

api-gateway:
- kong-db, kong-migrations, kong

infrastructure:
- consul, jaeger, grafana, minio

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-23 18:35:09 -08:00
hailin 917e3094a2 fix(api-gateway,admin-web): 修复仪表板API路由配置
Kong 网关:
- 添加 /api/v1/dashboard 路由到 reporting-service

Admin-Web 前端:
- 修复所有 API endpoints 添加 /v1 前缀
- 确保与 Kong 路由配置一致

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 04:21:53 -08:00
hailin 594f7880c3 fix(gateway): remove duplicate /leaderboard route from referral-service
The /api/v1/leaderboard route was duplicated in both referral-service
and leaderboard-service. Since leaderboard-service is the dedicated
ranking service with more features (daily/weekly/monthly rankings,
virtual accounts, snapshots), all leaderboard requests should be
routed to leaderboard-service.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 22:00:22 -08:00
hailin 3f622eb13c feat(gateway): add missing API routes to Kong configuration
Add routes for APIs that were implemented but missing from Kong:
- /api/v1/backup-share (backup-service)
- /api/v1/virtual-accounts (leaderboard-service)
- /api/v1/export (reporting-service)
- /api/v1/analytics (presence-service)

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 21:53:55 -08:00
hailin 52ddad1000 fix(api-gateway): correct Kong routes and add missing globalPrefix
- Kong: change /api/v1/plantings to /api/v1/planting (match controller)
- reward-service: add missing app.setGlobalPrefix('api/v1')

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 21:51:58 -08:00
hailin bb048bb104 feat(gateway): add wallet service routes for profile page
Add /api/v1/wallet route to Kong gateway to support:
- GET /wallet/my-wallet
- POST /wallet/claim-rewards
- POST /wallet/settle
- POST /wallet/withdraw
- GET /wallet/withdrawals
- GET /wallet/ledger/my-ledger

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 20:16:24 -08:00
hailin 96804e560b fix(gateway): add /downloads route for APK file downloads
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 07:27:57 -08:00
hailin 917f0f4ee1 fix(gateway): add /api/app/version route for mobile update check
Mobile app was calling /api/app/version/check but this route was not
configured in Kong gateway. Added admin-mobile-version route to forward
these requests to admin-service.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-09 07:17:01 -08:00
hailin d0487c4a7e feat(profile): integrate referral and authorization APIs for profile page
- Add Kong routes for identity-service /me, referral-service, and authorization-service
- Create AuthorizationService in Flutter for fetching user authorizations
- Extend ReferralService with getMyReferralInfo() and getDirectReferrals() methods
- Update profile_page.dart to display real team stats from APIs
- Fix authorization-service JWT strategy to accept identity-service token format
- Add decimal.js dependency to authorization-service
- Add prisma migration file for authorization-service

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-09 01:57:39 -08:00
hailin 0c00382a98 fix: convert deploy.sh CRLF to LF and add executable permission
- Convert Windows CRLF line endings to Unix LF for all deploy.sh files
- Add executable permission to all deploy.sh scripts

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 07:01:13 -08:00
hailin e76adcbe8d . 2025-12-07 14:56:13 +00:00
hailin b25a893d37 docs(config): update .env.example files for production deployment
- Update all .env.example files with production topology documentation
- Add network configuration for Server A (119.145.15.38/192.168.1.100) and Server B (192.168.1.111)
- Document service ports and connection URLs for all microservices
- Add architecture diagrams in comments for easy reference
- Include security notes and key generation commands

Files updated:
- backend/services/.env.example (main config)
- backend/services/identity-service/.env.example
- backend/services/mpc-service/.env.example
- backend/services/blockchain-service/.env.example
- backend/mpc-system/.env.example
- backend/api-gateway/.env.example
- backend/infrastructure/.env.example

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 04:55:21 -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
hailin a72b5f00d2 fix(api-gateway): update Nginx reverse proxy headers for Grafana 10+ compatibility
- Change Host header from $host to $http_host for correct host forwarding
- Add X-Forwarded-Host and X-Forwarded-Port headers
- Add Origin header ($scheme://$host) critical for Grafana 10+ CORS validation
- Disable proxy buffering for better real-time updates
- Update README with manual Nginx configuration update instructions for existing installations

Resolves 'origin not allowed' error when accessing Grafana through Nginx reverse proxy with SSL.
2025-12-04 22:31:59 -08:00
hailin 746cd8e35e fix(api-gateway): add Grafana 10+ CORS configuration for reverse proxy access
添加 Grafana 10+ 的 CORS/跨域配置,解决通过 Nginx 反向代理访问时的 "origin not allowed" 错误。

Changes:
- docker-compose.monitoring.yml: 添加 Grafana 安全配置
  - GF_SECURITY_ALLOW_EMBEDDING=true: 允许嵌入和反向代理访问
  - GF_SECURITY_COOKIE_SAMESITE=none: 允许跨域 Cookie
  - GF_SECURITY_COOKIE_SECURE=true: HTTPS 下安全传输 Cookie
  - GF_AUTH_ANONYMOUS_ENABLED=false: 保持安全性,禁用匿名访问

- .env.example: 添加重启提示说明
  - 强调修改 GRAFANA_ROOT_URL 后必须重启监控服务

- README.md: 新增 "Grafana 通过 Nginx/域名访问配置" 章节
  - 详细说明配置步骤
  - 提供验证方法
  - 列出常见错误和解决方案

问题根因:
Grafana 10+ 引入了更严格的安全策略,要求显式配置 CORS 相关参数才能通过反向代理访问。
仅配置 GF_SERVER_ROOT_URL 不足以解决跨域问题。

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 22:23:04 -08:00
hailin b94cf57b08 docs(api-gateway): enhance GRAFANA_ROOT_URL configuration documentation
- Added critical warning about GRAFANA_ROOT_URL matching actual access URL
- Documented common "origin not allowed" error and its cause
- Provided clear examples for local vs production deployment
- Added security tip for generating Grafana password

This fixes the 403 Forbidden error when accessing Grafana via domain
while GRAFANA_ROOT_URL is set to localhost.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 22:07:22 -08:00
hailin a748cf07f0 docs(api-gateway): clarify Kong database configuration details
- Added Kong database configuration section to README.md
- Documented that Kong database username and database name are hardcoded as 'kong'
- Clarified that only password is configurable via KONG_PG_PASSWORD
- Added security warnings about changing password in production
- Updated .env.example with detailed comments about Kong database config

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 21:53:10 -08:00
hailin 2556fea841 refactor: separate configuration from code following 12-Factor App principles
- Created .env.example files with comprehensive security warnings
- Removed hardcoded IP addresses and credentials from docker-compose files
- Made database passwords mandatory (fail-fast on missing config)
- Removed Chinese mirror sources from all Dockerfiles
- Enhanced deploy.sh scripts with .env validation and auto-creation
- Added comprehensive README.md deployment guides
- Changed ALLOWED_IPS default to enable cross-server deployment
- Updated all docker-compose files to use environment variables

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-04 21:46:35 -08:00
Developer 12032b905f fix(identity-service): 修复 MPC 服务调用路径
问题: identity-service 调用 mpc-service 返回 404
原因: mpc-service 有全局前缀 /api/v1,但调用路径缺少此前缀

修复:
- mpc-client.service.ts: 添加 /api/v1 前缀到 MPC API 调用路径
- kong.yml: 添加 /api/v1/mpc-party 路由

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 16:49:49 -08:00
Developer d71c104c86 fix(api-gateway): 添加 /api/v1/user 路由到 Kong 配置
问题: 移动端调用 /api/v1/user/auto-create 返回 404
原因: Kong 配置只有 /api/v1/users (复数), 缺少 /api/v1/user (单数)
解决: 添加 identity-user 路由匹配 /api/v1/user 路径

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 16:29:33 -08:00
Developer 9656a6f4c4 feat(presence-service): 添加 Prometheus 指标监控和 Grafana Dashboard
Prometheus 指标端点 (/api/v1/metrics):
- presence_online_users_total: 实时在线人数
- presence_dau_total: 今日 DAU
- presence_heartbeat_total: 心跳计数
- presence_events_received_total: 事件上报计数
- presence_session_start_total: 会话开始计数
- presence_heartbeat_duration_seconds: 心跳处理延迟
- presence_event_batch_duration_seconds: 事件批处理延迟

Grafana Dashboard:
- 核心指标概览 (在线人数、DAU、心跳、事件)
- 趋势图表 (在线人数趋势、心跳/事件速率)
- 事件分布 (饼图、按小时趋势)
- 性能指标 (P50/P95/P99 延迟)
- 服务资源 (内存、CPU)

配置更新:
- prometheus.yml 添加 presence-service 抓取配置
- package.json 添加 prom-client 依赖

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 08:38:05 -08:00
Developer eb57309724 fix(api-gateway): 增加文件上传大小限制到 500MB
- Kong request-size-limiting: 50MB -> 500MB
- Nginx client_max_body_size: 100M -> 500M

用于支持大型 APK/IPA 文件上传

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 08:04:26 -08:00
Developer 8932d87df7 fix(monitoring): 修复 Prometheus 端口冲突问题
- 将 Prometheus 端口从 9090 改为 9099,避免与已有服务冲突
- 同步更新 install-monitor.sh 和 deploy.sh 中的端口配置

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 06:09:18 -08:00
Developer 90bfa4afac feat(api-gateway): 添加 Kong 监控栈一键安装脚本
- 添加 scripts/install-monitor.sh 一键安装脚本
  - 自动检查依赖和 DNS 解析
  - 自动生成 Nginx 配置
  - 自动申请 Let's Encrypt SSL 证书
  - 自动启动 Prometheus + Grafana
- 添加 prometheus 插件到 kong.yml 配置
- 添加 docker-compose.monitoring.yml 监控服务编排
- 添加 Grafana 预配置仪表盘
- 扩展 deploy.sh 支持 monitoring install/up/down 命令

使用方式:
  ./deploy.sh monitoring install             # 使用默认域名安装
  ./deploy.sh monitoring install mydomain.com # 自定义域名
  ./deploy.sh monitoring up                   # 仅启动服务
  ./deploy.sh metrics                         # 查看指标

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 06:01:22 -08:00
Developer de5cbce0d3 fix(api-gateway): 禁用 deck 容器的代理设置
避免继承宿主机的 http_proxy 环境变量导致连接失败

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 01:01:22 -08:00
Developer d2a00213f8 fix(api-gateway): 使用 deck 同步配置到数据库模式
- 添加 kong-config 容器使用 deck 同步 kong.yml
- 移除 KONG_DECLARATIVE_CONFIG (数据库模式不支持)
- 添加 sync 命令手动同步配置
- 修改 reload 命令使用 deck sync

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:57:16 -08:00
Developer a148f26649 fix(api-gateway): 使用官方 Docker Hub 镜像解决拉取问题
- 使用 docker.io/kong/kong-gateway:3.5 官方镜像
- 使用 docker.io/library/postgres:16-alpine 官方镜像
- 保留数据库模式,完整功能支持

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:54:03 -08:00
Developer edb8134414 feat(api-gateway): 支持分布式部署 Kong 和后端服务分离
- 修改 kong.yml 使用外部 IP (192.168.1.111) 访问后端服务
- 修改 docker-compose.yml 使用独立网络,移除外部网络依赖
- 修改 deploy.sh 改为检查后端服务器连通性
- 更新 README 添加分布式部署架构图和详细部署流程

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:50:22 -08:00
Developer de2e2d0428 refactor(api-gateway): 将 Kong 独立为解耦模块
- 将 Kong 从 services/docker-compose.yml 移到 api-gateway/docker-compose.yml
- 添加 api-gateway/deploy.sh 一键部署脚本
- 完善 api-gateway/README.md 文档,包含完整架构图和部署流程
- Kong 使用外部网络连接 services,实现解耦部署

架构变更:
- services: 只包含微服务,不依赖 Kong
- api-gateway: 独立的 Kong 网关,可选部署

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:38:49 -08:00
Developer 7d9d5eeffe feat(api-gateway): 添加 Kong API 网关和 Nginx 配置
- 添加 Kong 声明式配置 (kong.yml),定义所有微服务路由
- 更新 docker-compose.yml 添加 Kong 服务 (kong-db, kong-migrations, kong)
- 添加 rwaapi.szaiai.com Nginx 配置 (SSL + 反向代理到 Kong)
- 添加 nginx/install.sh 一键安装脚本
- 添加 API Gateway README 文档

架构: 用户 → Nginx (SSL) → Kong (API Gateway) → 各微服务

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-03 00:33:22 -08:00
hailin b9a3fb9a83 first commit 2025-11-23 21:21:44 -08:00