Skip to content

feat: Implement entity database modeling with PostgreSQL entities and repositories#6

Merged
qowlgur121 merged 6 commits into
developfrom
feature/4-implement-entity-database-modeling
Aug 10, 2025
Merged

feat: Implement entity database modeling with PostgreSQL entities and repositories#6
qowlgur121 merged 6 commits into
developfrom
feature/4-implement-entity-database-modeling

Conversation

@qowlgur121

Copy link
Copy Markdown
Member

Summary

  • Implement complete entity database modeling for OpenContext ingestion pipeline
  • Create PostgreSQL entities with full relationship mapping and business logic
  • Establish comprehensive repository layer with advanced query methods
  • Provide complete test coverage with TestContainers integration
  • Resolve security vulnerabilities and ensure production-ready build environment

Key Implementation Notes

  • Pattern: Applied Service-Repository pattern with JPA entity modeling for clean data access layer
  • Testing: Added comprehensive test suite with 28 TestContainers-based integration tests
  • API Docs: Database schema implemented with Flyway migration scripts
  • Performance: Optimized queries with proper indexing and relationship mapping

Major Components

Entity Layer

  • SourceDocument: Complete document metadata with ingestion status tracking
  • DocumentChunk: Hierarchical structure with parent-child relationships

Repository Layer

  • SourceDocumentRepository: Advanced queries for status filtering and duplicate prevention
  • DocumentChunkRepository: Hierarchical navigation with PostgreSQL recursive CTE

Database Schema

  • Flyway Migration: Complete PostgreSQL schema with constraints and indexes
  • Foreign Keys: Proper CASCADE behavior for data integrity

Security Fixes

Package Structure Changes

Refactored to align with team standards from PR #5:

  • com.opencontext.entity.* - Entity classes
  • com.opencontext.repository.* - Repository interfaces
  • Removed duplicate IngestionStatus enum

Test Coverage

All 28 tests pass with BUILD SUCCESSFUL:

  • Entity unit tests with builder pattern validation
  • Repository integration tests with TestContainers
  • Real PostgreSQL testing environment

Related Issues

Closes #4

- Replace QueryDSL with OpenFeign fork to fix SQL injection vulnerability
- Update DJL and Commons Lang3 to latest secure versions
- Modernize QueryDSL configuration for Spring Boot 3.3 compatibility
- Fix deprecated buildDir and annotation processor warnings
- Update gradlew script with latest Gradle wrapper improvements
- Add missing gradle-wrapper.jar for self-contained builds
- Include gradlew.bat for Windows development support
- Ensures all team members can build without local Gradle installation
- Set platform: linux/amd64 for all Docker services
- Resolves compatibility issues on Apple Silicon (M1/M2) machines
- Ensures consistent behavior across different hardware architectures
…repositories

- Add IngestionStatus enum with complete document processing lifecycle states
- Implement SourceDocument entity with file metadata and ingestion tracking
- Implement DocumentChunk entity with hierarchical parent-child relationships
- Create SourceDocumentRepository with advanced query methods for status filtering
- Create DocumentChunkRepository with hierarchy navigation and cascade operations
- Add comprehensive Flyway migration V1 for PostgreSQL table creation with indexes
- Implement complete test suite with TestContainers integration testing
- Include entity unit tests with Builder pattern validation
- Add repository integration tests with real PostgreSQL container testing
- Cover CASCADE delete operations, hierarchy queries, and performance optimizations

Resolves #4
- Remove redundant 'core' package nesting (com.opencontext.core.* → com.opencontext.*)
- Eliminate duplicate IngestionStatus enum, use team member's implementation
- Maintain full entity relationship functionality and test coverage
- Update all imports to reflect new package structure

This resolves package structure inconsistencies and enables seamless
integration with common modules established in PR #5.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements a comprehensive entity database modeling system for the OpenContext ingestion pipeline, establishing the foundational data layer with PostgreSQL entities and repositories. The implementation follows the Service-Repository pattern with JPA entity modeling and includes extensive test coverage using TestContainers.

  • Complete PostgreSQL entity layer with SourceDocument and DocumentChunk entities featuring hierarchical relationships
  • Comprehensive repository interfaces with advanced query methods for document management and chunk navigation
  • Full database schema with Flyway migrations, proper indexing, and CASCADE relationships

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docker-compose.yml Adds platform specification for consistent cross-platform container deployment
core/build.gradle Updates dependencies for security patches and removes deprecated QueryDSL plugin
V1__Create_source_documents_and_document_chunks_tables.sql Implements complete PostgreSQL schema with tables, indexes, and constraints
SourceDocument.java Core entity for document metadata with ingestion status tracking and business logic
DocumentChunk.java Hierarchical chunk entity with parent-child relationships and tree navigation
SourceDocumentRepository.java Repository with advanced queries for status filtering and duplicate prevention
DocumentChunkRepository.java Repository with hierarchical navigation using PostgreSQL recursive CTEs
SourceDocumentTest.java Unit tests for entity builder pattern and business logic validation
DocumentChunkTest.java Unit tests for hierarchical relationships and tree structure methods
SourceDocumentRepositoryTest.java Integration tests with TestContainers for repository operations
DocumentChunkRepositoryTest.java Integration tests for hierarchical queries and cascade behavior
core/gradlew Updated Gradle wrapper script with POSIX improvements
core/gradlew.bat Updated Gradle wrapper batch script with merge conflict markers

Comment thread core/gradlew.bat Outdated
Comment thread core/gradlew.bat Outdated
@rem SPDX-License-Identifier: Apache-2.0
@rem
=======
>>>>>>> 2b49148 (build: regenerate gradle wrapper for consistent build environment)

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the file. These should be resolved before merging.

Suggested change
>>>>>>> 2b49148 (build: regenerate gradle wrapper for consistent build environment)
@rem SPDX-License-Identifier: Apache-2.0
@rem

Copilot uses AI. Check for mistakes.
Comment thread core/gradlew.bat Outdated
@rem SPDX-License-Identifier: Apache-2.0
@rem
=======
>>>>>>> 2b49148 (build: regenerate gradle wrapper for consistent build environment)

Copilot AI Aug 10, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git merge conflict markers are present in the file. These should be resolved before merging.

Suggested change
>>>>>>> 2b49148 (build: regenerate gradle wrapper for consistent build environment)
@rem SPDX-License-Identifier: Apache-2.0
@rem

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@qowlgur121
qowlgur121 requested a review from Copilot August 10, 2025 03:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants