264 Commits

Author SHA1 Message Date
Copilot
5ba19104eb Enable connection pool monitoring and configure optimized Prisma connection limits (#174)
* Initial plan

* feat: enable connection pool monitoring and configure Prisma connection limits

- Start connection pool monitoring automatically in server.ts
- Add connection pool configuration logging to db.ts
- Update .env.example with detailed connection pool parameters
- Configure connection_limit=5 in Docker Compose for PgBouncer
- Add DATABASE_URL_DIRECT to production docker-compose
- Create comprehensive unit tests for connection pool monitoring

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* docs: add connection pooling quick start and implementation guides

- Add CONNECTION_POOLING_QUICKSTART.md with practical commands
- Add CONNECTION_POOLING_IMPLEMENTATION.md with implementation summary
- Include troubleshooting tips and monitoring commands
- Document performance tuning strategies

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review comments

- Fix username consistency in .env.example (use 'spywatcher' instead of 'postgres')
- Add clarifying comment for dynamic import pattern in server.ts
- Both changes improve code clarity and consistency

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-05 19:33:33 -06:00
Copilot
12806450db Query Performance Optimization - Add benchmarking, monitoring, and validation tools (#173)
* Initial plan

* Add comprehensive query performance monitoring and benchmarking tools

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Add pagination validation and comprehensive query performance guide

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Address code review feedback - fix validation, remove duplication, add security

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Add comprehensive summary documentation for query optimization implementation

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Address security review comments - improve SQL injection protection and validation

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-05 18:35:02 -06:00
Copilot
793928c561 Add real-time WebSocket updates and interactive drill-down to Analytics dashboard (#172)
* Initial plan

* feat: add real-time WebSocket updates and drill-down to Analytics dashboard

- Add WebSocket integration for real-time analytics updates
- Add drill-down functionality to charts (click on users/channels)
- Add DrillDownPanel component integration
- Add live connection status indicator
- Optimize metric calculations with useMemo
- Update chart components (HeatmapChart, VolumeChart, TimelineChart) with click handlers
- Fix Analytics tests with proper router and socket mocking

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* test: add comprehensive tests for drill-down and chart components

- Add DrillDownPanel component tests (6 test cases)
- Add HeatmapChart component tests (4 test cases)
- All tests passing (177 total)

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add comprehensive documentation for enhanced analytics dashboard

- Document all implemented features
- Include technical implementation details
- Add API integration documentation
- Document testing coverage
- Add performance characteristics
- Include deployment notes

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* refactor: address code review feedback for type safety and best practices

- Use useState for URL params instead of direct window.location access
- Improve variable scoping for WebSocket handlers
- Add proper type guards for chart click handlers
- Remove unsafe type assertions
- All tests still passing (177 total)

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: use React Router's useSearchParams for URL params handling

- Replace direct window.location.search access with useSearchParams hook
- Ensure guildId updates properly when URL changes via client-side routing
- Simplify WebSocket cleanup logic and remove unused variables
- All 177 tests passing

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-05 12:54:48 -06:00
Copilot
6588d5b647 Add search, date filtering, and export to user activity timeline (#171)
* Initial plan

* feat: add search, date filtering, and export to timeline feature

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* test: add comprehensive tests for timeline components

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback - improve type safety and validation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address PR review comments - stabilize debounce and improve readability

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-05 11:51:20 -06:00
Copilot
2aa4be44f7 [WIP] Create contributing guidelines for open source contributors (#170)
* Initial plan

* docs: add comprehensive contributing guidelines and templates

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: update README and SECURITY with better formatting and links

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: finalize contributing guidelines and formatting

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-04 15:38:59 -06:00
Copilot
ba81c0a8dc Add interactive API documentation portal with multi-language examples (#169)
* Initial plan

* Add OpenAPI documentation for privacy, plugins, and admin routes

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add comprehensive API documentation guides with code examples

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add API documentation index and update main README

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add comprehensive API documentation portal implementation summary

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Fix broken documentation links

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-03 20:57:24 -06:00
Copilot
8dc30b8abf [WIP] Create developer documentation for architecture and contributing (#168)
* Initial plan

* docs: add architecture, code style, testing, and local environment guides

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add database schema, prerequisites, PR process, and commit conventions

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add common issues and debugging guides

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add database setup, code of conduct, test requirements, and review process

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-03 15:10:57 -06:00
Copilot
65c4118fc2 Add comprehensive admin documentation for server management and operations (#159)
* Initial plan

* docs: Add admin panel, user management, ban management, and IP blocking guides

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* docs: Add permissions, audit logs, feature flags, and rate limiting configuration guides

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* docs: Add security, integrations, operations docs (backup, restore, monitoring, alerts, incident-response, maintenance)

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-03 13:58:37 -06:00
Copilot
cf84a692f6 [WIP] Create user documentation for end users (#153)
* Initial plan

* Add comprehensive user documentation with guides and tutorials

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add quick reference and screenshot documentation structure

- Add comprehensive quick reference guide with CLI commands, shortcuts, and API examples
- Add screenshot guide with capture guidelines and image specifications
- Add README for images directory with detailed instructions
- Update VitePress config to include new learning resources section
- Fix screenshot placeholder format to prevent build errors

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add comprehensive user documentation with guides and tutorials

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-03 13:12:23 -06:00
Copilot
891ca30a9d [WIP] Comprehensive Documentation - User, Admin, and Developer Guides (#152)
* Initial plan

* feat(docs): implement comprehensive VitePress documentation site

- Set up VitePress documentation platform with search and dark mode
- Created user guide with installation, quick start, and feature guides
- Added ghost detection comprehensive guide with examples
- Created admin guide with environment configuration
- Implemented developer guide with contributing guidelines
- Added API reference with code examples in multiple languages
- Configured navigation structure for all doc sections
- Added changelog and documentation README

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat(docs): add remaining guide pages and deployment workflow

- Created timeline analysis guide
- Added plugin system guide
- Implemented privacy controls guide
- Created advanced charts guide
- Added API authentication documentation
- Created GitHub Actions workflow for docs deployment
- Added logo SVG for documentation site
- Updated main README with documentation section

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-03 12:26:58 -06:00
Copilot
410d2d476d Add multi-language support (i18n) with 5 languages (#151)
* Initial plan

* Add i18n framework and initial setup with translations

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add Dashboard i18n, RTL support, and comprehensive tests

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Complete i18n implementation with documentation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Fix ThemeToggle tests for i18n integration

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Address code review feedback - improve i18n code quality

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Address PR review feedback - improve type safety and translations

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-03 10:26:23 -06:00
Copilot
9d94469497 Add advanced visualization components: network graphs, Sankey/chord diagrams, interactive filtering (#150)
* Initial plan

* Add advanced visualization components with network graph, sankey, chord diagrams and interactive filtering

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add comprehensive documentation for advanced visualization features

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Address code review feedback - improve type safety and remove extra blank lines

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Remove unused react-force-graph-2d dependency, optimize data merging with O(n+m) complexity, update doc versions

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-03 08:56:49 -06:00
Copilot
5215eeed84 Add extensibility framework with plugin system (#149)
* Initial plan

* Add plugin system core infrastructure with API, examples, and tests

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Integrate plugin system with bot and API server

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Add plugin system to README and configure linting

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Fix type safety in PluginLoader (code review feedback)

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Update backend/plugins/template/index.js

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: ⓪ηηωεε忧世 <onnweexd@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-02 22:59:23 -06:00
Copilot
1a98ee7419 Implement custom analytics rules engine with visual builder and execution system (#148)
* Initial plan

* Implement custom analytics rules engine - backend and frontend

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Fix TypeScript and lint errors in rules engine implementation

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Address code review feedback - improve type safety and navigation

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Changes before error encountered

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-02 21:18:08 -06:00
Copilot
606ba4bbdb Establish safe database migration procedures for production (#147)
* Initial plan

* feat: implement comprehensive database migration safety procedures

- Add test-migration.sh for isolated migration testing
- Add rollback-migration.sh for safe rollback procedures
- Add validate-migration.sh for data integrity validation
- Create MIGRATION_SAFETY.md with zero-downtime strategies
- Integrate migration testing into CI/CD pipeline
- Update scripts documentation

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* style: fix prettier formatting in migration docs

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review feedback

- Fix foreign key violation check to properly detect orphaned records
- Replace grep -oP with grep -oE for better portability
- Replace ls parsing with find command for reliable file listing
- Fix capitalization in documentation list items

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-02 19:55:18 -06:00
Copilot
dd0bec5046 Implement production-ready auto-scaling and load balancing infrastructure (#146)
* Initial plan

* feat: add comprehensive auto-scaling and load balancing configuration

- Add frontend HPA for auto-scaling (2-5 replicas)
- Enhance backend HPA with custom metrics support
- Improve load balancer configuration with health-based routing
- Add advanced traffic management policies
- Create AUTO_SCALING.md documentation
- Add validation script for auto-scaling setup
- Add load testing script for traffic spike simulation
- Update Helm production values with enhanced configs

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: add monitoring, alerting, and comprehensive documentation

- Add Prometheus alerting rules for auto-scaling events
- Add ServiceMonitor for metrics collection
- Create comprehensive AUTO_SCALING_EXAMPLES.md tutorial
- Update DEPLOYMENT.md with auto-scaling references
- Update scripts/README.md with new validation tools
- Add monitoring for HPA, deployments, and load balancers
- Include troubleshooting scenarios and examples

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add comprehensive implementation summary

- Create AUTO_SCALING_IMPLEMENTATION.md with complete overview
- Document all components, files, and specifications
- Include deployment instructions and validation results
- Add technical specifications and performance characteristics
- Document success criteria achievement

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback

- Merge duplicate alb.ingress.kubernetes.io/load-balancer-attributes annotation
- Fix nginx.ingress.kubernetes.io/limit-burst-multiplier to correct annotation name
- Remove unused checks_warned variable from validation script
- Fix YAML escape sequence in AUTO_SCALING_EXAMPLES.md

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-02 18:03:58 -06:00
Copilot
d3111dfbdf Add production deployment infrastructure with Kubernetes, Terraform, and multi-strategy CI/CD (#145)
* Initial plan

* Add Kubernetes manifests and Terraform infrastructure modules

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add Helm charts, deployment scripts, CI/CD workflows, and documentation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add infrastructure documentation and update README

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Fix code review issues and security vulnerabilities

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Address PR review comments: improve security, fix API versions, and enhance deployment reliability

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-02 17:27:49 -06:00
Copilot
ca1f33b734 feat: Implement automated backup and disaster recovery infrastructure (#144)
* Initial plan

* feat: Add backup and disaster recovery infrastructure

- Add BackupLog model to track backup operations
- Create backupMonitor.ts service for health checks and alerting
- Update scheduledTasks.ts with backup health monitoring
- Enhance backup.sh with encryption, S3, and notifications
- Enhance restore.sh with PITR and decryption support
- Add setup-wal-archiving.sh for WAL configuration
- Create comprehensive DISASTER_RECOVERY.md runbook
- Update .env.example with backup configuration

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* test: Add comprehensive tests for backup monitoring

- Add 14 unit tests for backupMonitor utility
- Test backup health checks and alerting
- Test backup logging and verification
- Test backup statistics collection
- All tests passing

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: Add comprehensive backup documentation

- Add backup section to README with quick commands
- Create BACKUP.md quick reference guide
- Add npm scripts for backup health checks and stats
- Document configuration and troubleshooting steps

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: Address code review feedback

- Wire up startBackupHealthChecks in server.ts startup
- Add error handling and verification to WAL archive commands
- Improve PITR documentation with manual setup instructions
- Add retry logic to S3 WAL archiving

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* refactor: Address code review nitpicks

- Backup removed WAL config lines for easier rollback
- Use numeric fallback for total size instead of 'unknown'
- Fix cleanup logic to remove correct temporary files
- Improve type casting for metadata fields
- Add deleted count to cleanup output

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: Address PR review comments

- Fix CLEANUP_DECRYPTED variable check in restore.sh cancellation path
- Suppress stderr on both stat and date command fallbacks for cleaner output
- Fix FILE_DAY extraction using substring instead of tail -c 3
- Use proper Prisma.JsonValue type casting instead of 'as any'
- Replace hardcoded GitHub Actions paths with $PROJECT_ROOT variable
- Add cleanup for old .removed config backup files (keep 5 most recent)

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-02 11:13:15 -06:00
Copilot
7eda87ea5e Implement dark/light theme system with smooth transitions and system preference support (#143)
* Initial plan

* Initial commit: Fix build errors before theme implementation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: Implement comprehensive dark/light theme system with smooth transitions

- Enhanced ThemeContext with system preference detection
- Added smooth CSS transitions for theme switching
- Updated ThemeToggle with three-state support (light/dark/system)
- Added keyboard shortcut (Ctrl+Shift+T) for theme toggle
- Implemented theme persistence across sessions
- Prevented flash on page load with inline script
- Added theme-aware Toaster component
- Created comprehensive tests for theme functionality
- Added CSS variables for light theme (Catppuccin Latte)
- All 98 tests passing

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: Add light theme colors and theme toggle to Login page

- Added comprehensive light theme color overrides in CSS
- Added theme toggle button to Login page for testing
- All theme transitions working smoothly
- Theme persistence verified across page reloads

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: Address code review feedback

- Use catppuccin color variables for tooltip instead of hardcoded colors
- Optimize CSS transitions by targeting specific elements instead of universal selector
- Improves performance on pages with many DOM elements

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: Clean up setTimeout and fix type error in theme initialization

- Add cleanup for setTimeout in ThemeToggle to prevent memory leaks
- Fix type error in effectiveTheme initialization with proper type assertion
- Addresses PR review feedback

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-02 07:04:15 -06:00
Copilot
76207d73f3 Implement WCAG 2.1 AA accessibility compliance (#142)
* Initial plan

* feat: implement core accessibility improvements - WCAG 2.1 AA

- Add screen reader utility classes (sr-only, sr-only-focusable)
- Add focus-visible enhancement for keyboard navigation
- Update Button component with ARIA attributes (aria-busy, aria-disabled, aria-label)
- Update Card components with flexible heading levels and id support
- Add skip-to-main-content link in App.tsx
- Update Dashboard page with semantic HTML (header, section, main landmark)
- Add proper table accessibility (scope, caption, aria-labelledby)
- Add ARIA labels to action buttons
- Update Login page with semantic HTML and ARIA attributes
- Update ThemeToggle with descriptive aria-label
- Update StatCard with aria-live regions and improved semantics
- All existing tests passing

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: add accessibility testing and enhanced chart accessibility

- Add vitest-axe for automated accessibility testing
- Create comprehensive accessibility tests for Button, Card, and StatCard components
- Add ARIA live regions and role="img" to chart components (VolumeChart, TimelineChart)
- Add accessible data tables as fallback for charts
- Update AnalyticsConsentBanner with semantic HTML and ARIA attributes
- Create comprehensive ACCESSIBILITY.md documentation
- All 81 tests passing including 16 new accessibility tests

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback for accessibility improvements

- Make data table fallbacks visible and accessible (not sr-only)
- Improve loading button text to be more descriptive
- Better structure for filter checkbox with aria-describedby
- Add aria-label to table headers with abbreviations
- All 81 tests still passing

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: apply PR review feedback from copilot-pull-request-reviewer

- Remove redundant aria-disabled attribute (native disabled is sufficient)
- Remove unnecessary span wrapper around button children
- Remove redundant aria-label from th elements with abbr
- Change chart role from img to region for interactive charts
- Remove role entirely from TimelineChart (has interactive elements)
- Update accessibility tests to check native disabled attribute
- All 81 tests passing

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-11-01 19:49:17 -05:00
Copilot
dae07553a8 Add OpenAPI/Swagger documentation with interactive Swagger UI and ReDoc (#141)
* Initial plan

* Add OpenAPI/Swagger documentation infrastructure

- Install swagger-ui-express and swagger-jsdoc packages
- Create OpenAPI configuration with schemas, security schemes, and components
- Add /api/docs endpoint for interactive Swagger UI
- Add /api/openapi.json endpoint for OpenAPI spec
- Document analytics routes (ghosts, heatmap, lurkers, roles, clients, shifts)
- Document ban management routes (banned, ban, unban, whitelist operations)
- Document key auth routes (discord callback, logout, me)

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add documentation for additional API routes

- Document status and health check endpoints
- Document suspicion analysis endpoints
- Document timeline endpoints
- Update OpenAPI config to include nested routes
- Total of 20 documented API endpoints

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add ReDoc support and comprehensive API documentation

- Install redoc-express for alternative documentation view
- Add /api/redoc endpoint for clean documentation interface
- Add more auth endpoints (refresh, sessions management)
- Create comprehensive API_DOCUMENTATION.md guide
- Total of 23 documented endpoints with full examples

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add screenshots and finalize API documentation

- Capture screenshots of Swagger UI, ReDoc, and OpenAPI spec
- Add screenshots to API_DOCUMENTATION.md
- Update main README.md with links to interactive documentation
- Fix redoc import statement
- Complete OpenAPI/Swagger implementation with 23 documented endpoints

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add OpenAPI implementation summary documentation

- Create comprehensive implementation summary
- Document all 23 endpoints with details
- Include usage examples and guidelines
- Add maintenance and future enhancement sections
- Complete OpenAPI/Swagger implementation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-01 14:49:15 -05:00
Copilot
d5233dad31 Add health checks, uptime tracking, and public status page (#140)
* Initial plan

* feat: Add health checks, uptime tracking, and incident management backend

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: Add incident management tests and fix linting issues

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: Add public status page frontend

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: Add comprehensive documentation and fix type errors

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* refactor: Extract validation constants and improve documentation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: Address PR review comments - fix latency calc, add Discord cache, clear errors

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-11-01 14:06:11 -05:00
Copilot
7da8cc91a6 Implement centralized log aggregation with Grafana Loki stack (#139)
* Initial plan

* feat: implement centralized log aggregation with Grafana Loki stack

- Add Loki for log aggregation and storage with 30-day retention
- Configure Promtail for log collection from all services
- Set up Grafana with pre-configured logging dashboard
- Add structured logging with JSON format and label extraction
- Support Docker container log collection via Docker socket
- Implement log filtering by service, level, and custom fields
- Add comprehensive documentation for logging system
- Update Docker Compose for dev and prod environments

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add validation script and quickstart guide for centralized logging

- Add comprehensive validation script to check logging setup
- Create quick start guide for users
- Validate all configuration files (YAML, JSON, Docker Compose)
- All 22 validation checks passing successfully

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add comprehensive implementation summary

- Document all components deployed
- Detail configuration highlights and design decisions
- Compare with alternative solutions (ELK, CloudWatch)
- Provide troubleshooting guide
- List future enhancement opportunities
- Confirm all success criteria met

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback

- Support both docker-compose and docker compose commands
- Fix log path duplication in Promtail (separate backend and security logs)
- Remove invalid Tempo datasource reference from Grafana config
- Add authentication note for production Loki deployments
- Update security documentation with Loki auth best practices

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update LOGGING.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update docs/LOGGING_IMPLEMENTATION_SUMMARY.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update promtail/README.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: ⓪ηηωεε忧世 <onnweexd@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-31 23:15:38 -05:00
Copilot
15912432b1 Implement GDPR-compliant analytics system with usage tracking and insights dashboard (#138)
* Initial plan

* feat: implement backend analytics system with GDPR compliance

- Add analytics database models (UserAnalyticsEvent, FeatureUsageMetric, PerformanceMetric, AnalyticsSummary)
- Create analytics service with event tracking, feature usage, and performance metrics
- Add analytics tracking middleware for automatic API request tracking
- Implement GDPR-compliant data anonymization when consent not given
- Add analytics API endpoints for viewing metrics and insights
- Create analytics tests with proper mocking
- Add analyticsConsent field to User model
- Integrate analytics middleware into server pipeline

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: complete analytics implementation with frontend integration

- Fix TypeScript type issues in analytics service
- Update frontend App.tsx to integrate analytics tracking and consent banner
- Add automatic page tracking via useAnalytics hook
- Add feature tracking to Analytics page
- Create comprehensive integration tests for metrics API
- Add DATABASE_URL to test environment
- Fix Redis connection cleanup null check
- Add MetricsDashboard route to frontend
- Integrate AnalyticsConsentBanner component globally

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: add comprehensive analytics documentation and migration

- Add ANALYTICS.md with complete system documentation
- Add PRIVACY_ANALYTICS.md with privacy policy for analytics
- Create database migration SQL for analytics tables
- Document all features, usage, API endpoints, and best practices
- Include GDPR compliance details and user rights
- Add troubleshooting guide and testing instructions

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback

- Fix division by zero in MetricsDashboard for consent rate and avg per user calculations
- Simplify JSON handling by removing inefficient JSON.parse(JSON.stringify())
- Use type assertion for Prisma JSON fields to avoid type conflicts
- All unit tests passing (8/8)

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address PR review feedback on analytics implementation

- Make hasConsent and consentStatus reactive with useState in useAnalytics hook
- Fix uniqueUsers calculation to count distinct userId instead of all records
- Remove trackFeatureUsage from dependency array in Analytics.tsx
- Use early return pattern in metricsAnalytics.ts POST /event endpoint
- Remove unused LineChart and Line imports from MetricsDashboard.tsx
- Update test mock to use _count.userId instead of _count._all

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-31 18:33:49 -05:00
Copilot
49ba58aebf Implement Sentry error tracking and alerting for frontend and backend (#137)
* Initial plan

* feat: implement comprehensive Sentry integration for frontend and backend

- Enhanced backend Sentry configuration with error grouping and context
- Added Sentry React SDK integration for frontend
- Created ErrorBoundary component for React error handling
- Configured source map support for both frontend and backend
- Added helper functions for error capture, user context, and breadcrumbs
- Created comprehensive documentation in SENTRY.md
- Added example alert rules configuration
- Updated environment variables for Sentry configuration
- Added source map upload scripts for backend

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* test: add comprehensive tests for Sentry integration

- Added backend unit tests for Sentry monitoring functions
- Added frontend tests for Sentry configuration exports
- Added ErrorBoundary component tests
- All tests passing successfully

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* refactor: address code review feedback for Sentry integration

- Made source map upload script portable with configurable strip-prefix
- Hide error messages in production for security
- Simplified Vite plugin conditional loading for better readability
- Removed rate limiting errors from ignore list to ensure monitoring
- Fixed TypeScript errors in test files

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* test: fix ErrorBoundary test reliability

- Simplified test assertions to avoid flaky behavior
- All frontend and backend tests now passing

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* refactor: address PR review feedback

- Use npx instead of global npm install for Sentry CLI
- Add JSDoc documentation for beforeSend hook explaining hint parameter
- Remove duplicate build:prod script (source maps now enabled by default)
- Remove unused userEvent import from ErrorBoundary test

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-31 14:41:24 -05:00
Copilot
b9b01207cf feat: Add APM, error tracking, and observability infrastructure (#136)
* Initial plan

* feat: add APM and error tracking with Sentry and Prometheus

- Install Sentry and Prometheus client dependencies
- Add Sentry integration with error tracking and APM
- Add Prometheus metrics for HTTP requests, WebSocket connections, and DB queries
- Add health check endpoints (/health/live and /health/ready)
- Update Winston logger with structured JSON logging and request ID correlation
- Add SENTRY_DSN to environment configuration
- Configure database monitoring helpers

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* test: add comprehensive tests for monitoring features

- Add health check endpoint tests (7 test cases)
- Add Prometheus metrics tests (9 test cases)
- All tests passing successfully

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: resolve linting issues in monitoring code

- Fix unused parameter warning in Sentry initialization
- Add proper eslint-disable directives in test file

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review feedback

- Fix Sentry request handler to be no-op (v10 uses integrations)
- Remove redundant fallback in Winston logger (env has default)
- Add clarifying comments for Sentry v10 behavior

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* docs: add security note for health check endpoints

Health checks are intentionally not rate-limited to ensure availability
for orchestrators and monitoring systems. This is standard practice.

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review feedback from PR review

- Remove redundant Sentry request/tracing handlers (no-ops in v10)
- Update misleading middleware ordering comment
- Fix Sentry check in dbMonitoring (captureException is safe to call)
- Add log level to Console and combined.log transports
- Add Discord API health check caching (30s TTL) to avoid rate limits

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-31 09:43:56 -05:00
Copilot
12c21876fc [WIP] Redesign frontend UI/UX with modern design principles (#135)
* Initial plan

* Changes before error encountered

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Complete UI/UX redesign with modern components and theme system

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Replace custom color tokens with Catppuccin theme classes for consistency

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-30 22:10:32 -05:00
Copilot
82bdf045e4 Implement per-user API quota system with subscription tiers (#134)
* Initial plan

* Add quota management system with tier-based rate limiting

- Add SubscriptionTier enum (FREE, PRO, ENTERPRISE) to schema
- Implement quota tracking in Redis with daily limits
- Add quota enforcement middleware
- Create quota management routes for admin
- Add comprehensive tests for quota functionality

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update documentation for quota and rate limiting features

- Add comprehensive quota management documentation to RATE_LIMITING.md
- Update README with tier-based quota features
- Create database migration for subscription tier
- Fix linting issues in new code

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Make quota limits endpoint async for consistency

- Address code review feedback
- Keep handler async even though operations are synchronous
- Maintains consistency with other route handlers

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add comprehensive quota usage guide

- Create detailed usage guide for quota management
- Include examples for developers
- Add admin instructions
- Document best practices and troubleshooting

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Fix race condition and add caching to quota system

- Replace separate check and increment with atomic checkAndIncrementQuota
- Add Redis caching for user tier/role lookups (5 min TTL)
- Add input validation for category parameter in reset endpoint
- Remove whitespace-only lines in test files
- Update tests to match new atomic quota operations

Addresses code review feedback on race conditions, database load, and input validation.

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-30 20:55:28 -05:00
Copilot
b5b5c53c2c Add public API with TypeScript SDK for third-party integrations (#133)
* Initial plan

* feat: add public API, SDK, and comprehensive documentation

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* test: add SDK tests and public API integration tests

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: improve type safety for query parameters

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* security: update axios to fix DoS vulnerability

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-30 17:50:54 -05:00
Copilot
4559286bfc Add real-time WebSocket analytics with Socket.io and Redis scaling (#132)
* Initial plan

* feat: add WebSocket infrastructure for real-time analytics

- Add Socket.io server with Redis adapter for horizontal scaling
- Implement WebSocket authentication middleware
- Add room-based broadcasting (guild and analytics rooms)
- Create analytics broadcaster with throttling (30s)
- Integrate WebSocket events with Discord bot
- Add frontend WebSocket client service
- Support real-time message, presence, role, and join events

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* test: add unit tests for WebSocket and analytics broadcaster

- Add comprehensive WebSocket service tests
- Add analytics broadcaster tests with throttling validation
- Install socket.io-client for testing
- Tests cover authentication, room subscriptions, and event emissions

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* docs: add WebSocket API documentation and example React component

- Add comprehensive WebSocket API documentation
- Create LiveAnalytics React component example
- Document all events, subscriptions, and best practices
- Include troubleshooting guide and security information

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review feedback

- Fix event listener cleanup by using consistent callback references
- Update TypeScript types to use type-only imports
- Fix return type in useEffect
- Replace toast.warning with toast (react-hot-toast doesn't have warning)
- Ensure proper cleanup in all code paths

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: resolve linting issues in WebSocket services

- Fix import ordering in websocket.ts
- Remove async/await from sync methods
- Use void operator for floating promises
- Update tests to match method signatures

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address PR review feedback

- Remove socketService.disconnect() in LiveAnalytics component cleanup to avoid disconnecting shared singleton
- Fix comment in analyticsBroadcaster to say "Top 20 users" instead of "Top 20 channels"
- Simplify reconnection error handling - only disconnect on auth errors, let Socket.io handle transient failures
- Replace deprecated User.tag with User.username throughout index.ts for Discord.js v14+ compatibility

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-30 16:52:15 -05:00
Copilot
53050266cb Add comprehensive event history view for user activity (#131)
* Initial plan

* Changes before error encountered

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* feat: implement comprehensive user activity timeline feature

- Add backend timeline API endpoint with cursor-based pagination
- Implement timeline service with pattern detection for anomalies
- Create UserTimeline frontend page with infinite scroll
- Add TimelineEvent and EventTypeFilter components
- Integrate timeline links in Suspicion pages
- Add unit tests for timeline service

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update backend/src/analytics/timeline.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* fix: correct hasMore pagination logic in timeline service

- Fetch limit + 1 items to accurately detect if more results exist
- Fix hasMore calculation to check actual merged results
- Add comprehensive test cases for pagination edge cases
- Addresses code review feedback on pagination logic

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: ⓪ηηωεε忧世 <onnweexd@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-30 15:37:31 -05:00
Copilot
29c657bb05 Add enhanced analytics dashboard with real-time visualizations (#130)
* Initial plan

* Add enhanced analytics dashboard with visualizations

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Address code review feedback - fix memory leak and improve UX

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Update frontend/src/components/analytics/ExportButton.tsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix DateRangeSelector initialization and fetchData dependency issues

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-30 12:38:19 -05:00
Copilot
9e5e10f263 Add multi-factor behavioral analysis for suspicion detection (#129)
* Initial plan

* feat: add advanced suspicion detection backend with multi-factor analysis

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* feat: add frontend suspicion detail UI with comprehensive dashboard

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: improve navigation consistency in suspicion detail view

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: resolve linting issues in advanced suspicion module

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address PR review feedback - add guildId param, guard division by zero, extract constants, remove unused state

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-30 10:31:21 -05:00
Copilot
9ef56ada2e Implement PgBouncer connection pooling with monitoring and graceful shutdown (#128)
* Initial plan

* feat: implement PgBouncer connection pooling and monitoring

- Add PgBouncer service with transaction mode pooling
- Configure optimal pool sizes (25 default, 100 max clients)
- Update docker-compose for dev and prod environments
- Enhance Prisma client with connection metrics
- Improve Redis connection lifecycle management
- Add comprehensive connection pool monitoring utilities
- Create monitoring endpoints for health checks and metrics
- Add graceful shutdown handlers for all services
- Update environment configuration with PgBouncer settings

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* feat: add comprehensive documentation and tests for connection pooling

- Create comprehensive CONNECTION_POOLING.md documentation
- Add PgBouncer setup guide in docs/
- Create unit tests for connection pool monitoring
- Add integration tests for monitoring endpoints
- Update .gitignore for pgbouncer credentials

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* docs: finalize connection pooling documentation and README updates

- Add comprehensive pgbouncer/README.md with usage guide
- Update main README with connection pooling section
- Add references to all relevant documentation
- Complete documentation checklist

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* fix: address code review feedback on connection pooling

- Fix PgBouncer Dockerfile permissions by running entrypoint as root with su-exec
- Add PGPASSWORD to health check for proper authentication
- Fix isHealthy check to not treat 0% utilization as unhealthy
- Use proper URL parsing for isPgBouncer detection instead of string matching
- Remove duplicate SIGTERM/SIGINT handlers in redis.ts, coordinate through db.ts
- Add su-exec package for secure user switching in container

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-29 23:42:18 -05:00
Copilot
1f23b39254 Optimize database queries: eliminate N+1 patterns, add pagination, enhance monitoring (#127)
* Initial plan

* Add pagination utilities and optimize channel diversity analytics

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Optimize presence, roles, and behavior shift analytics queries

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Add comprehensive query optimization documentation and benchmark script

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Address code review feedback - clean up benchmark script

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* Fix query issues: remove redundant HAVING clauses and rename parameter

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-29 23:01:55 -05:00
Copilot
70e27a0cae Implement Redis caching layer for analytics with tag-based invalidation (#126)
* Initial plan

* feat: implement Redis caching layer for analytics

- Add CacheService with tag-based invalidation
- Add PubSubService for real-time updates
- Add CacheInvalidationService for event-driven cache clearing
- Wrap all analytics functions with 2-15min TTL caches
- Add cache monitoring endpoints for stats and management
- Fix schema type issues (arrays vs strings for clients/roles)

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* test: add comprehensive cache service tests and documentation

- Add 26 unit tests for CacheService with 100% coverage
- Create comprehensive REDIS_CACHING.md documentation
- Document caching strategies, TTLs, and best practices
- Add monitoring, troubleshooting, and performance sections

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review feedback

- Add test for invalidateByTags method
- Fix test expectation for invalidateByTags
- Update documentation to reflect cache warming is implemented
- Maintain exec mock for type compatibility

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

* fix: address code review feedback from PR comments

- Add 'ready' event handler for Redis subscriber to ensure connection
- Use consistent pub/sub pattern in onPresenceUpdate (generic publish)
- Extract regex escaping to reusable escapeRegex utility method
- Add stricter validation for tag parameter to prevent Redis pattern injection
- Remove redundant type annotation in clients.ts forEach
- Fix import order in monitoring.ts

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-29 20:17:18 -05:00
Copilot
484c080277 Optimize database performance through indexing, query optimization, and monitoring (#125)
* Initial plan

* Add comprehensive database optimization: indexes, query optimization, and monitoring

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update backend/src/routes/monitoring.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix: Add missing async keyword to /database/health route handler

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: ⓪ηηωεε忧世 <onnweexd@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-29 11:30:44 -05:00
Copilot
4b663de9b4 PostgreSQL migration with production-grade features and tooling (#124)
* Initial plan

* Add PostgreSQL enhancements: schema updates, scripts, and documentation

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Fix schema validation and add full-text search setup script

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update MIGRATION.md with comprehensive PostgreSQL migration guide

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add comprehensive PostgreSQL migration summary document

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Address code review feedback: security, error handling, and script improvements

- Remove hardcoded database password fallback in migration script
- Add null/type checking to splitToArray function
- Replace beforeExit with SIGTERM/SIGINT handlers for graceful shutdown
- Add uncaught exception and unhandled rejection handlers
- Remove redundant datasources configuration in db.ts
- Fix pg_dump error handling in backup.sh
- Fix restore format handling for custom format dumps
- Improve table parsing in maintenance.sh using psql -t flag
- Update schema comment to reference setup-fulltext-search.sh script

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-28 23:15:43 -05:00
Copilot
ff3ad58aae Security Logging & Monitoring - Audit Trail and Alerts (#121)
* Initial plan

* Add security logging and monitoring infrastructure

- Add SecurityLog and AlertLog models to Prisma schema
- Create comprehensive security logger utility with event logging
- Implement alert system with Discord/Slack webhook support
- Add security logging middleware for HTTP responses
- Integrate security logging into authentication flows (login, logout, refresh)
- Add logging for authorization events (permissions, role changes)
- Implement alert conditions (failed logins, privilege escalation, etc.)
- Update environment configuration for webhook URLs

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Add comprehensive tests for security logging and alert system

- Add unit tests for security logger (11 tests, all passing)
- Add unit tests for alert system (13 tests, all passing)
- Add unit tests for IP management (11 tests, all passing)
- Test authentication, authorization, and security event logging
- Test alert triggers and webhook notifications
- Test IP blocking and whitelisting functionality

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Security hardening - fix clear-text logging and tainted format strings

- Sanitize metadata in security events to redact sensitive fields (passwords, tokens, scopes, etc.)
- Add IP address sanitization to prevent log injection attacks
- Remove sensitive data from error logs
- Fix CodeQL security alerts (clear-text logging, tainted format strings)
- All tests still passing (35 tests)
- Zero CodeQL security alerts remaining

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Address code review feedback - enhanced security validation

Code review improvements:
- Pass sanitized event to alert system (prevents sensitive data in alerts)
- Strict IP address validation (IPv4/IPv6 format checking)
- Remove raw IP from database reason field
- Improved IP sanitization with regex validation
- All tests still passing (35/35)
- Type checking clean

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>

* Update backend/src/middleware/securityLogging.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update backend/src/utils/securityLogger.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update backend/src/middleware/auth.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update backend/src/utils/alertSystem.ts

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Address PR review feedback - fix setTimeout reliability and response capture

- Replace setTimeout with database expiresAt field for IP auto-unblocking
- Add cleanupExpiredBlocks() function for periodic cleanup
- Update isIPBlocked() to automatically clean up expired blocks
- Replace res.send override with res.on('finish') to capture all response methods
- Add 4 new tests for expiration handling
- All 39 tests passing

Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
Co-authored-by: Patrick Fanella <61631520+PatrickFanella@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-28 22:29:01 -05:00
3506170152 Merge pull request #107 from subculture-collective/copilot/implement-rate-limiting-ddos-protection-again
Implement comprehensive rate limiting and DDoS protection
2025-10-27 15:56:18 -05:00
copilot-swe-agent[bot]
dcb9ca61d4 fix: resolve merge conflicts with main branch
- Merged origin/main using theirs strategy for conflicted files
- Fixed redis.test.ts structure (added missing describe block for scanKeys)
- Updated analytics.ts to remove unused caching imports
- Fixed function name from removeFromWhitelist to removeIPFromWhitelist in bans.ts
- All TypeScript type checks passing

Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-27 20:52:52 +00:00
copilot-swe-agent[bot]
64123b8301 Merge remote-tracking branch 'origin/main' into copilot/implement-rate-limiting-ddos-protection-again 2025-10-27 20:48:12 +00:00
e4e1eb9d93 Merge pull request #109 from subculture-collective/copilot/fix-log-injection-issue
[WIP] Fix log injection vulnerability in user input
2025-10-27 15:43:36 -05:00
copilot-swe-agent[bot]
edf0be08d7 Fix log injection in auth.ts route - sanitize discordId in warning log
Co-authored-by: PatrickFanella <61631520+PatrickFanella@users.noreply.github.com>
2025-10-27 04:54:21 +00:00
Patrick Fanella
139feeba50 Merge branch 'main' into copilot/fix-log-injection-issue 2025-10-26 23:47:45 -05:00
8073a06bf7 Merge pull request #111 from subculture-collective/copilot/replace-keys-with-scan
[WIP] Replace keys command with scan for improved performance
2025-10-26 23:16:13 -05:00
2d87c83ff3 Merge branch 'main' into copilot/replace-keys-with-scan 2025-10-26 23:16:01 -05:00
bdef95d6cd Merge pull request #113 from subculture-collective/copilot/fix-redis-performance-issue
Replace redis.keys() with redis.scan() to prevent blocking
2025-10-26 21:42:59 -05:00
copilot-swe-agent[bot]
0592d73ad1 Changes before error encountered
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-27 02:42:34 +00:00
copilot-swe-agent[bot]
4b8247e9cb Sanitize platform names in client arrays for defensive security
Co-authored-by: onnwee <211922112+onnwee@users.noreply.github.com>
2025-10-27 02:41:30 +00:00