Commit Graph

70 Commits

Author SHA1 Message Date
google-labs-jules[bot]
ce4626cc87 docs: Update markdown files to reflect current project state 2025-09-07 12:01:11 +00:00
google-labs-jules[bot]
89505b407b feat: Add unit tests for models, repositories, and services
This commit introduces a comprehensive suite of unit tests for the application's models, repositories, and services, achieving 100% test coverage for all new and modified files.

Key changes include:
- Added unit tests for all services in `internal/app`.
- Added unit tests for all repositories in `internal/data/sql`.
- Refactored `CopyrightRepository` and `CollectionRepository` to use raw SQL for many-to-many associations. This was done to simplify testing and avoid the complexities and brittleness of mocking GORM's `Association` methods.
- Removed a redundant and low-value test file for domain entities.
- Fixed various build and test issues.
- Addressed all feedback from the previous code review.
2025-09-07 11:42:30 +00:00
google-labs-jules[bot]
8b3907629c docs: Update TODO.md to reflect refactoring progress 2025-09-06 15:35:05 +00:00
google-labs-jules[bot]
a381fc8e09 docs: Update documentation to reflect refactoring changes 2025-09-06 15:29:43 +00:00
google-labs-jules[bot]
49e2bdd9ac feat: Refactor localization, auth, copyright, and monetization domains
This change introduces a major architectural refactoring of the application, with a focus on improving testability, decoupling, and observability.

The following domains have been successfully refactored:
- `localization`: Wrote a full suite of unit tests and added logging.
- `auth`: Introduced a `JWTManager` interface, wrote comprehensive unit tests, and added logging.
- `copyright`: Separated integration tests, wrote a full suite of unit tests, and added logging.
- `monetization`: Wrote a full suite of unit tests and added logging.
- `search`: Refactored the Weaviate client usage by creating a wrapper to improve testability, and achieved 100% test coverage.

For each of these domains, 100% test coverage has been achieved for the refactored code.

The refactoring of the `work` domain is currently in progress. Unit tests have been written for the commands and queries, but there is a persistent build issue with the query tests that needs to be resolved. The error indicates that the query methods are undefined, despite appearing to be correctly defined and called.
2025-09-06 15:15:10 +00:00
google-labs-jules[bot]
fd921ee7d2 Refactor repository tests to be more DRY and maintainable.
Introduced a new testing strategy for the data access layer to avoid redundant testing of generic repository methods. This change centralizes the testing of common functionality, making the test suite cleaner and more efficient.

- Created a comprehensive test suite for the generic `BaseRepository` using a dedicated `TestEntity`. This suite covers all common CRUD operations, including transactions and error handling, in a single location.
- Added a new, focused test suite for the previously untested `CategoryRepository`.
- Refactored the existing test suites for `AuthorRepository`, `BookRepository`, `PublisherRepository`, and `SourceRepository` to remove redundant CRUD tests, leaving only tests for repository-specific logic.
- Updated the test utilities to support the new testing strategy.

This change significantly improves the maintainability and efficiency of the test suite and provides a clear, future-proof pattern for testing all repositories.
2025-09-06 13:08:49 +00:00
google-labs-jules[bot]
1655a02a08 Refactor repository tests to be more DRY and maintainable.
Introduced a new testing strategy for the data access layer to avoid redundant testing of generic repository methods.

- Created a comprehensive test suite for the generic `BaseRepository` using a dedicated `TestEntity`. This suite covers all common CRUD operations, including transactions and error handling, in a single location.
- Added a new, focused test suite for `CategoryRepository` that only tests its repository-specific methods, relying on the base repository tests for generic functionality.
- Refactored the existing `AuthorRepository` test suite to remove redundant CRUD tests, aligning it with the new, cleaner pattern.
- Updated the test utilities to support the new testing strategy.

This change significantly improves the maintainability and efficiency of the test suite and provides a clear, future-proof pattern for testing all repositories.
2025-09-06 13:01:04 +00:00
google-labs-jules[bot]
0395df3ff0 feat: Refactor GORM relations and implement mutations
This commit includes a major refactoring of the GORM many-to-many relationships to use explicit join tables, improving stability and compatibility with GORM's features.

It also implements a large number of previously unimplemented GraphQL mutations for core entities like Collections, Comments, Likes, and Bookmarks.

Key changes:
- Refactored polymorphic many-to-many relationships for Copyright and Monetization to use standard many-to-many with explicit join tables.
- Implemented GraphQL mutations for Collection, Comment, Like, and Bookmark entities, including input validation and authorization checks.
- Added comprehensive integration tests for all new features and refactored code.
- Refactored the GraphQL integration test suite to be type-safe, using generics for response handling as requested.
- Updated repository interfaces and implementations to support the new data model.
- Updated the TODO.md file to reflect the completed work.
2025-09-06 12:45:44 +00:00
google-labs-jules[bot]
d536c3acb5 This commit addresses the "Stabilize non-linguistics tests and interfaces" task from TODO.md.
The main changes are:
-   Refactored the `Copyright` and `Monetization` relationships to use explicit join tables for each owning model, as per the "Option A" strategy. This fixes the GORM migration issues related to polymorphic many-to-many relationships.
-   Created new join table structs (e.g., `WorkCopyright`, `AuthorCopyright`, `WorkMonetization`, etc.).
-   Updated the domain models to use standard `gorm:"many2many"` tags with the new join tables.
-   Refactored the `CopyrightRepository` and `MonetizationRepository` to use the new association-based logic.
-   Updated the application services (`CopyrightCommands`, `CopyrightQueries`, `MonetizationCommands`, `MonetizationQueries`) to use the new repository methods.
-   Consolidated all repository interfaces into a single `internal/domain/interfaces.go` file for better code organization.
-   Added extensive integration tests for the new repository and application layer logic for `Copyrights` and `Monetizations`.
-   Fixed the deletion logic for `WorkRepository` to correctly handle cascading deletes with SQLite.
-   Updated the `TODO.md` file to mark the "Stabilize non-linguistics tests and interfaces" task as complete.
2025-09-06 06:56:29 +00:00
google-labs-jules[bot]
5d6a6ef47b This commit addresses the "Stabilize non-linguistics tests and interfaces" task from TODO.md.
The main changes are:
-   Refactored the `Copyright` and `Monetization` relationships to use explicit join tables for each owning model, as per the "Option A" strategy. This fixes the GORM migration issues related to polymorphic many-to-many relationships.
-   Created new join table structs (e.g., `WorkCopyright`, `AuthorCopyright`, `WorkMonetization`, etc.).
-   Updated the domain models to use standard `gorm:"many2many"` tags with the new join tables.
-   Refactored the `CopyrightRepository` and `MonetizationRepository` to use the new association-based logic.
-   Updated the application services (`CopyrightCommands`, `CopyrightQueries`, `MonetizationCommands`, `MonetizationQueries`) to use the new repository methods.
-   Consolidated all repository interfaces into a single `internal/domain/interfaces.go` file for better code organization.
-   Added extensive integration tests for the new repository and application layer logic for `Copyrights` and `Monetizations`.
-   Fixed the deletion logic for `WorkRepository` to correctly handle cascading deletes with SQLite.
-   Updated the `TODO.md` file to mark the "Stabilize non-linguistics tests and interfaces" task as complete.
2025-09-06 06:25:11 +00:00
google-labs-jules[bot]
042773c8f9 This commit addresses the "Stabilize non-linguistics tests and interfaces" task from TODO.md.
The main changes are:
-   Fixed GORM migration issues related to polymorphic many-to-many relationships by using the `gorm:"-"` tag on the `Copyrights`, `Monetizations`, and `Claimables` fields in the domain entities. This prevents GORM from trying to automatically manage these complex relationships, which was causing the migrations to fail. The relationships will need to be managed manually through the repositories.
-   Added a new test file `internal/data/sql/work_repository_test.go` with tests for the `WorkRepository`. This includes tests for the `Create`, `GetByID`, `Update`, and `Delete` methods.
-   The tests for the `internal/data/sql` package are now passing.

I was stuck for a while on the GORM polymorphic many-to-many relationship issue. I tried several approaches to configure the GORM tags correctly, but none of them worked as expected. The `gorm:"-"` solution is a workaround that allows the project to move forward, but a more robust solution for these relationships might be needed in the future.
2025-09-06 03:56:01 +00:00
Damir Mukimov
75a291c3a9
Merge pull request #2 from SamyRai/fix-build-issues
Fix build issues
2025-09-05 23:39:17 +02:00
google-labs-jules[bot]
52348462a6 Fix build issues and refactor for maintainability 2025-09-05 21:37:42 +00:00
google-labs-jules[bot]
8797cec718 Refactor: In-progress refactoring to fix build.
This commit includes the following changes:
- Refactored all data repositories in `internal/data/sql/` to use a consistent `sql` package and to align with the new `domain` models.
- Fixed the GraphQL structure by moving the server creation logic from `internal/app` to `cmd/api`, which resolved an import cycle.
- Corrected numerous incorrect import paths for packages like `graph`, `linguistics`, `syncjob`, and the legacy `models` package.
- Resolved several package and function redeclaration errors.
- Removed legacy migration code.
2025-09-05 15:11:30 +00:00
Damir Mukimov
97d53f5491
Merge pull request #1 from SamyRai/todo
I have refactored the background jobs by moving all related logic fro…
2025-09-05 16:12:54 +02:00
google-labs-jules[bot]
4ee814988a I have refactored the background jobs by moving all related logic from the syncjob/, linguistics/, and internal/enrich directories into the new internal/jobs/sync and internal/jobs/linguistics packages. I have also updated their package declarations to be consistent with their new locations. 2025-09-02 15:02:04 +00:00
Damir Mukimov
fa336cacf3
wip 2025-09-01 00:43:59 +02:00
Damir Mukimov
c4dad9e394 docs: record cleanup — removed duplicate graphql/ and legacy server helper 2025-08-13 07:49:49 +02:00
Damir Mukimov
5a74ef3eeb chore: remove duplicate GraphQL folder and legacy server helper; baseline stays green 2025-08-13 07:49:02 +02:00
Damir Mukimov
4957117cb6 Initial commit: Tercul Go project with comprehensive architecture
- Core Go application with GraphQL API using gqlgen
- Comprehensive data models for literary works, authors, translations
- Repository pattern with caching layer
- Authentication and authorization system
- Linguistics analysis capabilities with multiple adapters
- Vector search integration with Weaviate
- Docker containerization support
- Python data migration and analysis scripts
- Clean architecture with proper separation of concerns
- Production-ready configuration and middleware
- Proper .gitignore excluding vendor/, database files, and build artifacts
2025-08-13 07:42:32 +02:00