Skip to content

Latest commit

 

History

History
308 lines (253 loc) · 12.5 KB

File metadata and controls

308 lines (253 loc) · 12.5 KB

Product Requirements Document (PRD)

SQLDBEntityNotifier v2.0 - Advanced Change Data Capture Library


📋 Document Information

  • Document Version: 2.0.0
  • Project Name: SQLDBEntityNotifier
  • Target Framework: .NET 6.0
  • Document Type: Product Requirements Document for TestSprite Testing
  • Created Date: December 2024
  • Last Updated: December 2024
  • Author: Jatin Dave
  • License: MIT

🎯 Executive Summary

SQLDBEntityNotifier is a production-ready .NET library that provides real-time database change detection across multiple database platforms (SQL Server, MySQL, PostgreSQL) with advanced Change Data Capture (CDC) capabilities. The library enables applications to receive instant notifications when database changes occur, supporting complex filtering, routing, analytics, and recovery scenarios.

Key Value Propositions

  • Multi-Database Support: Single API for SQL Server, MySQL, and PostgreSQL
  • Advanced CDC Features: Column-level filtering, schema change detection, change correlation
  • Enterprise-Grade: Analytics, routing, replay, and recovery capabilities
  • Zero Breaking Changes: Full backward compatibility with enhanced features
  • Production Ready: Comprehensive testing, error handling, and monitoring

🏗️ System Architecture

Core Components

┌─────────────────────────────────────────────────────────────┐
│                    Application Layer                        │
├─────────────────────────────────────────────────────────────┤
│              UnifiedDBNotificationService<T>               │
│                    + Column Filtering                      │
├─────────────────────────────────────────────────────────────┤
│                    CDCProviderFactory                       │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐        │
│  │SqlServerCDC │  │  MySqlCDC   │  │PostgreSqlCDC│        │
│  │  Provider   │  │  Provider   │  │  Provider   │        │
│  └─────────────┘  └─────────────┘  └─────────────┘        │
├─────────────────────────────────────────────────────────────┤
│                    ICDCProvider Interface                   │
├─────────────────────────────────────────────────────────────┤
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐        │
│  │   SQL       │  │   MySQL     │  │ PostgreSQL  │        │
│  │  Server     │  │   Binary    │  │     WAL     │        │
│  │    CDC      │  │    Log      │  │  Replication│        │
│  └─────────────┘  └─────────────┘  └─────────────┘        │
└─────────────────────────────────────────────────────────────┘

Advanced Feature Engines

  • ChangeAnalytics: Performance metrics and change pattern analysis
  • SchemaChangeDetection: Real-time schema change monitoring
  • ChangeCorrelationEngine: Multi-table change correlation
  • ChangeContextManager: Context propagation and management
  • AdvancedChangeFilters: Complex filtering and exclusion rules
  • ChangeRoutingEngine: Intelligent change routing and delivery
  • ChangeReplayEngine: Change replay and recovery capabilities

📊 Functional Requirements

FR-001: Multi-Database CDC Support

  • Priority: Critical
  • Description: Support Change Data Capture across SQL Server, MySQL, and PostgreSQL
  • Acceptance Criteria:
    • SQL Server: Native CDC with sys.sp_cdc_enable_table
    • MySQL: Binary log monitoring with replication privileges
    • PostgreSQL: Logical replication with WAL position tracking
    • Unified API interface for all database types
    • Automatic provider selection based on connection string

FR-002: Column-Level Change Filtering

  • Priority: High
  • Description: Monitor specific columns and exclude others from change notifications
  • Acceptance Criteria:
    • Monitor only specified columns
    • Exclude specific columns (e.g., audit fields, timestamps)
    • Dynamic column configuration without service restart
    • 75-85% reduction in unnecessary notifications
    • Support for complex column filter rules

FR-003: Real-Time Change Detection

  • Priority: Critical
  • Description: Detect and notify about database changes in real-time
  • Acceptance Criteria:
    • Support for Insert, Update, Delete operations
    • Schema change detection and notification
    • Batch operation support
    • Transaction ID tracking
    • Old/new value comparison

FR-004: Advanced Change Processing

  • Priority: High
  • Description: Advanced change analytics, correlation, and context management
  • Acceptance Criteria:
    • Performance metrics collection
    • Change pattern detection
    • Multi-table change correlation
    • Context propagation across async operations
    • Schema change impact analysis

FR-005: Advanced Routing & Filtering

  • Priority: Medium
  • Description: Intelligent change routing and complex filtering capabilities
  • Acceptance Criteria:
    • Multi-destination delivery
    • Routing rules based on change content
    • Advanced filter logic (AND/OR combinations)
    • Time-based and content-based filtering
    • Destination statistics and monitoring

FR-006: Change Replay & Recovery

  • Priority: Medium
  • Description: Replay changes and recover from failures
  • Acceptance Criteria:
    • Change replay with configurable options
    • Recovery mechanisms for failed operations
    • Audit trail maintenance
    • Replay session management
    • Performance optimization for replay operations

