# TODO List for Tercul Go Application --- ## High Priority ### [ ] Architecture Refactor (DDD-lite) - [~] **Resolvers call application services only; add dataloaders per aggregate (High, 3d)** - *Status: Partially complete.* Many resolvers still call repositories directly. Dataloaders are not implemented. - *Next Steps:* Refactor remaining resolvers to use application services. Implement dataloaders to solve N+1 problems. - [ ] **Adopt migrations tool (goose/atlas/migrate); move SQL to `internal/data/migrations` (High, 2d)** - *Status: Partially complete.* `goose` is added as a dependency, but no migration files have been created. - *Next Steps:* Create initial migration files from the existing schema. Move all schema changes to new migration files. - [ ] **Observability: centralize logging; add Prometheus metrics and OpenTelemetry tracing; request IDs (High, 3d)** - *Status: Partially complete.* OpenTelemetry and Prometheus libraries are added, but not integrated. The current logger is a simple custom implementation. - *Next Steps:* Integrate OpenTelemetry for tracing. Add Prometheus metrics to the application. Implement a structured, centralized logging solution. - [ ] **CI: add `make lint test test-integration` and integration tests with Docker compose (High, 2d)** - *Status: Partially complete.* CI runs tests and linting, and uses docker-compose to set up DB and Redis. No `Makefile` exists. - *Next Steps:* Create a `Makefile` with `lint`, `test`, and `test-integration` targets. ### [ ] Features - [x] **Implement analytics data collection (High, 3d)** - *Status: Mostly complete.* The analytics service is implemented with most of the required features. - *Next Steps:* Review and complete any missing analytics features. --- ## Medium Priority ### [ ] Performance Improvements - [ ] Implement batching for Weaviate operations (Medium, 2d) - [ ] Add performance benchmarks for critical paths (Medium, 2d) - [ ] Add benchmarks for text analysis (sequential vs concurrent) and cache hit/miss rates ### [ ] Code Quality & Architecture - [ ] Expand Weaviate client to support all models (Medium, 2d) - [ ] Add code documentation and API docs (Medium, 2d) - [ ] Replace bespoke cached repositories with decorators in `internal/data/cache` (reads only; deterministic invalidation) (Medium, 2d) - [ ] Config: replace ad-hoc config with env parsing + validation (e.g., koanf/envconfig); no globals (Medium, 1d) ### [ ] Testing - [ ] 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 --- ## Low Priority ### [ ] Testing - [ ] Refactor `RunTransactional` to be mock-friendly (Low, 1d) --- ## Completed - [x] Add comprehensive input validation for all GraphQL mutations (High, 2d) - *Partially complete. Core mutations are validated.* - [x] Create skeleton packages: `cmd/`, `internal/platform/`, `internal/domain/`, `internal/app/`, `internal/data/`, `internal/adapters/graphql/`, `internal/jobs/` - [x] Move infra to `internal/platform/*` (`config`, `db`, `cache`, `auth`, `http`, `log`, `search`) - [x] Wire DI in `cmd/api/main.go` and expose an `Application` facade to adapters - [x] Unify GraphQL under `internal/adapters/graphql` and update `gqlgen.yml`; move `schema.graphqls` and resolvers - [x] Introduce Unit-of-Work: `platform/db.WithTx(ctx, func(ctx) error)` and repo factory for `*sql.DB` / `*sql.Tx` - [x] Split write vs read paths for `work` (commands.go, queries.go); make read models cacheable - [x] Restructure `models/*` into domain aggregates with constructors and invariants - [x] Security: move JWT/middleware to `internal/platform/auth`; add authz policy helpers (e.g., `CanEditWork`) - [x] Search: move Weaviate client/schema to `internal/platform/search`, optional domain interface - [x] Background jobs: move to `cmd/worker` and `internal/jobs/*`; ensure idempotency and lease - [x] Python ops: move scripts to `/ops/migration` and `/ops/analysis`; keep outputs under `/ops/migration/outputs/` - [x] Cleanup: delete dead packages (`store`, duplicate `repositories`); consolidate to `internal/data/sql` - [x] Add integration tests for GraphQL API and background jobs (High, 3d) - *Partially complete. Core mutations are tested.* - [x] Stabilize non-linguistics tests and interfaces (High, 2d) - [x] Fix `graph` mocks to accept context in service interfaces - [x] Update `repositories` tests (missing `TestModel`) and align with new repository interfaces - [x] Update `services` tests to pass context and implement missing repo methods in mocks - [x] **Full Test Coverage (High, 5d):** - [x] Write unit tests for all models, repositories, and services. - [x] Refactor existing tests to use mocks instead of a real database. - [x] Refactor domains to be more testable and decoupled, with 100% unit test coverage and logging. - [x] `localization` domain - [x] `auth` domain - [x] `copyright` domain - [x] `monetization` domain - [x] `search` domain - [x] `work` domain --- > TODO items include context, priority, and estimated effort. Update this list after each milestone.