Commit Graph

1360 Commits

Author SHA1 Message Date
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
Developer b350d6b023 . 2025-11-30 19:04:47 -08:00
Developer 98f5d948dd feat(planting-service): Implement complete planting service with DDD architecture
- Domain Layer:
  - PlantingOrder aggregate with full lifecycle management
  - PlantingPosition aggregate for user holdings
  - PoolInjectionBatch aggregate for 5-day batch processing
  - Value objects: TreeCount, ProvinceCitySelection, FundAllocation, Money
  - Domain events for state transitions
  - FundAllocationDomainService for 10-target fund distribution (2199 USDT/tree)

- Application Layer:
  - PlantingApplicationService for order management
  - PoolInjectionService for batch processing
  - 5-second province/city confirmation mechanism

- Infrastructure Layer:
  - Prisma ORM with PostgreSQL
  - Repository implementations
  - External service clients (Wallet, Referral)
  - Object mappers

- API Layer:
  - REST controllers with Swagger documentation
  - JWT authentication guard
  - Request/Response DTOs with validation

- Testing:
  - 45+ unit tests
  - 12+ integration tests
  - 17+ E2E tests
  - Docker test environment

- Documentation:
  - Architecture design (DDD + Hexagonal)
  - API documentation
  - Development guide
  - Testing guide
  - Deployment guide

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 18:55:50 -08:00
Developer 2d18155ac2 . 2025-11-30 17:35:08 -08:00
Developer 845d841bca feat(wallet-service): Implement complete wallet service with DDD architecture
- Add domain layer with aggregates (WalletAccount, LedgerEntry, DepositOrder, SettlementOrder)
- Add value objects (Money, Balance, Hashpower, UserId, etc.)
- Add domain events for event-driven architecture
- Implement application layer with CQRS commands and queries
- Add infrastructure layer with Prisma repositories
- Implement REST API with NestJS controllers
- Add JWT authentication with guards and strategies
- Add comprehensive unit tests (69 tests) and E2E tests (23 tests)
- Add documentation: ARCHITECTURE.md, API.md, DEVELOPMENT.md, TESTING.md, DEPLOYMENT.md
- Add E2E testing guide for WSL2 environment

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 09:13:57 -08:00
Developer a966d71fa0 . 2025-11-30 06:44:57 -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
Developer f4a3a6dd1c . 2025-11-29 07:14:44 -08:00
Developer 503999eaf2 docs: Add detailed DDD + Hexagonal architecture documentation
- Add comprehensive DDD tactical patterns (Entity, Value Object, Aggregate, Repository, Domain Service)
- Add Hexagonal Architecture details (Input/Output Ports, Adapters)
- Include code examples for each pattern
- Add dependency injection explanation
- Update section numbering

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:13:38 -08:00
Developer 79ccdd7116 feat: Complete MPC TSS implementation with t-of-n threshold signing
Major changes:
- Add TSS core library (pkg/tss) with keygen and signing protocols
- Implement gRPC clients for Server Party service
- Add MPC session endpoints to Account service
- Deploy 3 Server Party instances in docker-compose
- Add MarkPartyReady and StartSession to proto definitions
- Complete integration tests for 2-of-3, 3-of-5, 4-of-7 thresholds
- Add comprehensive documentation (architecture, API, testing, deployment)

Test results:
- 2-of-3: PASSED (keygen 93s, signing 80s)
- 3-of-5: PASSED (keygen 198s, signing 120s)
- 4-of-7: PASSED (keygen 221s, signing 150s)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 06:57:53 -08:00
Developer 75226ce097 feat: Complete production deployment configuration
- Add config.example.yaml with all configuration options documented
- Add server-party service main.go with HTTP endpoints
- Fix message-router gRPC handler registration
- All services now buildable and deployable via docker-compose

Test results:
- Unit tests: 3/3 PASS
- Integration tests: 26/26 PASS
- E2E tests: 8/8 PASS
- Docker build: All 4 services built successfully

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 04:10:06 -08:00
Developer 0f70bb02fd fix: Complete E2E test fixes for account service authentication
- Fix CreateAccount to decode hex-encoded public key before storage
- Fix Login signature verification to hash challenge before verifying
- Return 401 instead of 400 for invalid hex format in login credentials
- Fix CompleteRecovery to handle direct transition from requested state

All 8 E2E tests now pass (100% pass rate):
- TestAccountRecoveryFlow, TestCompleteAccountFlow, TestDuplicateUsername, TestInvalidLogin
- TestCompleteKeygenFlow, TestExceedParticipantLimit, TestGetNonExistentSession, TestJoinSessionWithInvalidToken

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 03:07:50 -08:00
Developer 393c0ef04d > 2025-11-29 01:35:10 -08:00
Developer 5faf4fc9a0 fix: Add hex encoding/decoding for account service authentication
- Add encoding/hex import to account handler
- Encode challenge as hex string in GenerateChallenge handler
- Decode hex-encoded challenge and signature in Login handler
- Decode hex-encoded public key in CompleteRecovery handler

