mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-27 05:11:34 +00:00
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.
3.6 KiB
3.6 KiB
TODO List for Tercul Go Application
[ ] Performance Improvements
- Implement batching for Weaviate operations (Medium, 2d)
[ ] Security Enhancements
- Add comprehensive input validation for all GraphQL mutations (High, 2d)
[ ] Code Quality & Architecture
- Expand Weaviate client to support all models (Medium, 2d)
- Add code documentation and API docs (Medium, 2d)
[ ] Architecture Refactor (DDD-lite)
- Create skeleton packages:
cmd/,internal/platform/,internal/domain/,internal/app/,internal/data/,internal/adapters/graphql/,internal/jobs/ - Move infra to
internal/platform/*(config,db,cache,auth,http,log,search) - Wire DI in
cmd/api/main.goand expose anApplicationfacade to adapters - Unify GraphQL under
internal/adapters/graphqland updategqlgen.yml; moveschema.graphqlsand resolvers - Resolvers call application services only; add dataloaders per aggregate
- Introduce Unit-of-Work:
platform/db.WithTx(ctx, func(ctx) error)and repo factory for*sql.DB/*sql.Tx - Split write vs read paths for
work(commands.go, queries.go); make read models cacheable - Replace bespoke cached repositories with decorators in
internal/data/cache(reads only; deterministic invalidation) - Restructure
models/*into domain aggregates with constructors and invariants - Adopt migrations tool (goose/atlas/migrate); move SQL to
internal/data/migrations; deletemigrations.go - Observability: centralize logging; add Prometheus metrics and OpenTelemetry tracing; request IDs
- Config: replace ad-hoc config with env parsing + validation (e.g., koanf/envconfig); no globals
- Security: move JWT/middleware to
internal/platform/auth; add authz policy helpers (e.g.,CanEditWork) - Search: move Weaviate client/schema to
internal/platform/search, optional domain interface - Background jobs: move to
cmd/workerandinternal/jobs/*; ensure idempotency and lease - Python ops: move scripts to
/ops/migrationand/ops/analysis; keep outputs under/ops/migration/outputs/ - Cleanup: delete dead packages (
store, duplicaterepositories); consolidate tointernal/data/sql - CI: add
make lint test test-integrationand integration tests with Docker compose
[ ] Testing
- Add unit tests for all models, repositories, and services (High, 3d)
- Add integration tests for GraphQL API and background jobs (High, 3d)
- Add performance benchmarks for critical paths (Medium, 2d)
- Add benchmarks for text analysis (sequential vs concurrent) and cache hit/miss rates
[ ] Monitoring & Logging
- Add monitoring for background jobs and API endpoints (Medium, 2d)
- Add metrics for linguistics: analysis duration, cache hit/miss, provider usage
[ ] Next Objective Proposal
- Stabilize non-linguistics tests and interfaces (High, 2d)
- Fix
graphmocks to accept context in service interfaces - Update
repositoriestests (missingTestModel) and align with new repository interfaces - Update
servicestests to pass context and implement missing repo methods in mocks
- Fix
- Add performance benchmarks and metrics for linguistics (Medium, 2d)
- Benchmarks for AnalyzeText (provider on/off, concurrency levels)
- Export metrics and dashboards for analysis duration and cache effectiveness
- Documentation (Medium, 1d)
- Document NLP provider toggles and defaults in README/config docs
- Describe SRP/DRY design and extension points for new providers
TODO items include context, priority, and estimated effort. Update this list after each milestone.