mirror of
https://github.com/SamyRai/tercul-backend.git
synced 2025-12-26 22:21:33 +00:00
* docs: Update TASKS.md and PRODUCTION-TASKS.md to reflect current codebase state (December 2024 audit) * refactor: Unify all commands into a single Cobra CLI - Refactor cmd/api/main.go into 'tercul serve' command - Refactor cmd/worker/main.go into 'tercul worker' command - Refactor cmd/tools/enrich/main.go into 'tercul enrich' command - Add 'tercul bleve-migrate' command for Bleve index migration - Extract common initialization logic into cmd/cli/internal/bootstrap - Update Dockerfile to build unified CLI - Update README with new CLI usage This consolidates all entry points into a single, maintainable CLI structure. * fix: Fix CodeQL workflow and add comprehensive test coverage - Fix Go version mismatch by setting up Go before CodeQL init - Add Go version verification step - Improve error handling for code scanning upload - Add comprehensive test suite for CLI commands: - Bleve migration tests with in-memory indexes - Edge case tests (empty data, large batches, errors) - Command-level integration tests - Bootstrap initialization tests - Optimize tests to use in-memory Bleve indexes for speed - Add test tags for skipping slow tests in short mode - Update workflow documentation Test coverage: 18.1% with 806 lines of test code All tests passing in short mode * fix: Fix test workflow and Bleve test double-close panic - Add POSTGRES_USER to PostgreSQL service configuration in test workflow - Fix TestInitBleveIndex double-close panic by removing defer before explicit close - Test now passes successfully Fixes failing Unit Tests workflow in PR #64
8.4 KiB
8.4 KiB
Consolidated Tasks for Tercul (Production Readiness)
This document is the single source of truth for all outstanding development tasks, aligned with the architectural vision in refactor.md. Last updated: December 2024
!! CRITICAL !!
Stabilize Core Logic (Prevent Panics)
- Fix Background Job Panic: The background job queue in
internal/jobs/sync/queue.gocan panic on error. This must be refactored to handle errors gracefully. (Status: Complete - Investigation revealed no panicking code. All background jobs handle errors gracefully.)
High Priority
EPIC: Achieve Production-Ready API
- Implement All Unimplemented Resolvers: The GraphQL API is complete. All resolvers are implemented and functional.
- Mutations:
DeleteUser,CreateContribution,UpdateContribution,DeleteContribution,ReviewContribution,Logout,RefreshToken,ForgotPassword,ResetPassword,VerifyEmail,ResendVerificationEmail,UpdateProfile,ChangePassword- ✅ All implemented - Queries:
Translations,Author,User,UserByEmail,UserByUsername,Me,UserProfile,Collection,Collections,Comment,Comments,Search- ✅ All implemented
- Mutations:
- Refactor API Server Setup: The API server startup has been refactored into
cmd/api/server.gowith clean separation of concerns.- GraphQL Playground and Prometheus metrics endpoints consolidated into main API server at
/playgroundand/metrics.
- GraphQL Playground and Prometheus metrics endpoints consolidated into main API server at
EPIC: Comprehensive Documentation
- Create Full API Documentation: Basic API documentation exists in
api/README.mdwith all queries, mutations, and types documented.- Enhance
api/README.mdwith more detailed examples, error responses, and usage patterns. - Add GraphQL schema descriptions to improve auto-generated documentation.
- Enhance
- Improve Project
README.md: The rootREADME.mdhas been updated with project overview, getting started guide, and architectural principles.- Add more detailed development workflow documentation.
- Add troubleshooting section for common issues.
- Ensure Key Packages Have READMEs:
internal/jobs/sync/README.mdexists as a good example.- Add READMEs for other critical packages (
internal/app/*,internal/platform/*).
- Add READMEs for other critical packages (
EPIC: Foundational Infrastructure
- Establish CI/CD Pipeline: Basic CI infrastructure exists.
- CI:
Makefiletargetlint-testexists and runsgolangci-lintandgo test ./...successfully. - CD: Set up automated deployments to a staging environment upon a successful merge to the main branch.
- GitHub Actions: Create
.github/workflows/ci.ymlfor automated testing and linting.
- CI:
- Implement Basic Observability: Observability infrastructure is in place but needs production hardening.
- Centralized Logging: Structured
zerologlogger exists ininternal/observability/logger.go. Request IDs and span IDs are added to logging context via middleware. - Logging Enhancements: Add user ID to authenticated request logs. Implement log sampling for high-volume endpoints.
- Metrics: Basic Prometheus metrics exist for HTTP requests and database queries (
internal/observability/metrics.go). - Metrics Enhancements: Add GraphQL resolver metrics, business metrics (works created, searches performed), and cache hit/miss metrics.
- Tracing: OpenTelemetry tracing is implemented with basic instrumentation.
- Tracing Enhancements: Replace stdout exporter with OTLP exporter for production. Add database query tracing via GORM callbacks. Instrument all GraphQL resolvers with spans.
- Centralized Logging: Structured
EPIC: Core Architectural Refactoring
- Refactor Dependency Injection: The composition root has been moved to
cmd/api/main.gowith proper dependency injection.NewApplicationaccepts repository interfaces (e.g.,domain.WorkRepository) instead of concrete implementations.- Platform components (e.g.,
JWTManager) are instantiated incmd/api/main.goand passed as dependencies.
- Implement Basic Read Models (DTOs): DTOs are partially implemented.
WorkDTOexists ininternal/app/work/dto.go(minimal implementation).- Enhance DTOs: Expand DTOs to include all fields needed for list vs detail views. Create
WorkListDTOandWorkDetailDTOwith optimized fields. - Extend to Other Aggregates: Create DTOs for
Translation,Author,User, etc. - Optimize Queries: Refactor queries to use optimized SQL with proper joins to avoid N+1 problems.
- Improve Configuration Handling: The application still uses global singletons for configuration (
config.Cfg).- Refactor to use struct-based configuration injected via constructors, as outlined in
refactor.md. - Database migration path is configurable via
MIGRATION_PATHenvironment variable. - Make metrics server port configurable (currently hardcoded in server setup).
- Add configuration validation on startup.
- Refactor to use struct-based configuration injected via constructors, as outlined in
EPIC: Robust Testing Framework
- Refactor Testing Utilities: Tests currently use live database connections.
- Refactor
internal/testutil/testutil.goto use testcontainers for isolated test environments. - Add parallel test execution support.
- Create reusable test fixtures and builders.
- Refactor
- Implement Mock Repositories: Mock repositories are fully implemented and functional.
- All mock repositories in
internal/adapters/graphql/*_mock_test.goandinternal/testutil/mock_*.goare complete. - No panicking mocks found - all methods are properly implemented.
- All mock repositories in
Medium Priority
EPIC: Complete Core Features
- Search Implementation: Full-text search is fully implemented with Weaviate.
- Search service exists in
internal/app/search/service.go. - Weaviate client wrapper in
internal/platform/search/weaviate_wrapper.go. - Supports multi-class search (Works, Translations, Authors).
- Supports filtering by language, tags, dates, authors.
- Enhancements: Add incremental indexing on create/update operations. Add search result caching.
- Search service exists in
- Implement Analytics Features: Basic analytics exist but needs completion.
- Analytics service exists in
internal/app/analytics/. - Complete Metrics: Implement like, comment, and bookmark counting (currently TODOs in
internal/jobs/linguistics/work_analysis_service.go). - Implement service to calculate popular translations based on engagement metrics.
- Analytics service exists in
- Refactor
enrichTool: Thecmd/tools/enrich/main.gotool may need architectural alignment.- Review and refactor to use application services instead of accessing data repositories directly (if applicable).
EPIC: Further Architectural Improvements
- Implement Repository Caching: Caching exists for linguistics but not for repositories.
- Implement decorator pattern for repository caching in
internal/data/cache. - Create
CachedWorkRepository,CachedAuthorRepository,CachedTranslationRepositorydecorators. - Implement cache-aside pattern with automatic invalidation on writes.
- Add cache metrics (hit/miss rates).
- Implement decorator pattern for repository caching in
- Consolidate Duplicated Structs: Review and consolidate any duplicated analytics structs.
- Check for
WorkAnalyticsandTranslationAnalyticsduplication across packages.
- Check for
Low Priority
EPIC: Code Quality & Documentation
- Add GoDoc Comments: Document all public functions and types.
- Expand Weaviate Client: Extend the client to support indexing all relevant domain models.
- Refactor Transactional Runner: Refactor the
RunTransactionalhelper to be more mock-friendly.
Completed
internal/app/work/commands.go: TheMergeWorkcommand is fully implemented.internal/app/search/service.go: The search service correctly fetches content from the localization service and is fully functional.- GraphQL API: All resolvers implemented and functional.
- Background Jobs: Sync jobs and linguistic analysis jobs are fully implemented with proper error handling.
- Server Setup: Refactored into
cmd/api/server.gowith clean middleware chain. - Basic Observability: Logging, metrics, and tracing infrastructure in place.
- Dependency Injection: Proper DI implemented in
cmd/api/main.go. - API Documentation: Basic documentation exists in
api/README.md.