Commit graph

296 commits

Author SHA1 Message Date
senke
b8adaf8935 [BE-SVC-022] be-svc: Implement data export service
- Created DataExportService for comprehensive user data export (GDPR compliance)
- Exports all user data: profile, settings, tracks, playlists, comments, likes, analytics, federated identities, roles
- Added ExportUserData method to retrieve all user data from database
- Added ExportUserDataAsJSON method to export as downloadable JSON file
- Added endpoint GET /api/v1/users/me/export that returns JSON file download
- Comprehensive unit tests for export service
- Proper error handling and logging

Phase: PHASE-6
Priority: P2
Progress: 118/267 (44.19%)
2025-12-24 18:01:00 +01:00
senke
250d243fb8 [BE-SVC-021] be-svc: Implement error recovery mechanisms
- Created recovery package with comprehensive retry logic
- Implemented Retry and RetryWithResult with configurable strategies
- Added exponential backoff with jitter support
- Created multiple recovery strategies:
  - RetryRecoveryStrategy: retry with backoff
  - FallbackRecoveryStrategy: fallback function
  - CircuitBreakerRecoveryStrategy: wait for circuit breaker
  - CompositeRecoveryStrategy: combine multiple strategies
- Added helper functions: IsRetryableError, IsTemporaryError, IsPermanentError
- Support for context cancellation and timeout
- Comprehensive unit tests for all recovery mechanisms

Phase: PHASE-6
Priority: P2
Progress: 117/267 (43.82%)
2025-12-24 17:52:53 +01:00
senke
fe7cf7fc04 [BE-SVC-020] be-svc: Implement request validation improvements
- Enhanced error messages in validator with more descriptive and contextual messages
- Added custom validations: slug, phone, date_iso, not_empty
- Created QueryParamValidation middleware for query parameter validation
- Support for validation rules: numeric, integer, min, max, oneof, email, uuid, url
- Improved error messages for all validation tags (40+ tags supported)
- Comprehensive unit tests for query parameter validation
- Better error context and user-friendly messages

Phase: PHASE-6
Priority: P2
Progress: 116/267 (43.45%)
2025-12-24 17:09:54 +01:00
senke
7bafb85e22 [BE-SVC-019] be-svc: Implement API versioning strategy
- Created VersionManager for managing API versions
- Added VersionMiddleware for automatic version detection:
  - X-API-Version header
  - Accept header (application/vnd.veza.v1+json)
  - URL path (/api/v1/...)
- Added support for deprecated versions with sunset dates
- Added /api/versions endpoint for version information
- Added helpers: GetAPIVersion, GetAPIVersionInfo
- Comprehensive unit tests for versioning system
- Integrated version manager in APIRouter

Phase: PHASE-6
Priority: P2
Progress: 115/267 (43.07%)
2025-12-24 17:07:30 +01:00
senke
0ac3b82962 [BE-SVC-018] be-svc: Implement request tracing
- Created TraceContext struct for distributed tracing
- Implemented W3C Trace Context format support (traceparent header)
- Added backward compatibility with legacy X-Trace-ID and X-Span-ID headers
- Created HTTPClientWithTracing for automatic trace propagation in outgoing requests
- Enhanced Tracing middleware to use new trace context system
- Added context propagation helpers (WithTraceContext, FromContext)
- Added child span creation for nested operations
- Comprehensive unit tests for trace context and HTTP client

Phase: PHASE-6
Priority: P2
Progress: 114/267 (42.70%)
2025-12-24 17:05:32 +01:00
senke
965633ef89 [BE-SVC-017] be-svc: Implement graceful shutdown
- Created ShutdownManager for coordinated graceful shutdown of all services
- Added Shutdowner interface for services that need graceful shutdown
- Implemented parallel shutdown with individual timeouts (10s per service)
- Added global shutdown timeout (30s total)
- Integrated shutdown manager in main.go for:
  - HTTP server shutdown
  - JobWorker cancellation
  - Config.Close() (DB, Redis, RabbitMQ)
  - Logger sync
  - Sentry flush
- Added comprehensive unit tests for shutdown manager
- Prevents registration of new services during shutdown

Phase: PHASE-6
Priority: P2
Progress: 113/267 (42.32%)
2025-12-24 17:03:11 +01:00
senke
2f2c8a032c [BE-SVC-016] be-svc: Implement health check improvements
- Enhanced HealthCheck struct with Details field for additional metrics
- Added detailed database pool statistics (open connections, in use, idle, wait counts)
- Added health checks for S3 storage service (if enabled)
- Added health checks for Job Worker with job queue statistics
- Added health checks for Email Sender (SMTP configuration)
- Updated HealthHandler to accept additional services
- Updated router to pass S3, JobWorker, and EmailSender to health handler

Phase: PHASE-6
Priority: P2
Progress: 112/267 (41.95%)
2025-12-24 17:00:53 +01:00
senke
e1cf8472b6 [BE-SVC-015] be-svc: Implement logging aggregation
- Added HTTP writer for centralized log collection (Loki-compatible)
- Created AggregationConfig with batch processing and flush intervals
- Integrated with existing zap logger using multi-core approach
- Added environment variables for configuration (LOG_AGGREGATION_ENABLED, LOG_AGGREGATION_ENDPOINT, etc.)
- Added unit tests for aggregation functionality
- Updated config.go to initialize logger with aggregation if enabled