This fixes compatibility between the test client (which uses hex encoding)
and the server handlers.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 01:34:32 -08:00
hailin cc6a76514b fix: Report completion for all 3 participants in TestCompleteKeygenFlow
The test was only reporting completion for one participant, but the session
requires ALL participants to report completion before transitioning to
"completed" status. This follows the domain logic in ShouldCompleteSession()
which checks session.AllCompleted().

Changes:
- Added reportCompletion calls for all 3 parties (party_user_device,
  party_server, party_recovery)
- Updated test comment to clarify all participants must report completion
2025-11-29 00:52:53 -08:00
hailin 7531cbd07a fix: Implement MarkPartyReady and StartSession handlers, update domain logic
- Add sessionRepo to HTTP handler for database operations
- Implement MarkPartyReady handler to update participant status
- Implement StartSession handler to start MPC sessions
- Update CanStart() to accept participants in 'ready' status
- Make Start() method idempotent to handle automatic + explicit starts
- Fix repository injection through dependency chain in main.go
- Add party_id parameter to test completion request
2025-11-29 00:31:24 -08:00
hailin 6fa4d7ac1d feat: 添加MPC多方计算服务模块
新增 mpc-service 微服务,实现 MPC-TSS 门限签名功能:

架构设计:
- 采用六边形架构(Hexagonal Architecture)
- 实现 CQRS 命令查询职责分离模式
- 遵循 DDD 领域驱动设计原则

核心功能:
- Keygen: 分布式密钥生成协议参与
- Signing: 门限签名协议参与
- Share Rotation: 密钥份额轮换
- Share Management: 份额查询和管理

技术栈:
- NestJS + TypeScript
- Prisma ORM
- Redis (缓存和分布式锁)
- Kafka (事件发布)
- Jest (单元/集成/E2E测试)

测试覆盖:
- 单元测试: 81个
- 集成测试: 30个
- E2E测试: 15个
- 总计: 111个测试全部通过

文档:
- ARCHITECTURE.md: 架构设计文档
- API.md: REST API接口文档
- TESTING.md: 测试架构说明
- DEVELOPMENT.md: 开发指南
- DEPLOYMENT.md: 部署运维文档

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:31:43 -08:00
hailin 92a227b576 . 2025-11-24 12:00:38 +00:00
hailin 7367838324 . 2025-11-24 03:59:50 -08:00
hailin 9a00c611b7 . 2025-11-24 03:49:34 -08:00
hailin ed5bafbfad . 2025-11-24 03:46:12 -08:00
hailin d09af9aa3e . 2025-11-24 03:43:25 -08:00
hailin cf706d95a8 . 2025-11-24 11:40:27 +00:00
hailin c08a692c97 . 2025-11-24 03:38:54 -08:00
hailin 0340d068e7 . 2025-11-24 03:35:26 -08:00
hailin 9e854c3888 . 2025-11-24 11:30:43 +00:00
hailin ff65cdf3c1 . 2025-11-24 03:26:09 -08:00
hailin 4cdd0b07b9 . 2025-11-24 03:21:24 -08:00
hailin fbcef7aba2 . 2025-11-24 03:14:38 -08:00
hailin ff2bbbc977 . 2025-11-24 03:11:05 -08:00
hailin 0e9dc61961 . 2025-11-24 03:03:41 -08:00
hailin 169ca891e6 . 2025-11-24 02:58:50 -08:00
hailin 0b1defb78b . 2025-11-24 02:54:27 -08:00
hailin 3aaac6af6f . 2025-11-24 02:50:45 -08:00
hailin c6c2545095 . 2025-11-24 02:38:15 -08:00
hailin 77725bd769 . 2025-11-24 02:33:14 -08:00
hailin 015f314907 . 2025-11-24 02:31:30 -08:00
hailin 8e3aa0e794 . 2025-11-24 02:29:44 -08:00
hailin f9a0f95cab . 2025-11-24 02:19:40 -08:00
hailin 4fbca69942 . 2025-11-24 02:12:13 -08:00
hailin d8f23a8913 . 2025-11-24 02:08:47 -08:00
hailin abc87306d2 . 2025-11-24 01:59:58 -08:00
hailin dce2ea5963 . 2025-11-24 01:48:17 -08:00
hailin 8f639273b1 . 2025-11-24 01:41:54 -08:00
hailin 19b6415c95 . 2025-11-24 17:06:30 +08:00
hailin ef1ef8ba25 . 2025-11-24 08:27:36 +00:00
hailin 1469b45723 . 2025-11-24 07:49:40 +00:00
hailin 4b03c422ea . 2025-11-24 07:47:29 +00:00
hailin e2055483db . 2025-11-24 07:25:33 +00:00
hailin 44d2e2ad80 . 2025-11-24 06:58:46 +00:00
hailin c29c185a03 identity_service_context first commit 2025-11-24 06:09:06 +00:00
hailin b9a3fb9a83 first commit 2025-11-23 21:21:44 -08:00