Commit Graph

2 Commits

Author SHA1 Message Date
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 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