Phase: PHASE-6
Priority: P2
Progress: 111/267 (41.57%)
2025-12-24 16:58:58 +01:00
senke
f5d8486caa [BE-SVC-014] be-svc: Implement monitoring and alerting
- Created monitoring and alerting service with Prometheus integration
- Support for alert rules with thresholds and severities
- Alert firing and resolution tracking
- Notification callbacks for alert events
- Continuous monitoring with configurable intervals
- Default alert rules for common scenarios
- Prometheus query evaluation and threshold checking
- Comprehensive unit tests for core functionality
2025-12-24 16:54:19 +01:00
senke
03f35dbb7c [BE-SVC-013] be-svc: Implement CDN integration
- Created CDN service with support for multiple providers
- Support for CloudFront, Cloudflare, and generic CDN
- URL generation for assets, audio, HLS streams, and images
- Cache invalidation with batch support
- Signed URL generation for private content
- Cache headers configuration
- Provider abstraction for easy switching
- Comprehensive unit tests for all functionality
2025-12-24 16:52:06 +01:00
senke
0090fdfb8b [BE-SVC-012] be-svc: Implement HLS streaming service
- Enhanced HLS streaming service with additional features
- Stream validation and health checks
- URL generation for master and quality playlists
- Stream cleanup and management
- Statistics and monitoring
- Stream listing with filtering and pagination
- Status updates and existence checks
- Comprehensive unit tests for core functionality
2025-12-24 16:49:57 +01:00
senke
d52efd811e [BE-SVC-011] be-svc: Implement audio transcoding service
- Created AudioTranscodeService with FFmpeg support
- Support for multiple audio formats (MP3, AAC, FLAC, OGG, WAV, M4A)
- Configurable bitrates and quality presets (low, medium, high, lossless)
- Sample rate and channel configuration
- Timeout handling and error management
- Transcode and TranscodeMultiple methods
- FFmpeg availability checking
- Audio metadata extraction using ffprobe
- Format validation and codec selection
- Comprehensive unit tests for core functionality
2025-12-24 16:47:48 +01:00
senke
dee331c5ff [BE-SVC-010] be-svc: Implement image processing service
- Enhanced image processing service with multiple features
- Support for multiple image sizes (thumbnail, small, medium, large)
- Multiple output formats (JPEG, PNG, WebP)
- Configurable quality settings and processing options
- ProcessImage with customizable options
- ProcessAvatar for optimized avatar processing
- ProcessImageMultipleSizes for batch processing
- OptimizeImage for target file size optimization
- Image format conversion and validation
- Comprehensive unit tests for core functions
2025-12-24 16:44:58 +01:00
senke
5ed6929aa9 [BE-SVC-009] be-svc: Implement notification service
- Created Notification model for GORM with proper relationships
- Enhanced NotificationService with GORM-based implementation
- Features: pagination, filtering by type/read status, batch creation
- Mark as read (single and all), deletion (single and all read)
- Unread count and notification types listing
- Comprehensive unit tests for all operations
- Better error handling and logging
2025-12-24 16:41:11 +01:00
senke
597607bf01 [BE-SVC-008] be-svc: Implement analytics aggregation service
- Created AnalyticsAggregationService for analytics_events table
- Aggregation by event type and time period (hour, day, week, month)
- Support for filtering by event names and user ID
- Features: event counts, unique users, average per user, payload summary
- Top events ranking and user activity counts
- Uses PostgreSQL date_trunc and to_char for period grouping
- Added unit tests for service validation and helper functions
2025-12-24 16:38:09 +01:00
senke
6e4590d493 [BE-SVC-007] be-svc: Implement recommendation engine
- Created TrackRecommendationService with ML-based algorithms
- Collaborative filtering (40%) using similar users' preferences
- Content-based filtering (30%) using track metadata (genre, artist, year)
- Popularity scoring (20%) based on play_count and like_count
- Recency scoring (10%) for recently uploaded tracks
- Support for seed tracks, genre filtering, and track exclusion
- Added unit tests for scoring algorithms
- Combines multiple algorithms for personalized recommendations
2025-12-24 16:34:17 +01:00
senke
301370ad1a [BE-SVC-006] be-svc: Implement search service
- Created FullTextSearchService using PostgreSQL tsvector/tsquery
- Supports full-text search for tracks, users, and playlists
- Uses GIN indexes from migration 048_search_indexes.sql
- Features relevance scoring with ts_rank_cd
- Weighted search (title/name weighted higher than description)
- Pagination and minimum relevance score filtering
- Unified search across all types and individual search methods
- Added unit tests for service validation and query preparation
2025-12-24 16:31:40 +01:00
senke
4c652150c5 [BE-SVC-005] be-svc: Implement file storage abstraction
- Added AWS SDK v2 dependency for S3 support
- Created S3StorageService implementing S3Service interface
- Support for AWS S3 and MinIO (S3-compatible storage)
- Added S3 configuration in config.go with environment variables
- Implemented upload, delete, presigned URL, and public URL methods
- Added unit tests for service validation and URL generation
- Service integrates with existing TrackStorageService
2025-12-24 16:28:51 +01:00
senke
1cf863a78b [BE-SVC-004] be-svc: Implement email service 2025-12-24 16:11:02 +01:00
senke
64d764c16f [BE-SVC-003] be-svc: Implement background job queue 2025-12-24 16:08:51 +01:00
senke
dc4fd2f3e1 [BE-SVC-002] be-svc: Implement rate limiting per user 2025-12-24 16:04:36 +01:00
senke
a11e1820b6 [BE-SVC-001] be-svc: Implement caching layer for frequently accessed data 2025-12-24 16:02:16 +01:00
senke
80ce04e8c6 [BE-DB-018] be-db: Add database performance monitoring 2025-12-24 15:58:48 +01:00
senke
e23a701d7b [BE-DB-017] be-db: Add database migration rollback tests 2025-12-24 15:57:19 +01:00
senke
96d9065066 [BE-DB-016] be-db: Add database backup strategy 2025-12-24 15:55:46 +01:00
senke
0bc1192ee4 [BE-DB-015] be-db: Optimize database connection pooling 2025-12-24 15:53:19 +01:00
senke
3ab31d9c5c [BE-DB-014] be-db: Add database triggers for audit logging 2025-12-24 15:47:38 +01:00
senke
8007d9e387 [BE-DB-013] be-db: Add database views for common queries 2025-12-24 15:46:29 +01:00
senke
783ff06f13 [BE-DB-012] be-db: Create migration for analytics_events table (already exists) 2025-12-24 15:45:17 +01:00
senke
15618c3d98 [BE-DB-011] be-db: Add database constraints for data validation 2025-12-24 15:43:52 +01:00
senke
530f170ef9 [BE-DB-010] be-db: Add composite indexes for common queries 2025-12-24 15:14:17 +01:00
senke
caab043970 [BE-DB-009] be-db: Add indexes for search queries 2025-12-24 15:13:03 +01:00
senke
974ef31a9c [BE-DB-008] be-db: Create migration for notifications table 2025-12-24 15:12:11 +01:00
senke
5c8a49d4f5 [BE-DB-007] be-db: Create migration for user_blocks table 2025-12-24 15:11:32 +01:00
senke
c1f6e93c95 [BE-DB-006] be-db: Create migration for user_follows table 2025-12-24 15:10:34 +01:00
senke
d0e25a3924 [BE-DB-005] be-db: Create migration for playlist_share_link table 2025-12-24 15:09:44 +01:00
senke
b646243bdf [BE-DB-004] be-db: Add created_at and updated_at timestamps to all models 2025-12-24 15:08:43 +01:00
senke
012dca8da0 [BE-DB-003] be-db: Add soft delete support to all models 2025-12-24 15:07:25 +01:00
senke
ab1f78030b [BE-API-042] be-api: Implement OAuth callback endpoint 2025-12-24 15:05:40 +01:00
senke
5a41b8c976 [BE-API-041] be-api: Implement user delete endpoint with soft delete support 2025-12-24 15:03:21 +01:00
senke
0657b79d09 [BE-API-039] be-api: Implement marketplace order details endpoint 2025-12-24 15:00:32 +01:00
senke
04ea22149c [BE-API-038] be-api: Implement marketplace order list endpoint 2025-12-24 14:50:39 +01:00
senke
f6fa8d933a [BE-API-037] be-api: Implement marketplace product update endpoint 2025-12-24 14:49:41 +01:00
senke
3e4e2bb174 [BE-API-036] be-api: Implement track analytics dashboard endpoint 2025-12-24 14:48:28 +01:00
senke
20b8210339 [BE-API-035] be-api: Implement analytics events endpoint 2025-12-24 14:47:12 +01:00
senke
6cdd3b7abe [BE-API-026] be-api: Implement track quota endpoint validation 2025-12-24 14:45:12 +01:00
senke
64cdfcc7bd [BE-API-025] be-api: Implement upload resume endpoint validation 2025-12-24 14:42:52 +01:00
senke
bc7ff26958 [BE-API-005] be-api: Implement playlist recommendations endpoint 2025-12-24 14:41:33 +01:00
senke
061d8f11cc [FE-COMP-004] fe-comp: Add confirmation dialogs for destructive actions
- Created reusable ConfirmationDialog component for destructive actions
- Replaced native confirm() dialogs with ConfirmationDialog in ChatSidebar (leave room, delete room)
- Replaced native confirm() dialogs with ConfirmationDialog in RolesPage (delete role)
- Replaced Dialog with ConfirmationDialog in PlaylistActions (delete playlist)
- Replaced window.confirm() with ConfirmationDialog in SessionsPage (revoke session, revoke all sessions)
- All destructive actions now use consistent confirmation dialogs
- Confirmation dialogs include proper messaging, loading states, and variant support
- Improved UX with better visual feedback and clearer action descriptions
2025-12-24 14:38:55 +01:00
senke
f16a8dc030 [FE-COMP-003] fe-comp: Add empty states to all list views
- Created reusable EmptyState component with icon, title, description, and action support
- Improved empty state in PlaylistList with better messaging and icons
- Improved empty states in UserProfilePage for tracks and playlists tabs
- Added contextual messages based on whether viewing own profile or others
- Added helpful descriptions and icons to all empty states
- Empty states now provide clear guidance on what users can do next
- All list views now have consistent and helpful empty state messaging
2025-12-24 14:33:20 +01:00
senke
65529011f2 [FE-COMP-002] fe-comp: Add error boundaries to all pages
- Added ErrorBoundary to all public routes (login, register, forgot-password, verify-email, reset-password)
- Added ErrorBoundary to public user profile page (/u/:username)
- Added ErrorBoundary to protected routes: dashboard, marketplace, chat
- Added ErrorBoundary to settings/sessions route
- Added ErrorBoundary to admin/roles route
- Added ErrorBoundary to tracks/:id route
- Added ErrorBoundary to playlists/* route
- Added ErrorBoundary to search route
- Added ErrorBoundary to notifications route
- Added ErrorBoundary to error pages (404, 500)
- All pages now have error boundaries for graceful error handling
- Error boundaries provide fallback UI with retry and home navigation options
2025-12-24 14:31:28 +01:00
senke
e19f3a3db7 [FE-COMP-001] fe-comp: Add loading states to all async operations
- Created ButtonLoading component for consistent loading button pattern
- Created comprehensive loading states pattern guide
- Documented best practices for loading states in async operations
- Identified and documented existing loading state implementations
- Provided patterns for form submissions, data fetching, mutations, and skeleton loaders
- Created checklist for implementing loading states
- Documented examples from existing codebase

Most components already have loading states implemented. Pattern guide ensures consistency for future implementations.
2025-12-24 13:25:10 +01:00
senke
f47029a769 [FE-PAGE-014] fe-page: Add Notifications page
- Created dedicated Notifications page with full notification management
- Added notification service with API integration (get, mark as read, mark all as read)
- Added filtering by status (all/unread/read) and type (message/track/mention/system/etc)
- Added mark as read functionality for individual notifications
- Added mark all as read functionality
- Added notification type icons and labels
- Added notification timestamps with relative time formatting
- Added notification links support for navigation
- Added empty states for no notifications
- Added loading and error states
- Integrated with backend notification APIs
- Added route /notifications to router
- Added lazy loading for NotificationsPage component
- Added visual distinction for unread notifications (badge, background)
- Added notification type badges
2025-12-24 13:22:31 +01:00
senke
b553639d25 [FE-PAGE-013] fe-page: Add Search page
- Created dedicated Search page with unified search interface
- Added search functionality for tracks, playlists, and users
- Implemented tabs for filtering results by type (All/Tracks/Playlists/Users)
- Added search query debouncing for performance
- Added URL query parameter synchronization (q, type)
- Added pagination for each result type
- Added empty states for no query and no results
- Added loading states for all search operations
- Added error handling for search failures
- Integrated with existing search APIs (tracks, playlists, users)
- Added search service for user search API
- Added route /search to router
- Added lazy loading for SearchPage component
- Added result previews in All tab (6 items per type)
- Added View All buttons to navigate to specific tabs
2025-12-24 13:19:54 +01:00
senke
218d87f239 [FE-PAGE-012] fe-page: Complete Sessions page implementation
- Added user agent parser to extract device information (OS, browser, device type)
- Added device information display with formatted device details
- Added location information display (with support for private IP detection)
- Enhanced session cards with device type badges and detailed info
- Improved device icon selection based on device type (mobile/tablet/desktop)
- Added formatted device info display (OS, browser, versions)
- Added location display with MapPin icon
- Added device type badge (mobile/tablet/desktop)
- Improved visual hierarchy with better spacing and badges
- Maintained existing session management actions (revoke, revoke all)
2025-12-24 13:16:32 +01:00
senke
e8c0ee76cf [FE-PAGE-011] fe-page: Complete Roles page implementation
- Added CreateRoleModal for creating new roles
- Added EditRoleModal for editing existing roles
- Added AssignRoleModal for assigning roles to users
- Fixed roleService type issues (roleId from number to string)
- Enhanced RolesPage with create/edit/assign functionality
- Added UI section for assigning roles to users by ID
- Integrated all modals with existing role management
- Added proper form validation and error handling
- Added loading states for all async operations
- Added display of user current roles in assign modal
2025-12-24 13:13:54 +01:00
senke
eeaf8de57e [FE-PAGE-010] fe-page: Complete User Profile page (public)
- Added user tracks display with grid layout and pagination
- Added user playlists display with grid layout and pagination
- Added stats section showing tracks, playlists, and followers count
- Implemented tabs for switching between tracks and playlists
- Enhanced FollowButton with API integration (follow/unfollow)
- Added follow/unfollow API functions in profileService
- Added followers/following API functions (getFollowers, getFollowing)
- Added View All links for tracks and playlists when count > 12
- Improved profile layout with better organization
- Added empty states for tracks and playlists sections
2025-12-24 13:09:30 +01:00
senke
84ff7a23f3 [FE-PAGE-009] fe-page: Complete Playlist List page implementation
- Added server-side search using searchPlaylists API
- Added filtering: visibility (public/private), owner (all/mine/others)
- Added client-side sorting: by date, title, track count (asc/desc)
- Enhanced filter UI with collapsible filters panel
- Added sort controls with field selector and order toggle
- Integrated search API when search query or filters are active
- Maintained existing bulk operations (delete, share, export)
- Added clear filters button when filters are active
- Improved UX with filter badges and active state indicators
2025-12-24 13:05:21 +01:00
senke
373767de4b [FE-PAGE-008] fe-page: Complete Playlist Detail page implementation
- Added collaborator management UI with AddCollaboratorModal
- Added sharing functionality with SharePlaylistModal
- Added recommendations section using PlaylistRecommendations component
- Integrated CollaboratorList component in tabs
- Organized content in tabs (Tracks, Collaborators, Recommendations)
- Enhanced share button to open share modal with token generation
- Added Add Collaborator button for playlist owners/admins
- Integrated existing components: CollaboratorList, PlaylistRecommendations
2025-12-24 13:02:32 +01:00
senke
bad778ee5a [FE-PAGE-007] fe-page: Complete Track Detail page implementation
- Added comments section with CommentSection component
- Added sharing functionality with ShareDialog component
- Added version history display using TrackHistory component
- Added analytics display using TrackStatsDisplay component
- Organized content in tabs (Comments, History)
- Enhanced share button to open share dialog with token generation
- Integrated comment creation, deletion, and pagination
- Added track statistics display (views, likes, comments, downloads, play time)
2025-12-24 12:57:49 +01:00
senke
02cef0066a [FE-PAGE-006] fe-page: Complete Marketplace page implementation
- Added product browsing with pagination (page, limit, total_pages)
- Added product filtering: search, product type, price range
- Added cart functionality: add, remove, update quantity, checkout
- Created cartStore with Zustand and persistence
- Added Cart component with checkout functionality
- Enhanced ProductCard with Add to Cart button
- Added filter UI with collapsible filters panel
- Added search bar for product search
- Added pagination controls (Previous/Next)
- Updated marketplaceService to support filters and pagination
2025-12-24 12:54:20 +01:00
senke
80bb63150d [FE-PAGE-005] fe-page: Complete Chat page implementation
- Added room management: create, join, leave, delete rooms
- Added CreateRoomDialog component for creating new rooms
- Added room actions menu (leave/delete) in ChatSidebar
- Added message search functionality with MessageSearch component
- Added search bar in ChatRoom with message highlighting
- Added TypingIndicator component (placeholder for future WebSocket integration)
- Enhanced ChatSidebar with room management UI
- Enhanced ChatRoom with search and typing indicators
2025-12-24 12:51:40 +01:00
senke
902f4840d5 [FE-PAGE-004] fe-page: Complete Settings page implementation
- Added Account Settings section with password change, data export, and account deletion
- Added Playback Settings section with audio quality, volume, crossfade, and autoplay controls
- Updated SettingsTabs to include Account and Playback tabs (5 tabs total)
- Added PlaybackSettings interface to types
- Integrated account management features (password change, data export, account deletion)
- Added audio playback controls (quality selector, volume slider, crossfade slider, autoplay toggle)
2025-12-24 12:48:28 +01:00
senke
54e2f610ab [FE-PAGE-003] fe-page: Complete Profile page implementation
- Added profile completion indicator with progress bar
- Added profile completion percentage and missing fields display
- Added social links management (Twitter, Instagram, Facebook, YouTube, Website)
- Improved bio editing with Textarea component and character counter
- Added social links display when not editing
- Added location field
- Updated UpdateProfileRequest interface to include social_links
- Integrated profile completion API endpoint
2025-12-24 12:41:34 +01:00
senke
c2b4cb8302 [FE-PAGE-002] fe-page: Complete Library page implementation
- Added filtering by genre and format with dropdown selects
- Added sorting by date, title, and popularity with order toggle
- Added bulk operations: select multiple tracks, bulk delete, bulk update
- Added bulk mode toggle with selection checkboxes
- Added batch delete and batch update API functions
- Added pagination controls
- Improved UI with filter bar and sort dropdown
- Added toast notifications for operations
- Added select all/deselect all functionality
2025-12-24 12:38:25 +01:00
senke
dea05f4968 [FE-PAGE-001] fe-page: Complete Dashboard page implementation
- Created dashboardService.ts to fetch real stats and activity from API
- Created useDashboard hook for managing dashboard data
- Updated DashboardPage to use real data instead of hardcoded values
- Added loading states and skeletons for better UX
- Made quick actions functional with navigation
- Added activity timeline with real timestamps
- Formatted numbers with K/M suffixes for readability
- Added relative time formatting using date-fns
2025-12-24 12:35:38 +01:00
senke
f6ebb9d40e [BE-SEC-014] be-sec: Implement secrets management
- Enhanced secrets management with environment-aware defaults
- Fixed RabbitMQ URL: no default credentials in production
- Added getRabbitMQURL with environment-aware logic
- Added ValidateRequiredSecrets to validate required secrets
- Added RequiredSecretKeys listing production-required secrets
- Added validation for RabbitMQ URL in production
- All secrets properly managed via environment variables
- No hardcoded secrets in production code
2025-12-24 12:30:18 +01:00
senke
1394660da3 [BE-SEC-013] be-sec: Implement audit logging for security events
- Added comprehensive audit logging methods for security events
- LogPasswordChange, LogPasswordResetRequest, LogPasswordReset
- LogTwoFactorEnabled, LogTwoFactorDisabled, LogTwoFactorVerification
- LogAccessDenied, LogRoleChange, LogAccountLocked
- LogSecurityEvent for generic security events
- Integrated audit logging in password reset handlers
- All security events logged with IP, user agent, and metadata
2025-12-24 12:27:39 +01:00
senke
0366b87d94 [BE-SEC-011] be-sec: Implement security headers
- Enhanced security headers middleware with additional headers
- Added X-Permitted-Cross-Domain-Policies: none
- Added Cross-Origin-Embedder-Policy: require-corp
- Added Cross-Origin-Opener-Policy: same-origin
- Added Cross-Origin-Resource-Policy: same-origin
- Enhanced Permissions-Policy with additional restrictions
- Enhanced CSP with frame-ancestors directive
- HSTS now only set in production (not in development)
- Updated tests to verify all new headers
2025-12-24 12:24:54 +01:00
senke
03cb70ef41 [BE-SEC-010] be-sec: Implement file upload validation
- Enhanced file validation with robust magic bytes checking
- Added validateMagicBytes to prevent file type spoofing
- Added validateAudioMagicBytes (MP3, FLAC, WAV, OGG, AAC/M4A)
- Added validateImageMagicBytes (JPEG, PNG, GIF, WebP, SVG)
- Added validateVideoMagicBytes (MP4, WebM, OGG, AVI)
- Magic bytes validation runs before MIME type validation
- Existing validations: MIME type, file size, extension, ClamAV scanning
2025-12-24 12:17:06 +01:00
senke
d3bcfd8e60 [BE-SEC-009] be-sec: Implement input sanitization
- Created comprehensive sanitization utility functions
- SanitizeInput, SanitizeText, SanitizeHTML, SanitizeURL, SanitizeEmail, SanitizeUsername
- Applied sanitization to profile handler (username, bio, names, search)
- Applied sanitization to social posts content
- Applied sanitization to comment content
- Applied sanitization to playlist titles and descriptions
- All functions prevent XSS via HTML escaping and remove dangerous URL schemes
- Removes control characters and limits input length to prevent DoS
2025-12-24 12:15:25 +01:00
senke
d2fc79d0fe [BE-SEC-008] be-sec: Implement session timeout and refresh
- Added automatic session refresh mechanism in auth middleware
- Sessions are refreshed when they reach 25% of lifetime remaining
- Refresh happens asynchronously to avoid blocking requests
- Applied to both RequireAuth and OptionalAuth middlewares
- Session timeout enforced through ValidateSession checks
2025-12-24 12:12:29 +01:00
senke
44517da6f6 [BE-SEC-007] security: Implement account lockout after failed login attempts
- Created AccountLockoutService to track failed login attempts
- Accounts are locked after 5 failed attempts within 15 minutes
- Lockout duration: 30 minutes (auto-unlock)
- Service uses Redis for persistence (fail-open if Redis unavailable)
- Integrated into AuthService Login method:
  * Check account lockout status before login
  * Record failed attempts (even for non-existent users to prevent enumeration)
  * Reset failed attempts counter on successful login
  * Auto-unlock expired accounts
- Added SetAccountLockoutService method to AuthService
- Service initialized in router when Redis is available

Phase: PHASE-4
Priority: P1
Progress: 9/267 (3.4%)
2025-12-24 12:10:41 +01:00
senke
616a0ebc9c [BE-SEC-006] security: Implement comprehensive password strength validation
- Enhanced PasswordValidator with additional security checks:
  * Maximum length validation (128 characters)
  * Common password detection (password, 123456, qwerty, etc.)
  * Repetitive pattern detection (aaaa, 1111, etc.)
  * Sequential pattern detection (1234, abcd, qwerty, etc.)
- Added ValidatePasswordChange method to ensure new password is
  sufficiently different from old password (similarity check)
- Updated PasswordService to use enhanced validator consistently
- Replaced utils.ValidatePasswordStrength with validators.PasswordValidator
- All password operations now use the same comprehensive validation rules

Phase: PHASE-4
Priority: P1
Progress: 8/267 (3.0%)
2025-12-24 12:08:03 +01:00
senke
33d1aa988c [BE-SEC-005] security: Implement rate limiting for authentication endpoints
- Applied RegisterRateLimit to POST /auth/register (3 attempts/hour)
- Applied PasswordResetRateLimit to password reset endpoints (3 attempts/hour)
- Added VerifyEmailRateLimit for POST /auth/verify-email (5 attempts/hour)
- Added ResendVerificationRateLimit for POST /auth/resend-verification (3 attempts/hour)
- Login endpoint already had rate limiting (5 attempts/15min)
- All rate limits are IP-based and use Redis for persistence
- Rate limiting disabled in test/e2e environments

Phase: PHASE-4
Priority: P1
Progress: 7/267 (2.6%)
2025-12-24 12:05:35 +01:00
senke
078e512770 [BE-SEC-004] security: Implement CSRF protection for all state-changing endpoints
- Created applyCSRFProtection helper function to apply CSRF middleware
- Applied CSRF protection to all protected routes with POST/PUT/DELETE:
  * Users routes (PUT, POST, DELETE)
  * Tracks routes (POST, PUT, DELETE)
  * Playlists routes (POST, PUT, DELETE)
  * Chat routes (POST)
  * Auth protected routes (POST logout, 2FA)
  * Roles routes (GET only, no state-changing)
  * Marketplace routes (POST)
  * Webhooks routes (POST, DELETE)
  * Comments routes (POST, DELETE)
- CSRF token endpoint (/csrf-token) remains accessible without CSRF check
- Middleware validates X-CSRF-Token header for all state-changing requests
- Protection only applies when Redis is available

Phase: PHASE-4
Priority: P1
Progress: 6/267 (2.2%)
2025-12-24 12:03:27 +01:00
senke
46fb0cc148 [BE-API-040] api: Implement user list endpoint
- Added ListUsers method to UserService with pagination and filtering
- Added ListUsers handler to ProfileHandler
- Registered GET /api/v1/users endpoint in router
- Supports filtering by role, is_active, is_verified, and search
- Supports sorting by created_at, username, email, last_login_at
- Includes pagination metadata (page, limit, total, total_pages, has_next, has_prev)

Phase: PHASE-2
Priority: P1
Progress: 5/267 (1.9%)
2025-12-24 11:59:56 +01:00
senke
58d63f2447 chore: Update BE-API-034 completion status 2025-12-24 11:57:07 +01:00
senke
b7b23ff4da [BE-API-034] be-api: Implement audit log search improvements
- Added additional filters: resource_id, ip_address, user_agent
- Added page-based pagination support in addition to offset-based
- Added CountLogs method to get total count for pagination
- Standardized SearchLogs handler to use RespondSuccess/RespondWithAppError
- Replaced c.Get with GetUserIDUUID helper
- Improved validation for query parameters
- Response includes total count, page, total_pages, and offset metadata

Phase: PHASE-2
Priority: P2
Progress: 41/267 (15.4%)
2025-12-24 11:56:57 +01:00
senke
29c81029bd chore: Update BE-API-033 completion status 2025-12-24 11:54:31 +01:00
senke
2904e7284c [BE-API-033] be-api: Implement webhook stats endpoint validation
- Standardized GetWebhookStats handler to use RespondSuccess/RespondWithAppError
- Replaced c.Get with GetUserIDUUID helper
- Handler retrieves webhook statistics via WebhookWorker.GetStats
- Handler returns queue_size, workers, and max_retries
- Handler uses standard API response format
- Added apperrors import

Phase: PHASE-2
Priority: P2
Progress: 40/267 (15.0%)
2025-12-24 11:54:22 +01:00
senke
31c71bfa89 chore: Update BE-API-032 completion status 2025-12-24 11:52:58 +01:00
senke
78a25f63f7 [BE-API-032] be-api: Implement upload stats endpoint
- Added GetUploadStats method in TrackUploadService to calculate statistics from tracks table
- Standardized GetUploadStats handler to use RespondSuccess/RespondWithAppError
- Replaced c.Get with GetUserIDUUID helper
- Handler retrieves statistics: total_uploads, total_size, audio_files, image_files, video_files
- Updated UploadHandler to include TrackUploadService dependency
- Updated router to pass TrackUploadService to UploadHandler

Phase: PHASE-2
Priority: P2
Progress: 39/267 (14.6%)
2025-12-24 11:52:49 +01:00
senke
325c496254 chore: Update BE-API-031 completion status 2025-12-24 11:48:54 +01:00
senke
d294245761 [BE-API-031] be-api: Implement session stats endpoint
- Standardized GetSessionStats handler to use RespondSuccess/RespondWithAppError
- Replaced c.Get with GetUserIDUUID helper
- Handler retrieves session statistics via SessionService.GetSessionStats
- Handler returns total_active sessions and unique_users count
- Handler uses standard API response format

Phase: PHASE-2
Priority: P2
Progress: 38/267 (14.2%)
2025-12-24 11:48:43 +01:00
senke
7724d28325 chore: Update BE-API-030 completion status 2025-12-24 11:47:25 +01:00
senke
5886fba2ec [BE-API-030] be-api: Implement session refresh endpoint validation
- Standardized RefreshSession handler to use RespondSuccess/RespondWithAppError
- Replaced c.Get with GetUserIDUUID helper
- Handler validates Authorization header and extracts Bearer token
- Handler extends session timeout to 24 hours via SessionService.RefreshSession
- Handler properly handles errors (session not found, expired, internal errors)
- Handler returns message, expires_in, and expires_at
- Handler uses standard API response format

Phase: PHASE-2
Priority: P1
Progress: 37/267 (13.9%)
2025-12-24 11:47:15 +01:00
senke
f9fde5e45b chore: Update BE-API-029 completion status 2025-12-24 11:45:41 +01:00
senke
4af22ab1c2 [BE-API-029] be-api: Implement shared track access endpoint validation
- Standardized GetSharedTrack handler to use RespondSuccess/RespondWithAppError
- Handler validates share token via TrackShareService.ValidateShareToken
- Handler retrieves track by share.TrackID
- Handler properly handles errors (share not found, expired, track not found)
- Handler returns track and share information
- Handler uses standard API response format
- Endpoint is public (no authentication required)

Phase: PHASE-2
Priority: P1
Progress: 36/267 (13.5%)
2025-12-24 11:45:27 +01:00
senke
fb31c6ceb8 chore: Update BE-API-028 completion status 2025-12-24 11:43:47 +01:00
senke
3a38b23381 [BE-API-028] be-api: Implement track share revoke endpoint validation
- Standardized RevokeShare handler to use RespondSuccess/RespondWithAppError
- Handler validates share ID and checks ownership
- Handler revokes share link via TrackShareService.RevokeShare
- Handler properly handles errors (share not found, forbidden, internal errors)
- Handler uses standard API response format

Phase: PHASE-2
Priority: P1
Progress: 35/267 (13.1%)
2025-12-24 11:43:31 +01:00
senke
0024b5320e chore: Update BE-API-027 completion status 2025-12-24 11:42:12 +01:00
senke
5bc2498744 [BE-API-027] be-api: Implement user liked tracks endpoint
- Standardized GetUserLikedTracks handler to use RespondSuccess/RespondWithAppError
- Added limit validation (max 100)
- Moved route from setupTrackRoutes to setupUserRoutes in protected group
- Handler uses existing TrackLikeService methods
- Handler returns paginated results with tracks, total, limit, and offset
- Handler uses standard API response format

Phase: PHASE-2
Priority: P1
Progress: 34/267 (12.7%)
2025-12-24 11:41:50 +01:00
senke
cabe17b1f2 chore: Update BE-API-024 completion status 2025-12-24 11:39:30 +01:00
senke
dc9e52ae7c [BE-API-024] be-api: Implement track batch operations validation
- Standardized BatchDeleteTracks and BatchUpdateTracks handlers
- Handlers use RespondSuccess and RespondWithAppError
- BatchDeleteTracks validates IDs, checks ownership, deletes in batch
- BatchUpdateTracks validates IDs and updates, checks ownership, updates in batch
- Both handlers return results with successful and failed operations
- Handlers use standard API response format

Phase: PHASE-2
Priority: P2
Progress: 33/267 (12.4%)
2025-12-24 11:39:21 +01:00
senke
f4dd60e230 chore: Update BE-API-023 completion status 2025-12-24 11:37:59 +01:00
senke
ea97662e63 [BE-API-023] be-api: Implement user completion endpoint validation
- Standardized GetProfileCompletion handler to use GetUserIDUUID
- Added validation to ensure completion percentage is between 0 and 100
- Handler already existed and was working correctly
- Endpoint returns correct completion percentage (0-100) and missing fields
- Handler uses standard API response format

Phase: PHASE-2
Priority: P1
Progress: 32/267 (12.0%)
2025-12-24 11:37:51 +01:00
senke
030905a1b2 chore: Update BE-API-022 completion status 2025-12-24 11:36:27 +01:00
senke
48734f8526 [BE-API-022] be-api: Implement avatar delete endpoint
- DeleteAvatar handler was already implemented and standardized
- Added route: DELETE /users/:userId/avatar
- Handler validates user authentication and ownership
- Handler deletes avatar file from storage and updates database
- Handler uses standard API response format

Phase: PHASE-2
Priority: P1
Progress: 31/267 (11.6%)
2025-12-24 11:36:15 +01:00
senke
e5ecaa7a3b chore: Update BE-API-021 completion status 2025-12-24 11:34:51 +01:00
senke
3afc57dfbc [BE-API-021] be-api: Implement avatar upload endpoint
- Standardized UploadAvatar handler to use RespondSuccess/RespondWithAppError
- Replaced common.GetUserIDFromContext with GetUserIDUUID
- Handler accepts both :userId and :id parameters
- Added route: POST /users/:userId/avatar
- Handler validates user authentication and ownership
- Handler uses existing ImageService methods
- Handler updates avatar URL in database

Phase: PHASE-2
Priority: P1
Progress: 30/267 (11.2%)
2025-12-24 11:34:41 +01:00
senke
a205ad44af chore: Update BE-API-020 completion status 2025-12-24 11:32:58 +01:00
senke
f75ebb5e20 [BE-API-020] be-api: Implement HLS stream info endpoint
- Added GetStreamInfo method to HLSService
- Added GetStreamInfo handler in HLSHandler
- Standardized GetStreamStatus handler to use RespondSuccess/RespondWithAppError
- Added routes: GET /tracks/:id/hls/info and GET /tracks/:id/hls/status
- GetStreamInfo returns general stream information
- GetStreamStatus returns status with processing info if applicable
- Handlers use standard API response format

Phase: PHASE-2
Priority: P1
Progress: 29/267 (10.9%)
2025-12-24 11:32:50 +01:00
senke
99edce5029 chore: Update BE-API-019 completion status 2025-12-24 11:31:13 +01:00
senke
971f9253bb [BE-API-019] be-api: Implement track play analytics endpoint
- Added RecordPlay handler in TrackHandler
- Added playbackAnalyticsService field and SetPlaybackAnalyticsService method
- Initialized PlaybackAnalyticsService in router.go
- Added route: POST /tracks/:id/play
- Handler accepts optional play_time in request body
- Handler uses existing PlaybackAnalyticsService.RecordPlayback method
- Handler uses standard API response format

Phase: PHASE-2
Priority: P1
Progress: 28/267 (10.5%)
2025-12-24 11:31:02 +01:00
senke
65062c5bbb chore: Update BE-API-018 completion status 2025-12-24 11:29:00 +01:00
senke
78862c6ee1 [BE-API-018] be-api: Implement user block/unblock endpoints
- Added BlockUser and UnblockUser methods to SocialService
- Added BlockUser and UnblockUser handlers in ProfileHandler
- Added routes: POST /users/:id/block and DELETE /users/:id/block
- Handlers use existing SocialService methods
- Includes validation to prevent users from blocking themselves
- Added IsBlocked helper method to check block status
- Handlers use standard API response format

Phase: PHASE-2
Priority: P2
Progress: 27/267 (10.1%)
2025-12-24 11:28:49 +01:00
senke
d869aa987a chore: Update BE-API-017 completion status 2025-12-24 11:26:42 +01:00
senke
94bac9a5fd [BE-API-017] be-api: Implement user follow/unfollow endpoints
- Added FollowUser and UnfollowUser handlers in ProfileHandler
- Added socialService field and SetSocialService method
- Initialized SocialService in setupUserRoutes
- Added routes: POST /users/:id/follow and DELETE /users/:id/follow
- Handlers use existing SocialService methods
- Includes validation to prevent users from following themselves
- Handlers use standard API response format

Phase: PHASE-2
Priority: P2
Progress: 26/267 (9.7%)
2025-12-24 11:26:32 +01:00
senke
e65f531b1d chore: Update BE-API-016 completion status 2025-12-24 11:23:44 +01:00
senke
398565d5a9 [BE-API-016] be-api: Implement notifications endpoints
- Standardized API responses in notification handlers
- Replaced c.Get with GetUserIDUUID for consistent user ID extraction
- Added routes: GET /notifications, POST /notifications/:id/read, POST /notifications/read-all
- Initialized NotificationService and NotificationHandlers in router
- Handlers and service already existed, only routes and response standardization were needed

Phase: PHASE-2
Priority: P1
Progress: 25/267 (9.4%)
2025-12-24 11:23:24 +01:00
senke
dd280ec020 chore: Update BE-API-015 completion status 2025-12-24 11:21:44 +01:00
senke
48c915db63 [BE-API-015] be-api: Implement playlist collaborators GET endpoint
- Endpoint already implemented in BE-API-002
- Route GET /playlists/:id/collaborators exists
- Handler GetCollaborators exists and uses standard API response format
- No changes needed

Phase: PHASE-2
Priority: P1
Progress: 24/267 (9.0%)
2025-12-24 11:21:28 +01:00
senke
7a725eb049 chore: Update BE-API-014 completion status 2025-12-24 11:20:43 +01:00
senke
50f58f1f16 [BE-API-014] be-api: Implement track versions restore endpoint
- Added RestoreVersion handler method in TrackHandler
- Initialized TrackVersionService in setupTrackRoutes
- Added POST /tracks/:id/versions/:versionId/restore route (protected)
- Handler uses existing TrackVersionService.RestoreVersion method
- Includes ownership check (only track owner can restore versions)

Phase: PHASE-2
Priority: P2
Progress: 23/267 (8.6%)
2025-12-24 11:20:38 +01:00
senke
b793e2496a chore: Update BE-API-013 completion status 2025-12-24 11:19:13 +01:00
senke
f90ddb0b0c [BE-API-013] be-api: Implement track comments endpoints
- Added GET /tracks/:id/comments route (public)
- Added POST /tracks/:id/comments route (protected)
- Added DELETE /comments/:id route (protected)
- Initialized CommentService and CommentHandler in setupTrackRoutes
- Standardized API responses in comment handlers
- Handlers use RespondSuccess and RespondWithAppError

Phase: PHASE-2
Priority: P1
Progress: 22/267 (8.2%)
2025-12-24 11:19:05 +01:00
senke
931b94ca28 chore: Update BE-API-012 completion status 2025-12-23 10:52:33 +01:00
senke
32c5f711d6 [BE-API-012] be-api: Implement conversation update endpoint
- Added UpdateRoom method to RoomService with ownership check
- Only room creator can update the room
- Added UpdateRoomRequest type
- Added UpdateRoom to RoomServiceInterface and RoomHandler
- Added PUT /conversations/:id route
- Handler uses standard API response format
- Service updates name and/or description fields

Phase: PHASE-2
Priority: P1
Progress: 21/267 (7.9%)
2025-12-23 10:51:18 +01:00
senke
dbe076d7dc chore: Update BE-API-011 completion status 2025-12-23 10:49:28 +01:00
senke
461add8300 [BE-API-011] be-api: Implement conversation participants endpoints
- Added RemoveMember method to RoomService and RoomServiceInterface
- Corrected RemoveMember in RoomRepository to use uuid.UUID
- Added AddParticipant and RemoveParticipant handlers
- Added POST /conversations/:id/participants route
- Added DELETE /conversations/:id/participants/:userId route
- Handlers use standard API response format
- Handlers reuse AddMember/RemoveMember service methods

Phase: PHASE-2
Priority: P1
Progress: 20/267 (7.5%)
2025-12-23 10:49:17 +01:00
senke
447a7ada46 chore: Update BE-API-010 completion status 2025-12-23 10:47:26 +01:00
senke
d1343dabfb [BE-API-010] be-api: Implement conversation delete endpoint
- Added DeleteRoom method to RoomService with ownership check
- Only room creator can delete the room
- Added DeleteRoom to RoomServiceInterface and RoomHandler
- Added DELETE /conversations/:id route
- Handler uses standard API response format
- Service performs soft delete via GORM

Phase: PHASE-2
Priority: P1
Progress: 19/267 (7.1%)
2025-12-23 10:47:17 +01:00
senke
431b7f1f06 chore: Update BE-API-009 completion status 2025-12-23 10:45:20 +01:00
senke
4959b44e8f [BE-API-009] be-api: Implement track search endpoint
- Added GET /tracks/search route in setupTrackRoutes
- Initialized TrackSearchService and set it in TrackHandler
- Handler SearchTracks and TrackSearchService already existed
- Supports query params: q, genre, artist, page, limit
- Service handles pagination, filtering, and returns tracks with pagination metadata

Phase: PHASE-2
Priority: P1
Progress: 18/267 (6.7%)
2025-12-23 10:45:08 +01:00
senke
67a3c4a175 chore: Update BE-API-008 completion status 2025-12-23 10:42:34 +01:00
senke
dda16108e7 [BE-API-008] be-api: Implement user search endpoint
- Created SearchUsers method in UserService with pagination support
- SearchUsers searches by username, email, first_name, and last_name using ILIKE
- Added SearchUsers handler in ProfileHandler with query params (q, page, limit)
- Added GET /users/search route in setupUserRoutes
- Returns paginated results with total count
- Password hashes are excluded from results

Phase: PHASE-2
Priority: P1
Progress: 17/267 (6.4%)
2025-12-23 10:42:26 +01:00
senke
1481be5ca4 chore: Update BE-API-007 completion status 2025-12-23 10:39:16 +01:00
senke
714f17f4c6 [BE-API-007] be-api: Implement roles management endpoints
- Standardized API responses in RoleHandler (RespondSuccess, RespondWithAppError)
- Added GET /api/v1/roles endpoint
- Added GET /api/v1/roles/:id endpoint
- Added POST /api/v1/users/:userId/roles endpoint
- Added DELETE /api/v1/users/:userId/roles/:roleId endpoint
- Created setupRoleRoutes function for role routes
- Handlers support both :id and :userId parameters
- All endpoints require authentication

Phase: PHASE-2
Priority: P1
Progress: 16/267 (6.0%)
2025-12-23 10:39:10 +01:00
senke
6b1f565750 chore: Update BE-API-006 completion status 2025-12-23 01:51:59 +01:00
senke
a3c055efbb [BE-API-006] be-api: Implement chat stats endpoint
- Added GetStats method to ChatService with database access
- Returns active_users (distinct users who sent messages in last 24h)
- Returns total_messages (non-deleted messages count)
- Returns rooms_active (rooms with messages in last 24h)
- Added GetStats handler and GET /chat/stats route
- Updated ChatService to use NewChatServiceWithDB for database access

Phase: PHASE-2
Priority: P1
Progress: 15/267 (5.6%)
2025-12-23 01:51:49 +01:00
senke
418d2b064c chore: Update BE-API-004 completion status 2025-12-23 01:51:06 +01:00
senke
bd938d6750 [BE-API-004] be-api: Implement playlist share link endpoint
- Added POST /playlists/:id/share route in router.go
- Initialized PlaylistShareService and set it in PlaylistService
- Handler CreateShareLink already existed and was fully implemented
- Standardized API response to return shareLink directly
- Route requires ownership or admin permission via middleware

Phase: PHASE-2
Priority: P1
Progress: 14/267 (5.2%)
2025-12-23 01:51:00 +01:00
senke
fbe7349679 [BE-API-003] be-api: Implement playlist search endpoint
- Added GET /playlists/search route in router.go
- Handler SearchPlaylists and service method already existed
- Supports query params: q, user_id, is_public, page, limit
- Service handles pagination, access control, and search filtering
- Route added to protected playlist group

Phase: PHASE-2
Priority: P1
Progress: 13/267 (4.9%)
2025-12-23 01:49:21 +01:00
senke
07c0959b8d [BE-DB-002] backend-database: Add foreign key constraints where missing
- Created migration 930_add_missing_foreign_keys.sql
- Added FK constraints for legacy fields: tracks.user_id, rooms.owner_id, messages.user_id, messages.parent_id
- Added FK constraint for audit_logs.user_id
- All constraints use ON DELETE SET NULL for legacy fields and audit_logs
- Verified primary foreign keys already have proper constraints in existing migrations
- Models already have proper GORM foreignKey tags

Phase: PHASE-1
Priority: P0
Progress: 12/267 (4.5%)
2025-12-23 01:48:33 +01:00
senke
e2c55b758c [BE-DB-001] backend-database: Add database indexes for performance-critical queries
- Created migration 920_add_performance_indexes.sql
- Added indexes on tracks.status, tracks.user_id, tracks.stream_status
- Added composite index on tracks(user_id, status)
- Added indexes on playlists.is_public, user_sessions.is_active
- Added composite index on user_sessions(user_id, is_active)
- Verified existing indexes on users.email, users.username, tracks.creator_id, playlists.user_id, sessions.user_id

Phase: PHASE-1
Priority: P0
Progress: 11/267 (4.1%)
2025-12-23 01:47:33 +01:00
senke
a14a5f0a29 [FE-API-002] frontend-api: Enable playlist collaborator service calls
- Removed requireFeature guards from collaborator functions
- Updated addCollaborator to use unwrapped response format
- Implemented getCollaborators to call GET endpoint
- Enabled PLAYLIST_COLLABORATION feature flag
- All collaborator CRUD operations now functional

Phase: PHASE-1
Priority: P0
Progress: 10/267 (3.7%)
2025-12-23 01:46:43 +01:00
senke
2f2fd47f7a [FE-API-001] frontend-api: Enable 2FA service calls when backend is ready
- Replaced axios with apiClient for automatic authentication
- Updated URLs to use /auth/2fa/* endpoints (was /2fa/*)
- Fixed verify() to accept (secret, code) matching backend
- Fixed disable() to accept password instead of code
- Enabled TWO_FACTOR_AUTH feature flag
- Service now properly calls backend endpoints

Phase: PHASE-1
Priority: P0
Progress: 9/267 (3.4%)
2025-12-23 01:45:47 +01:00
senke
651c8199b2 [INT-003] integration: Fix auth/login response format mismatch
- Added username field to UserResponse in Login handler
- Backend now returns { user: { id, email, username }, token: { access_token, refresh_token, expires_in } }
- Format matches frontend AuthResponse type
- Frontend client API already handles unwrapping correctly
- DTOs already use correct JSON tags (snake_case)

Phase: PHASE-1
Priority: P0
Progress: 8/267 (3.0%)
2025-12-23 01:44:54 +01:00
senke
854a248d70 [INT-002] integration: Fix type mismatches between frontend and backend
- Fixed queue_job_id: number -> string in hlsService.ts
- Fixed track_id: number -> string in trackService.ts
- Fixed id: number -> string in usePlaylistNotifications.ts
- Fixed Role.id, Permission.id, UserRole.id, UserRole.role_id, AssignRoleRequest.role_id: number -> string in role.ts
- Fixed playlist_id: number -> string in PlaylistAnalytics.tsx
- All IDs now consistently use string (UUID) type matching backend DTOs
- Backend already uses uuid.UUID for all entity IDs

Phase: PHASE-1
Priority: P0
Progress: 7/267 (2.6%)
2025-12-23 01:43:48 +01:00
senke
6887a97a3f [INT-001] integration: Fix API response format inconsistencies
- Fixed nested response structures in profile_handler.go (3 occurrences)
- Fixed nested response structures in playlist_handler.go (4 occurrences)
- Changed gin.H{"profile": profile} to profile directly
- Changed gin.H{"playlist": playlist} to playlist directly
- Changed gin.H{"collaborator": collaborator} to collaborator directly
- All responses now use consistent { success: true, data: {...} } format
- Frontend interceptor already handles unwrapping correctly

Phase: PHASE-1
Priority: P0
Progress: 6/267 (2.2%)
2025-12-23 01:42:53 +01:00
senke
f6ab2c6eeb [BE-API-002] api: Implement playlist collaborators endpoints
- Added routes in router.go: POST, GET, PUT, DELETE /playlists/:id/collaborators
- Applied RequireOwnershipOrAdmin middleware to POST, PUT, DELETE routes
- GET route accessible to collaborators (service layer checks permissions)
- Fixed UpdateCollaboratorPermission handler to use RespondWithAppError
- All handlers already existed in playlist_handler.go
- All endpoints properly authenticated and ownership checks enforced

Phase: PHASE-1
Priority: P0
Progress: 5/267 (1.9%)
2025-12-23 01:41:43 +01:00
senke
5e25825726 [BE-API-001] api: Implement 2FA endpoints (setup, verify, disable)
- Created TwoFactorHandler with SetupTwoFactor, VerifyTwoFactor, DisableTwoFactor, GetTwoFactorStatus
- Added routes: POST /auth/2fa/setup, POST /auth/2fa/verify, POST /auth/2fa/disable, GET /auth/2fa/status
- Updated LoginResponse DTO to include requires_2fa flag
- Updated Login handler to check 2FA status and return requires_2fa flag when enabled
- Reused existing TwoFactorService (already had QR generation and TOTP verification)
- Added VerifyTOTPCode helper method to TwoFactorService
- All endpoints properly authenticated with RequireAuth middleware

Phase: PHASE-1
Priority: P0
Progress: 4/267 (1.5%)
2025-12-23 01:40:28 +01:00
senke
246e3d9630 [BE-SEC-003] security: Fix ownership verification for playlist updates/deletes
- Added RequireOwnershipOrAdmin middleware to PUT/DELETE /playlists/:id routes
- Created playlistOwnerResolver that loads playlist from DB and returns owner user_id
- Service already handles ownership checks and collaborator permissions
- All existing integration tests pass (TestUpdatePlaylist_AsOwner, TestUpdatePlaylist_NotOwner, TestDeletePlaylist_AsOwner, TestDeletePlaylist_NotOwner)

Phase: PHASE-1
Priority: P0
Progress: 3/267 (1.1%)
2025-12-23 01:37:56 +01:00
senke
b76925c493 [BE-SEC-002] security: Fix ownership verification for track updates/deletes
- Verified RequireOwnershipOrAdmin middleware is correctly applied to PUT/DELETE /tracks/:id
- Verified trackOwnerResolver correctly loads track from DB and returns user_id
- Added comprehensive integration tests for ownership verification
- Test: user cannot update another user's track (403 Forbidden)
- Test: user cannot delete another user's track (403 Forbidden)
- Test: admin can update any track (200 OK)
- Test: admin can delete any track (200 OK)
- Test: user can update own track (200 OK)
- Test: user can delete own track (200 OK)
- All tests pass

Phase: PHASE-1
Priority: P0
Progress: 2/267 (0.7%)
2025-12-23 01:37:10 +01:00
senke
b9821db707 [BE-SEC-001] security: Fix ownership verification for user profile updates
- Verified RequireOwnershipOrAdmin middleware is correctly applied to PUT /users/:id
- Added integration tests for ownership verification
- Test: user cannot update another user's profile (403 Forbidden)
- Test: admin can update any profile (200 OK)
- Test: user can update own profile (200 OK)
- All tests pass

Phase: PHASE-1
Priority: P0
Progress: 1/267 (0.4%)
2025-12-23 01:36:04 +01:00