hailin
1df5854825
feat(multi-tenant): apply tenant middleware and refactor repositories
...
- Apply TenantContextMiddleware to all 6 services
- Add SimpleTenantFinder for services without direct tenant DB access
- Add TenantFinderService for evolution-service with database access
- Refactor 8 repositories to extend BaseTenantRepository:
- user-postgres.repository.ts
- verification-code-postgres.repository.ts
- conversation-postgres.repository.ts
- message-postgres.repository.ts
- token-usage-postgres.repository.ts
- file-postgres.repository.ts
- order-postgres.repository.ts
- payment-postgres.repository.ts
- Add @iconsulting/shared dependency to evolution-service and knowledge-service
- Configure middleware to exclude health and super-admin paths
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 18:30:31 -08:00
hailin
422069be68
feat: add enterprise multi-tenancy infrastructure
...
- Add shared tenant module with AsyncLocalStorage-based context management
- Create TenantContextService, TenantContextMiddleware, TenantGuard
- Add @TenantId(), @Tenant(), @RequireFeatures() decorators
- Create BaseTenantRepository for automatic tenant filtering
- Add TenantORM entity for tenants table
- Add tenant_id column to all 16 ORM entities across 6 services
- Create database migration script for multi-tenancy support
- Add tenant-related error codes
This implements row-level isolation for 100% data separation between tenants.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 18:11:12 -08:00
hailin
931055b51f
feat(admin): add conversation management with device tracking display
...
## Backend (conversation-service)
- Add AdminConversationController with JWT auth for admin API
- Endpoints: list conversations, by user, detail, messages, statistics
- Support filtering by status, userId, date range, conversion
- Add JWT_SECRET environment variable to docker-compose.yml
- Add jsonwebtoken dependency for admin token verification
## Frontend (admin-client)
### New Features:
- Add conversations feature module with:
- API layer (conversations.api.ts)
- React Query hooks (useConversations.ts)
- ConversationsPage with full management UI
### User Management Enhancement:
- Add "最近咨询记录" section in user detail drawer
- Display device info for each conversation:
- IP address with region
- User-Agent (parsed to browser/OS)
- Device fingerprint
- Show conversation status, conversion status, message count
### Navigation:
- Add "对话管理" menu item with MessageOutlined icon
- Add /conversations route
## Files Added:
- admin-conversation.controller.ts (backend admin API)
- conversations feature folder (frontend)
- infrastructure/conversations.api.ts
- application/useConversations.ts
- presentation/pages/ConversationsPage.tsx
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 10:04:17 -08:00
hailin
28df6fb89c
chore: update pnpm-lock.yaml for jsonwebtoken dependency
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 09:05:57 -08:00
hailin
042d2e1456
feat(analytics): implement statistics, financial reports, and audit logging
...
Backend (evolution-service):
- Add analytics module with scheduled statistics aggregation
- Implement daily_statistics aggregation (OVERALL, CHANNEL, CATEGORY)
- Add monthly financial report generation and management
- Create audit log service for operation tracking
- Schedule cron jobs for automatic data aggregation
Frontend (admin-client):
- Replace dashboard mock data with real API calls
- Add analytics page with trend charts and dimension breakdown
- Add financial reports page with confirm/lock workflow
- Add audit logs page with filtering and detail view
- Update navigation with analytics submenu
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 08:01:39 -08:00
hailin
02954f56db
refactor(services): implement Clean Architecture across 4 services
...
## Overview
Refactor user-service, payment-service, file-service, and conversation-service
to follow Clean Architecture pattern based on knowledge-service reference.
## Architecture Pattern Applied
```
src/
├── domain/
│ ├── entities/ # Pure domain entities (no ORM decorators)
│ └── repositories/ # Repository interfaces + Symbol DI tokens
├── infrastructure/
│ └── database/postgres/
│ ├── entities/ # ORM entities with TypeORM decorators
│ └── *-postgres.repository.ts # Repository implementations
└── {feature}/
└── {feature}.module.ts # DI configuration with Symbol providers
```
## Changes by Service
### user-service (40% → 100% compliant)
- Created: IUserRepository, IVerificationCodeRepository interfaces
- Created: UserORM, VerificationCodeORM entities
- Created: UserPostgresRepository, VerificationCodePostgresRepository
- Modified: UserEntity, VerificationCodeEntity → pure domain with factory methods
- Updated: user.module.ts, auth.module.ts with Symbol-based DI
### payment-service (50% → 100% compliant)
- Created: IOrderRepository, IPaymentRepository interfaces
- Created: OrderORM, PaymentORM entities
- Created: OrderPostgresRepository, PaymentPostgresRepository
- Modified: OrderEntity, PaymentEntity → pure domain with factory methods
- Updated: order.module.ts, payment.module.ts with Symbol-based DI
### file-service (40% → 100% compliant)
- Created: IFileRepository interface
- Created: FileORM entity
- Created: FilePostgresRepository
- Modified: FileEntity → pure domain with factory methods
- Updated: file.module.ts with Symbol-based DI
### conversation-service (60% → 100% compliant)
- Created: IConversationRepository, IMessageRepository, ITokenUsageRepository
- Created: ConversationORM, MessageORM, TokenUsageORM entities
- Created: ConversationPostgresRepository, MessagePostgresRepository,
TokenUsagePostgresRepository
- Modified: ConversationEntity, MessageEntity, TokenUsageEntity → pure domain
- Updated: conversation.module.ts with Symbol-based DI
- Updated: app.module.ts, data-source.ts entity patterns
## Key Implementation Details
1. **Symbol-based DI Pattern**:
```typescript
export const USER_REPOSITORY = Symbol('IUserRepository');
@Module({
providers: [{ provide: USER_REPOSITORY, useClass: UserPostgresRepository }],
exports: [UserService, USER_REPOSITORY],
})
```
2. **Pure Domain Entities**: Factory methods `create()` and `fromPersistence()`
for controlled instantiation without ORM decorators
3. **Repository Implementations**: Include `toORM()` and `toEntity()` conversion
methods for anti-corruption layer between domain and infrastructure
4. **Entity Discovery**: Changed glob pattern from `*.entity` to `*.orm`
in app.module.ts and data-source.ts files
## Breaking Changes
- None for API consumers
- Internal architecture restructuring only
## Testing
- All 4 services compile successfully with `pnpm build`
- Database schema compatibility verified (column mappings preserved)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-24 21:18:25 -08:00
hailin
d4925719fc
feat(multimodal): add file upload and image support for chat
...
- Add MinIO object storage to docker-compose infrastructure
- Create file-service microservice for upload management with presigned URLs
- Add files table to database schema
- Update nginx and Kong for MinIO proxy routes
- Implement file upload UI in chat InputArea with drag-and-drop
- Add attachment preview in MessageBubble component
- Update conversation-service to handle multimodal messages
- Add Claude Vision API integration for image analysis
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 05:34:41 -08:00
hailin
c914693f94
feat(web): add markdown rendering for AI responses
2026-01-10 01:33:00 -08:00
hailin
7f2fc153b5
refactor: simplify Anthropic client config using baseURL
...
Remove https-proxy-agent dependency since ANTHROPIC_BASE_URL already
supports pointing to a proxy server directly.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 20:45:44 -08:00
hailin
ea760b5695
chore: update pnpm-lock.yaml for https-proxy-agent
...
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 20:37:36 -08:00
hailin
a7add8ff90
Initial commit: iConsulting 香港移民咨询智能客服系统
...
项目架构:
- Monorepo (pnpm + Turborepo)
- 后端: NestJS 微服务 + Claude Agent SDK
- 前端: React + Vite + Ant Design
包含服务:
- conversation-service: 对话服务 (Claude AI)
- user-service: 用户认证服务
- payment-service: 支付服务 (支付宝/微信/Stripe)
- knowledge-service: 知识库服务 (RAG + Neo4j)
- evolution-service: 自我进化服务
- web-client: 用户前端
- admin-client: 管理后台
基础设施:
- PostgreSQL + Redis + Neo4j
- Kong API Gateway
- Nginx 反向代理
- Docker Compose 部署配置
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 00:01:12 -08:00