🔧 Non-Functional Requirements

NFR-001: Performance

  • Description: High-performance change detection with minimal latency
  • Acceptance Criteria:
    • Change detection latency < 100ms
    • Support for 1000+ changes per second
    • Memory usage < 500MB for typical workloads
    • CPU usage < 20% during peak operations

NFR-002: Scalability

  • Description: Support for large-scale database operations
  • Acceptance Criteria:
    • Support for 100+ concurrent table monitoring
    • Handle 10,000+ columns across all tables
    • Support for databases with 1TB+ data
    • Horizontal scaling capabilities

NFR-003: Reliability

  • Description: High availability and fault tolerance
  • Acceptance Criteria:
    • 99.9% uptime availability
    • Automatic reconnection on connection loss
    • Graceful degradation on partial failures
    • Comprehensive error handling and logging

NFR-004: Security

  • Description: Secure database connections and data handling
  • Acceptance Criteria:
    • Encrypted connection strings
    • Role-based access control support
    • Audit logging for all operations
    • Secure credential management

NFR-005: Maintainability

  • Description: Easy to maintain and extend
  • Acceptance Criteria:
    • Comprehensive unit test coverage (>90%)
    • Clear separation of concerns
    • Dependency injection support
    • Extensive documentation and examples

🧪 Testing Requirements

TR-001: Unit Testing

  • Coverage Target: >90% code coverage
  • Scope: All public methods and critical paths
  • Frameworks: xUnit, MSTest, Moq
  • Areas:
    • CDC provider implementations
    • Change detection logic
    • Filtering and routing engines
    • Analytics and correlation engines
    • Error handling and edge cases

TR-002: Integration Testing

  • Scope: Database connectivity and CDC operations
  • Environments: SQL Server, MySQL, PostgreSQL
  • Scenarios:
    • Real database change detection
    • Cross-database operations
    • Performance under load
    • Error recovery scenarios

TR-003: Performance Testing

  • Metrics: Throughput, latency, resource usage
  • Load Testing: High-volume change scenarios
  • Stress Testing: Resource exhaustion scenarios
  • Benchmarking: Comparison with baseline performance

TR-004: Security Testing

  • Areas: Authentication, authorization, data protection
  • Penetration Testing: Vulnerability assessment
  • Compliance: Security standard adherence

📁 Project Structure

Core Library (SQLDBEntityNotifier/)

SQLDBEntityNotifier/
├── Interfaces/           # Core interfaces and contracts
├── Models/              # Data models and DTOs
├── Providers/           # Database-specific CDC providers
├── Helpers/             # Utility classes and extensions
├── Compatibility/       # Backward compatibility layer
├── Examples/            # Usage examples and samples
└── UnifiedDBNotificationService.cs  # Main service class

Test Projects

SQLDBEntityNotifier.Tests/           # Main test suite
├── Models/                          # Model-specific tests
├── Providers/                       # Provider-specific tests
├── Compatibility/                   # Compatibility tests
└── Integration/                     # Integration tests

Supporting Projects

SQLEFTableNotification/              # Domain models
SQLEFTableNotificationLib/           # Library implementation
SQLEFTableNotification.Console/      # Console application
SQLEFTableNotificationTests/         # Additional test coverage

🎯 TestSprite Testing Objectives

Primary Testing Goals

  1. Comprehensive Coverage: Ensure all features are thoroughly tested
  2. Quality Assurance: Identify and fix bugs, performance issues
  3. Regression Prevention: Maintain existing functionality
  4. Documentation Validation: Verify examples and documentation accuracy

Testing Phases

  1. Phase 1: Core functionality testing (CDC, filtering, notifications)
  2. Phase 2: Advanced features testing (analytics, correlation, routing)
  3. Phase 3: Performance and stress testing
  4. Phase 4: Integration and end-to-end testing
  5. Phase 5: Security and compliance testing

Success Criteria

  • All 379 existing tests pass
  • New test coverage for advanced features
  • Performance benchmarks met
  • Security vulnerabilities identified and resolved
  • Documentation accuracy verified

🚀 Implementation Roadmap

Current Status (v2.0.0)

  • ✅ Core CDC infrastructure implemented
  • ✅ Advanced change processing engines
  • ✅ Advanced routing and filtering
  • ✅ Change replay and recovery
  • ✅ Comprehensive test suite (379 tests)
  • ✅ Advanced features documentation

Future Enhancements (v2.1+)

  • 🔄 Machine learning-based change pattern detection
  • 🔄 Cloud-native deployment support
  • 🔄 Advanced monitoring and alerting
  • 🔄 Multi-tenant support
  • 🔄 GraphQL API support

📞 Contact Information


📝 Document Approval

  • Product Owner: Jatin Dave
  • Technical Lead: Jatin Dave
  • QA Lead: TestSprite (AI-Powered Testing)
  • Stakeholders: Open Source Community, .NET Developers

This PRD serves as the foundation for comprehensive testing with TestSprite, ensuring all features are thoroughly validated and the library maintains its high quality standards.