feat(backend): Implement SignalR real-time communication infrastructure

Add complete SignalR infrastructure for real-time project collaboration and notifications with multi-tenant isolation and JWT authentication.

Changes:
- Created BaseHub with multi-tenant isolation and JWT authentication helpers
- Created ProjectHub for real-time project collaboration (join/leave, typing indicators)
- Created NotificationHub for user-level notifications
- Implemented IRealtimeNotificationService for application layer integration
- Configured SignalR in Program.cs with CORS and JWT query string support
- Added SignalRTestController for connection testing
- Documented hub endpoints, client events, and integration examples

Features:
- Multi-tenant isolation via automatic tenant group membership
- JWT authentication (Bearer header + query string for WebSocket)
- Hub endpoints: /hubs/project, /hubs/notification
- Project-level events: IssueCreated, IssueUpdated, IssueStatusChanged, etc.
- User-level notifications with tenant-wide broadcasting
- Test endpoints for validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yaojia Wang
2025-11-04 09:04:13 +01:00
parent 172d0de1fe
commit 5a1ad2eb97
8 changed files with 745 additions and 3 deletions

View File

@@ -0,0 +1,15 @@
namespace ColaFlow.API.Services;
public interface IRealtimeNotificationService
{
// Project-level notifications
Task NotifyProjectUpdate(Guid tenantId, Guid projectId, object data);
Task NotifyIssueCreated(Guid tenantId, Guid projectId, object issue);
Task NotifyIssueUpdated(Guid tenantId, Guid projectId, object issue);
Task NotifyIssueDeleted(Guid tenantId, Guid projectId, Guid issueId);
Task NotifyIssueStatusChanged(Guid tenantId, Guid projectId, Guid issueId, string oldStatus, string newStatus);
// User-level notifications
Task NotifyUser(Guid userId, string message, string type = "info");
Task NotifyUsersInTenant(Guid tenantId, string message, string type = "info");
}