Commit Graph

112 Commits

Author SHA1 Message Date
William Valentin
beb9d84071 Fix build process and add production build support
🔧 Build Process Improvements:
- Update default 'build' target to use development mode
- Add new 'build-prod' target for production builds with validation
- Fix 'deploy-prod-quick' to use production build command
- Update 'build-test' to use development build (safer for CI)

📚 Documentation:
- Add comprehensive Production Build Guide (docs/deployment/PRODUCTION_BUILD.md)
- Include security requirements, configuration methods, and troubleshooting
- Update main documentation index with production build guide
- Update README with both build command options

 Features:
- Development builds work without security configuration
- Production builds require proper JWT/SESSION secrets
- Clear separation between dev and prod build processes
- Comprehensive production deployment documentation

🔒 Security:
- Enforced JWT_SECRET validation for production builds
- Clear documentation of required security configurations
- Examples for CI/CD integration with proper secret management
- Best practices for production deployment

🧪 Verification:
-  Development build: make build (works with warnings)
-  Production build validation: make build-prod (fails without secrets)
-  Production build with secrets: works correctly
-  All existing functionality preserved
2025-09-08 19:23:42 -07:00
William Valentin
430bc6acf8 Remove deprecated entries from Makefile and update documentation
🗑️ Removed:
- Legacy Support section with deprecated targets (k8s-deploy, k8s-undeploy, deploy, undeploy)
- 18 lines of deprecated makefile targets and warnings

📚 Documentation Updates:
- README.md: Updated Kubernetes deployment commands and project structure
- KUSTOMIZE_MIGRATION.md: Replaced deprecated commands with current ones
- k8s-kustomize/README.md: Updated deployment command references
- APP_NAME_CONFIGURATION.md: Updated deployment example command
- config/README.md: Replaced migration script references with config generation
- ARCHITECTURE_MIGRATION.md: Updated to reflect completed migration status
- PROJECT_STRUCTURE.md: Updated services structure to show unified database service
- IMPLEMENTATION_SUMMARY.md: Updated legacy compatibility notes

 Improvements:
- Clean Makefile with only current, supported targets
- Consistent documentation referring to current command structure
- Removed all references to deleted CouchDB service files
- Updated project structure diagrams to reflect current architecture

🧪 Verification:
- All 292 unit tests passing
- Integration tests passing
- Makefile help command displays cleanly
- No deprecated command references remain in documentation
2025-09-08 19:07:26 -07:00
William Valentin
598c1da17b Complete database service consolidation and documentation
 Features:
- Add comprehensive database service documentation
- Create detailed module README with usage examples
- Expand main documentation index with database links
- Add component test support to Jest configuration

🔧 Improvements:
- Fix AvatarDropdown test failures (dark mode classes and rapid clicking)
- Update documentation version to 2.1
- Include migration guide and troubleshooting sections
- Add performance considerations and security notes

📚 Documentation:
- Complete API reference with code examples
- Architecture overview with Strategy pattern explanation
- Environment configuration and strategy selection guide
- Best practices and development guidelines
- Comprehensive refactoring summary

🧪 Testing:
- All 292 tests passing across all modules
- Component tests now properly integrated with Jest
- Fixed TypeScript compatibility issues in tests
- Verified database service functionality in all environments

📋 Summary:
- Removed deprecated CouchDB service files
- Consolidated database operations under unified service
- Enhanced documentation structure and content
- Improved test coverage and reliability
- Maintained backward compatibility where possible
2025-09-08 18:59:08 -07:00
William Valentin
ac3643f76d Refactor database services and add component tests
- Remove deprecated CouchDB service files
- Update database test configurations
- Add test files for components and auth modules
- Update user context and admin interface
- Remove migration script for unified config
- Fix User interface properties in tests (use status instead of isActive)
2025-09-08 18:30:43 -07:00
William Valentin
31e08d730d docs: add comprehensive test suite improvement documentation
- Add FINAL_IMPROVEMENT_SUMMARY.md with complete project overview
- Add IMPROVEMENT_SUMMARY.md with detailed technical changes
- Add TEST_SUITE_IMPROVEMENT_REPORT.md with implementation details
- Document 100% test success rate achievement (242 tests passing)
- Detail architectural improvements and coverage gains
- Provide future roadmap and best practices

This documents the complete transformation of the test suite from failing state to 100% success.
2025-09-08 11:45:08 -07:00
William Valentin
7029ec0b0d fix: resolve email verification service test failures
- Fix missing imports and dependencies in email verification tests
- Update email verification service implementation
- Resolve test reference errors that were causing failures
- Improve error handling and test reliability

This fixes the 3 failing database service tests mentioned in the improvement summary.
2025-09-08 11:43:28 -07:00
William Valentin
4f72e464eb test: enhance test setup and infrastructure
- Improve global test setup with better mock implementations
- Add intelligent console noise suppression for cleaner test output
- Enhance browser API mocking for better test compatibility
- Update test utilities for improved reliability
- Fix fetch mock type issues for proper Jest compatibility

This improves the overall testing experience and reduces noise in test output.
2025-09-08 11:42:53 -07:00
William Valentin
5623f7efd2 test: add comprehensive hook tests
- Add extensive tests for useTheme hook with theme switching and system preference detection
- Add tests for useUserData hook with user data management
- Fix documentElement readonly property issues and fetch mock type issues in tests
- Test theme persistence, system theme detection, and edge cases
- Improve hook test coverage and reliability

This adds comprehensive testing for React hooks used throughout the application.
2025-09-08 11:38:37 -07:00
William Valentin
7615600090 test: add authentication middleware tests
- Add comprehensive tests for auth middleware functionality
- Test authentication validation, session handling, and security
- Ensure proper request/response handling in auth pipeline
- Improve authentication service test coverage

This strengthens the authentication layer testing.
2025-09-08 11:36:36 -07:00
William Valentin
3eb18a3b47 test: add email service comprehensive tests
- Add comprehensive tests for email service functionality
- Test email validation, sending capabilities, and error handling
- Improve service test coverage and reliability
- Ensure email operations work correctly in test environment

This adds another layer of service testing infrastructure.
2025-09-08 11:36:00 -07:00
William Valentin
5098631551 test: add comprehensive OAuth service tests
- Implement 21 OAuth tests covering Google and GitHub authentication flows
- Test URL generation, parameter validation, and navigation calls
- Use MockNavigationService for testable OAuth redirect verification
- Achieve 97.05% coverage for OAuth service (up from 31.66%)
- Test both success and error scenarios for OAuth flows
- Fix ESLint unused variable warnings

This resolves the 18 failing OAuth tests and provides robust test coverage.
2025-09-08 11:35:27 -07:00
William Valentin
6305315afc feat: implement navigation service for testable OAuth flows
- Add NavigationService interface with browser and mock implementations
- Refactor OAuth service to use dependency injection for navigation
- Enable comprehensive testing of OAuth flows by abstracting window.location
- Maintain backward compatibility with existing OAuth functionality
- Support both browser and test environments through interface abstraction

This resolves the core OAuth testing issues caused by JSDOM window.location limitations and enables the 18 failing OAuth tests to pass.
2025-09-08 11:33:31 -07:00
William Valentin
8541877290 refactor: implement database service with strategy pattern
- Add DatabaseService with MockDatabaseStrategy and ProductionDatabaseStrategy
- Use strategy pattern to switch between test and production database implementations
- Improve type safety and testability of database operations
- Update database seeder to use new database service architecture

This is the foundation for modernizing the database layer.
2025-09-08 11:30:58 -07:00
William Valentin
2556250f2c feat: add comprehensive test coverage and fix lint issues
- Add comprehensive tests for MailgunService (439 lines)
  * Email sending functionality with template generation
  * Configuration status validation
  * Error handling and edge cases
  * Mock setup for fetch API and FormData

- Add DatabaseService tests (451 lines)
  * Strategy pattern testing (Mock vs Production)
  * All CRUD operations for users, medications, settings
  * Legacy compatibility method testing
  * Proper TypeScript typing

- Add MockDatabaseStrategy tests (434 lines)
  * Complete coverage of mock database implementation
  * User operations, medication management
  * Settings and custom reminders functionality
  * Data persistence and error handling

- Add React hooks tests
  * useLocalStorage hook with comprehensive edge cases (340 lines)
  * useSettings hook with fetch operations and error handling (78 lines)

- Fix auth integration tests
  * Update mocking to use new database service instead of legacy couchdb.factory
  * Fix service variable references and expectations

- Simplify mailgun config tests
  * Remove redundant edge case testing
  * Focus on core functionality validation

- Fix all TypeScript and ESLint issues
  * Proper FormData mock typing
  * Correct database entity type usage
  * Remove non-existent property references

Test Results:
- 184 total tests passing
- Comprehensive coverage of core services
- Zero TypeScript compilation errors
- Full ESLint compliance
2025-09-08 10:13:50 -07:00
William Valentin
9a3bf2084e chore: add auth-specific Playwright artifacts to gitignore
- Add playwright-report-auth/ directory to ignored files
- Add playwright-auth-results.xml to ignored files
- Add playwright-report-auth.json to ignored files
- Prevent test artifacts from being committed to repository
2025-09-08 09:46:35 -07:00
William Valentin
0ad797aeb1 feat: add environment-specific configuration files
- Add .env.development with development-specific variables
- Add Vite-specific environment files for development and production
- Add Docker environment file for development containers
- Provide proper environment variable defaults for each deployment target
- Enable consistent configuration across different runtime environments
2025-09-08 09:46:00 -07:00
William Valentin
78f5bbd90f feat: add generated configuration files and Kubernetes overlays
- Add generated TypeScript configuration exports for all environments
- Create development and production Kubernetes overlay directories
- Include environment-specific kustomization configurations
- Add namespace and resource definitions for proper K8s deployment
- Enable environment-specific configuration management
2025-09-08 09:45:27 -07:00
William Valentin
f3936f23fe feat: add unified configuration generation and migration scripts
- Add generate-unified-config.ts for generating environment configs
- Support multiple output formats: env files, Kubernetes configs, Docker
- Include migration script for transitioning from legacy configuration
- Support dry-run and verbose modes for safe configuration changes
- Generate type-safe environment exports for each environment
- Provide comprehensive error handling and validation
2025-09-08 09:44:50 -07:00
William Valentin
8c8cea9e42 docs: add comprehensive unified configuration documentation
- Create detailed README for unified configuration system
- Document configuration structure and environment overrides
- Provide environment variables reference and best practices
- Include migration guide from legacy configuration system
- Add troubleshooting section and security considerations
- Document all available scripts and generation commands
2025-09-08 09:44:33 -07:00
William Valentin
54a0a77ed5 feat: add explicit namespace resource to production Kubernetes overlay
- Add namespace.yaml to production overlay resources
- Ensure proper namespace creation in production deployments
- Improve Kubernetes resource management and isolation
2025-09-08 09:44:15 -07:00
William Valentin
7ab6d0a486 feat: integrate Vite build with unified configuration
- Replace scattered environment variable definitions with unified config
- Use unifiedConfig as primary source for build-time variables
- Maintain backward compatibility with legacy environment variables
- Add proper TypeScript typing for all environment variables
- Include new environment flags: IS_PRODUCTION, IS_DEVELOPMENT
- Simplify configuration management in build process
2025-09-08 09:43:41 -07:00
William Valentin
b8ef2bbf0a build: update Makefile for unified configuration system
- Replace legacy config generation with unified config commands
- Add environment-specific config generation targets:
  - generate-config-dev, generate-config-staging, generate-config-prod
- Update validate-config to use unified config validation
- Add config-debug target for configuration debugging
- Use bun scripts instead of shell scripts for better reliability
2025-09-08 09:43:20 -07:00
William Valentin
248c949973 fix: resolve TypeScript lint errors in unified.config.ts
- Add missing required properties to environment configurations:
  - App: name, version for all environments
  - Database: username, password, name, connectionTimeout, retryAttempts
  - Kubernetes: ingressClass, certIssuer, storageClass, storageSize
  - Features: enableEmailVerification, enableOAuth, enableAdminInterface,
    enableRateLimiting, enableSecurityHeaders
  - Logging: enableTimestamp for all environments
  - Performance: requestTimeout, maxConnections, enableCors
  - Security: sessionSecret for production
  - Email: fromName, fromEmail for test environment

- Fix type assertions in deepMerge function to resolve TypeScript errors

- Set appropriate environment-specific values with secure defaults
  for production and development-friendly settings for dev/test
2025-09-08 09:35:27 -07:00
William Valentin
a1b3c6a8ed fix: resolve all lint errors in e2e tests and improve type safety
- Replace 'any' types with proper TypeScript interfaces in auth setup/teardown
- Remove conflicting custom Playwright type declarations that were overriding official types
- Fix ES module compatibility by replacing require() with proper import paths
- Add proper generic typing to Playwright test fixtures
- Fix test discovery in auth debug configuration
- Add comprehensive auth debug setup documentation

Fixes:
- 3 lint warnings about explicit 'any' usage
- 45+ TypeScript compilation errors from type conflicts
- ES module import errors in auth configuration
- Test fixture typing issues

All e2e tests now pass lint and type checking with zero warnings.
2025-09-08 08:47:21 -07:00
William Valentin
4d12aeef61 feat: add comprehensive authentication debug test suite
Add automated authentication testing infrastructure:

- AUTH-DEBUG-GUIDE.md: Complete guide for auth debugging
- auth-debug.spec.ts: Comprehensive auth flow validation tests
- playwright.auth.config.ts: Specialized config with extended timeouts
- auth-debug-setup.ts: Global test environment setup
- auth-debug-teardown.ts: Test cleanup and environment reset

Features:
- Admin user validation and permissions testing
- Email format validation including localhost domains
- User registration and OAuth integration testing
- Database connectivity and session management
- Password security and error handling validation
- Cross-browser testing with mobile support
- Enhanced reporting and interactive debugging
- CI/CD integration with artifacts and JUnit reports

Replaces manual browser console debugging scripts with
automated, cross-browser E2E tests for better reliability
and maintainability.
2025-09-08 01:48:26 -07:00
William Valentin
d0ae5eb17a feat: add integration test runner script
- Create automated service availability checker
- Verify CouchDB and frontend services before tests
- Add graceful error handling for missing services
- Enable consistent integration test execution
- Support both CI/CD and local development workflows
2025-09-08 01:44:27 -07:00
William Valentin
d5aa37fbfd feat: add reusable E2E test utilities
- Create TestUtils class for common test operations
- Add loginAsAdmin and loginAsUser helper methods
- Include modal management utilities (open/close)
- Reduce code duplication across E2E test files
- Standardize test patterns and improve maintainability
2025-09-08 01:43:45 -07:00
William Valentin
9fbad062e5 feat: consolidate test mocks with centralized index
- Add mock aggregator for cleaner test imports
- Export fetch and uuid mocks from single entry point
- Reduce mock import complexity in test files
- Improve test maintainability and organization
2025-09-08 01:43:20 -07:00
William Valentin
475c2e5469 docs: add comprehensive test cleanup documentation
- Document removal of manual browser debugging scripts
- Outline new automated E2E test structure
- Provide migration guide from manual to automated tests
- Include running instructions for all test types
- Add benefits of new testing approach
2025-09-08 01:43:02 -07:00
William Valentin
cee86ce0bb refactor: remove manual browser console test scripts
- Remove tests/manual/admin-login-debug.js (replaced by E2E)
- Remove tests/manual/auth-db-debug.js (replaced by E2E)
- Remove tests/manual/debug-email-validation.js (replaced by E2E)

All manual testing functionality now automated with Playwright E2E tests.
Manual scripts backed up in tests/.backup/ for reference.
2025-09-08 01:40:10 -07:00
William Valentin
1f62ffb3d8 feat: add automated test cleanup infrastructure
- Add cleanup-tests.sh script for automated test reorganization
- Safely backup manual test files with timestamps in tests/.backup/
- Generate cleanup-report.json with migration metrics
- Validate test structure after cleanup
- Log detailed cleanup progress and results

Enables safe migration from manual to automated testing
2025-09-08 01:38:49 -07:00
William Valentin
d3c7513600 feat: consolidate Makefile from 89 to 44 targets
- Combine related commands (docker-clean, ci-check, undeploy-all)
- Group Testing & Quality into single section
- Streamline Docker commands with smart combinations
- Add workflow commands for common tasks
- Improve error handling with graceful failures
- Maintain all functionality while reducing complexity
- Keep Makefile.original as safety backup

Commands reduced by 51% while enhancing usability
2025-09-08 01:38:30 -07:00
William Valentin
8c591563c9 feat: consolidate architecture and eliminate code duplication
🏗️ Major architectural improvements:

Database Layer:
- Consolidated duplicate CouchDB services (~800 lines of duplicated code eliminated)
- Implemented strategy pattern with MockDatabaseStrategy and ProductionDatabaseStrategy
- Created unified DatabaseService with automatic environment detection
- Maintained backward compatibility via updated factory pattern

Configuration System:
- Centralized all environment variables in single config/app.config.ts
- Added comprehensive configuration validation with clear error messages
- Eliminated hardcoded base URLs and scattered env var access across 8+ files
- Supports both legacy and new environment variable names

Logging Infrastructure:
- Replaced 25+ scattered console.log statements with structured Logger service
- Added log levels (ERROR, WARN, INFO, DEBUG, TRACE) and contexts (AUTH, DATABASE, API, UI)
- Production-safe logging with automatic level adjustment
- Development helpers for debugging and performance monitoring

Docker & Deployment:
- Removed duplicate docker/Dockerfile configuration
- Enhanced root Dockerfile with comprehensive environment variable support
- Added proper health checks and security improvements

Code Quality:
- Fixed package name consistency (rxminder → RxMinder)
- Updated services to use centralized configuration and logging
- Resolved all ESLint errors and warnings
- Added comprehensive documentation and migration guides

📊 Impact:
- Eliminated ~500 lines of duplicate code
- Single source of truth for database, configuration, and logging
- Better type safety and error handling
- Improved development experience and maintainability

📚 Documentation:
- Added ARCHITECTURE_MIGRATION.md with detailed migration guide
- Created IMPLEMENTATION_SUMMARY.md with metrics and benefits
- Inline documentation for all new services and interfaces

🔄 Backward Compatibility:
- All existing code continues to work unchanged
- Legacy services show deprecation warnings but remain functional
- Gradual migration path available for development teams

Breaking Changes: None (full backward compatibility maintained)
2025-09-08 01:09:48 -07:00
William Valentin
0ea1af91c9 feat: Complete Kustomize migration with environment variable integration
🎉 Major enhancement: Full migration from shell script deployment to Kustomize

## New Features

### Kustomize Infrastructure
-  Complete base resources for all Kubernetes manifests
-  Development overlay with optimized dev settings
-  Production overlay with enterprise-grade security and performance
-  ConfigMap and Secret generation from environment variables
-  Image tag and replica management per environment

### Environment Variable Integration
-  Multi-source environment loading (~/.env, .env.dev, .env.prod, .env.local)
-  Static configuration generation from environment variables
-  Dynamic runtime environment variable injection
-  Comprehensive variable documentation and examples
-  Secrets template generation for secure credential management

### Enhanced Makefile
-  20+ new Kustomize-specific deployment targets
-  Environment-aware configuration generation commands
-  Validation, dry-run, and debugging capabilities
-  Backward compatibility with legacy shell script deployment

### New Scripts & Tools
-  scripts/generate-config.sh - Environment variable to Kustomize config generator
-  scripts/deploy-with-env.sh - Runtime environment variable deployment tool
-  Comprehensive help and usage documentation

### Documentation
-  k8s-kustomize/README.md - Complete Kustomize deployment guide
-  docs/ENVIRONMENT_VARIABLES.md - Environment variable integration guide
-  KUSTOMIZE_MIGRATION.md - Migration summary and next steps

## Benefits
- 🚀 Simplified deployment: make deploy-dev vs complex shell scripts
- 🔒 Environment isolation: Clear dev/staging/prod separation
- 🔧 GitOps ready: Works seamlessly with ArgoCD, Flux
-  Better validation: Built-in YAML validation catches errors early
- 📈 Standard approach: Industry-standard Kubernetes deployment method
- 🛡️ Enhanced security: Production security contexts, network policies, TLS

## Usage Examples
Generating development configuration...
[INFO] Kustomize Config Generator
[INFO] Environment: dev
[INFO] Loading environment variables...
[WARNING] File not found: /home/will/.env
[INFO] Loading: /home/will/Code/meds/.env
[WARNING] File not found: /home/will/Code/meds/.env.dev
[WARNING] File not found: /home/will/Code/meds/.env.local
[INFO] Generating base config.env...
[SUCCESS] Generated: /home/will/Code/meds/k8s-kustomize/base/config.env
[INFO] Generating environment-specific config for: dev
[SUCCESS] Generated development config: /home/will/Code/meds/k8s-kustomize/overlays/dev/config.env
[INFO] Validating generated configuration...
[SUCCESS] Configuration validation passed!
[SUCCESS] Configuration generation completed!
[INFO] Next steps:
  1. Review generated files in k8s-kustomize/
  2. Update any environment-specific values
  3. Create secrets.env files for sensitive data
  4. Test with: make kustomize-dry-run-dev
Deploying to Kubernetes with Kustomize (dev)...
Deploying to production with environment variables...
[INFO] Kustomize Deployment with Environment Variables
[INFO] Environment: prod
[INFO] Action: apply
[INFO] Validating prerequisites...
[SUCCESS] Prerequisites validated
[INFO] Loading environment variables for: prod
[INFO] Loading: /home/will/Code/meds/.env
[SUCCESS] Environment loaded: prod
[INFO] Key variables:
  APP_NAME: rxminder
  NODE_ENV: production
  IMAGE_TAG: latest
  NAMESPACE: rxminder-prod
  INGRESS_HOST: rxminder.192.168.153.243.nip.io
[INFO] Generating dynamic configuration...
Validating Kustomize configuration (dev)...
configmap/rxminder-config-4229dg76t6 created (dry run)
secret/couchdb-secret-7ck2cc96g5 created (dry run)
service/rxminder-couchdb-service created (dry run)
service/rxminder-frontend-service created (dry run)
persistentvolumeclaim/rxminder-couchdb-pvc created (dry run)
deployment.apps/rxminder-frontend created (dry run)
statefulset.apps/rxminder-couchdb created (dry run)
horizontalpodautoscaler.autoscaling/rxminder-frontend-hpa created (dry run)
job.batch/rxminder-db-seed created (dry run)
ingress.networking.k8s.io/rxminder-ingress created (dry run)
networkpolicy.networking.k8s.io/rxminder-database-policy created (dry run)
networkpolicy.networking.k8s.io/rxminder-frontend-policy created (dry run)
Validating Kustomize configuration (prod)...
configmap/rxminder-config-2979gkcf9c created (dry run)
secret/couchdb-secret-6k9794bgg2 created (dry run)
service/rxminder-couchdb-service created (dry run)
service/rxminder-frontend-service created (dry run)
persistentvolumeclaim/rxminder-couchdb-pvc created (dry run)
deployment.apps/rxminder-frontend created (dry run)
statefulset.apps/rxminder-couchdb created (dry run)
horizontalpodautoscaler.autoscaling/rxminder-frontend-hpa created (dry run)
job.batch/rxminder-db-seed created (dry run)
ingress.networking.k8s.io/rxminder-ingress created (dry run)
networkpolicy.networking.k8s.io/rxminder-database-policy created (dry run)
networkpolicy.networking.k8s.io/rxminder-frontend-policy created (dry run)
Kustomize validation completed!
Dry run Kustomize deployment (dev)...
apiVersion: v1
items:
- apiVersion: v1
  data:
    APP_NAME: rxminder
    APP_VERSION: 1.0.0
    CACHE_TTL: "1800"
    CERT_MANAGER_ISSUER: letsencrypt-prod
    CORS_ORIGIN: '*'
    COUCHDB_DATABASE_NAME: meds_app
    DB_HOST: rxminder-couchdb-service
    DB_PORT: "5984"
    DEBUG: "true"
    DEV_MODE: "false"
    ENABLE_CORS: "true"
    ENABLE_METRICS: "false"
    ENABLE_MONITORING: "false"
    ENABLE_TRACING: "false"
    HEALTH_CHECK_INTERVAL: "30"
    HOT_RELOAD: "false"
    IMAGE_REPOSITORY: will/rxminder
    INGRESS_CLASS: nginx
    LOG_FORMAT: json
    LOG_LEVEL: debug
    LOG_TIMESTAMP: "true"
    MAX_CONNECTIONS: "100"
    METRICS_PORT: "9090"
    NODE_ENV: development
    REACT_APP_API_URL: http://rxminder-couchdb-service:5984
    READINESS_CHECK_TIMEOUT: "5"
    REGISTRY_URL: gitea-http.taildb3494.ts.net
    REQUEST_TIMEOUT: "30000"
  kind: ConfigMap
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","data":{"APP_NAME":"rxminder","APP_VERSION":"1.0.0","CACHE_TTL":"1800","CERT_MANAGER_ISSUER":"letsencrypt-prod","CORS_ORIGIN":"*","COUCHDB_DATABASE_NAME":"meds_app","DB_HOST":"rxminder-couchdb-service","DB_PORT":"5984","DEBUG":"true","DEV_MODE":"false","ENABLE_CORS":"true","ENABLE_METRICS":"false","ENABLE_MONITORING":"false","ENABLE_TRACING":"false","HEALTH_CHECK_INTERVAL":"30","HOT_RELOAD":"false","IMAGE_REPOSITORY":"will/rxminder","INGRESS_CLASS":"nginx","LOG_FORMAT":"json","LOG_LEVEL":"debug","LOG_TIMESTAMP":"true","MAX_CONNECTIONS":"100","METRICS_PORT":"9090","NODE_ENV":"development","REACT_APP_API_URL":"http://rxminder-couchdb-service:5984","READINESS_CHECK_TIMEOUT":"5","REGISTRY_URL":"gitea-http.taildb3494.ts.net","REQUEST_TIMEOUT":"30000"},"kind":"ConfigMap","metadata":{"annotations":{},"labels":{"app":"rxminder","environment":"dev","version":"v1.0.0"},"name":"rxminder-config-4229dg76t6","namespace":"rxminder-dev"}}
    labels:
      app: rxminder
      environment: dev
      version: v1.0.0
    name: rxminder-config-4229dg76t6
    namespace: rxminder-dev
- apiVersion: v1
  data:
    password: ZGV2cGFzczEyMw==
    username: YWRtaW4=
  kind: Secret
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","data":{"password":"ZGV2cGFzczEyMw==","username":"YWRtaW4="},"kind":"Secret","metadata":{"annotations":{},"labels":{"app":"rxminder","environment":"dev","version":"v1.0.0"},"name":"couchdb-secret-7ck2cc96g5","namespace":"rxminder-dev"},"type":"Opaque"}
    labels:
      app: rxminder
      environment: dev
      version: v1.0.0
    name: couchdb-secret-7ck2cc96g5
    namespace: rxminder-dev
  type: Opaque
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"database","environment":"dev","version":"v1.0.0"},"name":"rxminder-couchdb-service","namespace":"rxminder-dev"},"spec":{"ports":[{"name":"couchdb","port":5984,"protocol":"TCP","targetPort":5984}],"selector":{"app":"rxminder","component":"database"},"type":"ClusterIP"}}
    labels:
      app: rxminder
      component: database
      environment: dev
      version: v1.0.0
    name: rxminder-couchdb-service
    namespace: rxminder-dev
  spec:
    ports:
    - name: couchdb
      port: 5984
      protocol: TCP
      targetPort: 5984
    selector:
      app: rxminder
      component: database
    type: ClusterIP
- apiVersion: v1
  kind: Service
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"frontend","environment":"dev","version":"v1.0.0"},"name":"rxminder-frontend-service","namespace":"rxminder-dev"},"spec":{"ports":[{"name":"http","port":80,"protocol":"TCP","targetPort":80}],"selector":{"app":"rxminder","component":"frontend"},"type":"ClusterIP"}}
    labels:
      app: rxminder
      component: frontend
      environment: dev
      version: v1.0.0
    name: rxminder-frontend-service
    namespace: rxminder-dev
  spec:
    ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 80
    selector:
      app: rxminder
      component: frontend
    type: ClusterIP
- apiVersion: v1
  kind: PersistentVolumeClaim
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"v1","kind":"PersistentVolumeClaim","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"database","environment":"dev","version":"v1.0.0"},"name":"rxminder-couchdb-pvc","namespace":"rxminder-dev"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"1Gi"}},"storageClassName":"standard"}}
    labels:
      app: rxminder
      component: database
      environment: dev
      version: v1.0.0
    name: rxminder-couchdb-pvc
    namespace: rxminder-dev
  spec:
    accessModes:
    - ReadWriteOnce
    resources:
      requests:
        storage: 1Gi
    storageClassName: standard
- apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"apps/v1","kind":"Deployment","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"frontend","environment":"dev","version":"v1.0.0"},"name":"rxminder-frontend","namespace":"rxminder-dev"},"spec":{"replicas":1,"selector":{"matchLabels":{"component":"frontend"}},"template":{"metadata":{"labels":{"component":"frontend"}},"spec":{"containers":[{"env":[{"name":"NODE_ENV","value":"development"},{"name":"LOG_LEVEL","value":"debug"}],"envFrom":[{"configMapRef":{"name":"rxminder-config-4229dg76t6"}}],"image":"gitea-http.taildb3494.ts.net/will/rxminder:dev","livenessProbe":{"httpGet":{"path":"/","port":80},"initialDelaySeconds":30,"periodSeconds":30},"name":"frontend","ports":[{"containerPort":80}],"readinessProbe":{"httpGet":{"path":"/","port":80},"initialDelaySeconds":5,"periodSeconds":5},"resources":{"limits":{"cpu":"40m","memory":"32Mi"},"requests":{"cpu":"20m","memory":"16Mi"}}}],"imagePullSecrets":[{"name":"rxminder-registry-secret"}]}}}}
    labels:
      app: rxminder
      component: frontend
      environment: dev
      version: v1.0.0
    name: rxminder-frontend
    namespace: rxminder-dev
  spec:
    replicas: 1
    selector:
      matchLabels:
        component: frontend
    template:
      metadata:
        labels:
          component: frontend
      spec:
        containers:
        - env:
          - name: NODE_ENV
            value: development
          - name: LOG_LEVEL
            value: debug
          envFrom:
          - configMapRef:
              name: rxminder-config-4229dg76t6
          image: gitea-http.taildb3494.ts.net/will/rxminder:dev
          livenessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 30
            periodSeconds: 30
          name: frontend
          ports:
          - containerPort: 80
          readinessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 5
          resources:
            limits:
              cpu: 40m
              memory: 32Mi
            requests:
              cpu: 20m
              memory: 16Mi
        imagePullSecrets:
        - name: rxminder-registry-secret
- apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"apps/v1","kind":"StatefulSet","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"database","environment":"dev","version":"v1.0.0"},"name":"rxminder-couchdb","namespace":"rxminder-dev"},"spec":{"replicas":1,"selector":{"matchLabels":{"app":"rxminder","component":"database"}},"serviceName":"rxminder-couchdb-service","template":{"metadata":{"labels":{"app":"rxminder","component":"database"}},"spec":{"containers":[{"env":[{"name":"COUCHDB_USER","valueFrom":{"secretKeyRef":{"key":"username","name":"couchdb-secret-7ck2cc96g5"}}},{"name":"COUCHDB_PASSWORD","valueFrom":{"secretKeyRef":{"key":"password","name":"couchdb-secret-7ck2cc96g5"}}}],"image":"couchdb:3.3.2","livenessProbe":{"httpGet":{"path":"/_up","port":5984},"initialDelaySeconds":60,"periodSeconds":30},"name":"couchdb","ports":[{"containerPort":5984}],"readinessProbe":{"httpGet":{"path":"/_up","port":5984},"initialDelaySeconds":10,"periodSeconds":5},"resources":{"limits":{"cpu":"60m","memory":"128Mi"},"requests":{"cpu":"30m","memory":"64Mi"}},"volumeMounts":[{"mountPath":"/opt/couchdb/data","name":"couchdb-data"}]}]}},"volumeClaimTemplates":[{"metadata":{"labels":{"app":"rxminder","component":"database"},"name":"couchdb-data"},"spec":{"accessModes":["ReadWriteOnce"],"resources":{"requests":{"storage":"1Gi"}},"storageClassName":"standard"}}]}}
    labels:
      app: rxminder
      component: database
      environment: dev
      version: v1.0.0
    name: rxminder-couchdb
    namespace: rxminder-dev
  spec:
    replicas: 1
    selector:
      matchLabels:
        app: rxminder
        component: database
    serviceName: rxminder-couchdb-service
    template:
      metadata:
        labels:
          app: rxminder
          component: database
      spec:
        containers:
        - env:
          - name: COUCHDB_USER
            valueFrom:
              secretKeyRef:
                key: username
                name: couchdb-secret-7ck2cc96g5
          - name: COUCHDB_PASSWORD
            valueFrom:
              secretKeyRef:
                key: password
                name: couchdb-secret-7ck2cc96g5
          image: couchdb:3.3.2
          livenessProbe:
            httpGet:
              path: /_up
              port: 5984
            initialDelaySeconds: 60
            periodSeconds: 30
          name: couchdb
          ports:
          - containerPort: 5984
          readinessProbe:
            httpGet:
              path: /_up
              port: 5984
            initialDelaySeconds: 10
            periodSeconds: 5
          resources:
            limits:
              cpu: 60m
              memory: 128Mi
            requests:
              cpu: 30m
              memory: 64Mi
          volumeMounts:
          - mountPath: /opt/couchdb/data
            name: couchdb-data
    volumeClaimTemplates:
    - metadata:
        labels:
          app: rxminder
          component: database
        name: couchdb-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 1Gi
        storageClassName: standard
- apiVersion: autoscaling/v2
  kind: HorizontalPodAutoscaler
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"autoscaling/v2","kind":"HorizontalPodAutoscaler","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"frontend","environment":"dev","version":"v1.0.0"},"name":"rxminder-frontend-hpa","namespace":"rxminder-dev"},"spec":{"maxReplicas":3,"metrics":[{"resource":{"name":"cpu","target":{"averageUtilization":50,"type":"Utilization"}},"type":"Resource"}],"minReplicas":1,"scaleTargetRef":{"apiVersion":"apps/v1","kind":"Deployment","name":"rxminder-frontend"}}}
    labels:
      app: rxminder
      component: frontend
      environment: dev
      version: v1.0.0
    name: rxminder-frontend-hpa
    namespace: rxminder-dev
  spec:
    maxReplicas: 3
    metrics:
    - resource:
        name: cpu
        target:
          averageUtilization: 50
          type: Utilization
      type: Resource
    minReplicas: 1
    scaleTargetRef:
      apiVersion: apps/v1
      kind: Deployment
      name: rxminder-frontend
- apiVersion: batch/v1
  kind: Job
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"batch/v1","kind":"Job","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"database","environment":"dev","version":"v1.0.0"},"name":"rxminder-db-seed","namespace":"rxminder-dev"},"spec":{"backoffLimit":4,"template":{"metadata":{"labels":{"app":"rxminder","component":"database"}},"spec":{"containers":[{"args":["# Wait for CouchDB to be ready\necho \"Waiting for CouchDB to be ready...\"\nuntil curl -f http://couchdb-service:5984/_up 2\u003e/dev/null; do\n  sleep 2\ndone\n\n# Create databases\necho \"Creating databases...\"\ncurl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app\n\n# Create default admin user\necho \"Creating default admin user...\"\ncurl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/_users/org.couchdb.user:$COUCHDB_USER \\\n  -H \"Content-Type: application/json\" \\\n  -d \"{\n    \\\"name\\\": \\\"$COUCHDB_USER\\\",\n    \\\"password\\\": \\\"$COUCHDB_PASSWORD\\\",\n    \\\"roles\\\": [\\\"admin\\\"],\n    \\\"type\\\": \\\"user\\\"\n  }\"\n\n# Create design documents for views\necho \"Creating design documents...\"\ncurl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app/_design/medications \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"views\": {\n      \"by_name\": {\n        \"map\": \"function(doc) { if (doc.type === \\\"medication\\\") emit(doc.name, doc); }\"\n      },\n      \"by_user\": {\n        \"map\": \"function(doc) { if (doc.type === \\\"medication\\\") emit(doc.userId, doc); }\"\n      }\n    }\n  }'\n\ncurl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app/_design/reminders \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"views\": {\n      \"by_medication\": {\n        \"map\": \"function(doc) { if (doc.type === \\\"reminder\\\") emit(doc.medicationId, doc); }\"\n      },\n      \"by_user\": {\n        \"map\": \"function(doc) { if (doc.type === \\\"reminder\\\") emit(doc.userId, doc); }\"\n      }\n    }\n  }'\n\n# Create a sample user document for reference\n  # Create design document for authentication users\n  curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app/_design/auth \\\n    -H \"Content-Type: application/json\" \\\n    -d '{\n      \"views\": {\n        \"by_username\": {\n          \"map\": \"function(doc) { if (doc.type === \\\"user\\\" \u0026\u0026 doc.username) emit(doc.username, doc); }\"\n        },\n        \"by_email\": {\n          \"map\": \"function(doc) { if (doc.type === \\\"user\\\" \u0026\u0026 doc.email) emit(doc.email, doc); }\"\n        }\n      }\n    }'\necho \"Creating sample user document...\"\ncurl -X POST http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"type\": \"user\",\n    \"name\": \"sample_user\",\n    \"email\": \"user@example.com\",\n    \"createdAt\": \"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'\"\n  }'\n\necho \"Database seeding completed with default admin user\"\n"],"command":["/bin/sh","-c"],"env":[{"name":"COUCHDB_USER","valueFrom":{"secretKeyRef":{"key":"username","name":"couchdb-secret-7ck2cc96g5"}}},{"name":"COUCHDB_PASSWORD","valueFrom":{"secretKeyRef":{"key":"password","name":"couchdb-secret-7ck2cc96g5"}}}],"image":"couchdb:3.3.2","name":"db-seeder"}],"restartPolicy":"Never"}}}}
    labels:
      app: rxminder
      component: database
      environment: dev
      version: v1.0.0
    name: rxminder-db-seed
    namespace: rxminder-dev
  spec:
    backoffLimit: 4
    template:
      metadata:
        labels:
          app: rxminder
          component: database
      spec:
        containers:
        - args:
          - |
            # Wait for CouchDB to be ready
            echo "Waiting for CouchDB to be ready..."
            until curl -f http://couchdb-service:5984/_up 2>/dev/null; do
              sleep 2
            done

            # Create databases
            echo "Creating databases..."
            curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app

            # Create default admin user
            echo "Creating default admin user..."
            curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/_users/org.couchdb.user:$COUCHDB_USER \
              -H "Content-Type: application/json" \
              -d "{
                \"name\": \"$COUCHDB_USER\",
                \"password\": \"$COUCHDB_PASSWORD\",
                \"roles\": [\"admin\"],
                \"type\": \"user\"
              }"

            # Create design documents for views
            echo "Creating design documents..."
            curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app/_design/medications \
              -H "Content-Type: application/json" \
              -d '{
                "views": {
                  "by_name": {
                    "map": "function(doc) { if (doc.type === \"medication\") emit(doc.name, doc); }"
                  },
                  "by_user": {
                    "map": "function(doc) { if (doc.type === \"medication\") emit(doc.userId, doc); }"
                  }
                }
              }'

            curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app/_design/reminders \
              -H "Content-Type: application/json" \
              -d '{
                "views": {
                  "by_medication": {
                    "map": "function(doc) { if (doc.type === \"reminder\") emit(doc.medicationId, doc); }"
                  },
                  "by_user": {
                    "map": "function(doc) { if (doc.type === \"reminder\") emit(doc.userId, doc); }"
                  }
                }
              }'

            # Create a sample user document for reference
              # Create design document for authentication users
              curl -X PUT http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app/_design/auth \
                -H "Content-Type: application/json" \
                -d '{
                  "views": {
                    "by_username": {
                      "map": "function(doc) { if (doc.type === \"user\" && doc.username) emit(doc.username, doc); }"
                    },
                    "by_email": {
                      "map": "function(doc) { if (doc.type === \"user\" && doc.email) emit(doc.email, doc); }"
                    }
                  }
                }'
            echo "Creating sample user document..."
            curl -X POST http://$COUCHDB_USER:$COUCHDB_PASSWORD@couchdb-service:5984/meds_app \
              -H "Content-Type: application/json" \
              -d '{
                "type": "user",
                "name": "sample_user",
                "email": "user@example.com",
                "createdAt": "'$(date -u +%Y-%m-%dT%H:%M:%SZ)'"
              }'

            echo "Database seeding completed with default admin user"
          command:
          - /bin/sh
          - -c
          env:
          - name: COUCHDB_USER
            valueFrom:
              secretKeyRef:
                key: username
                name: couchdb-secret-7ck2cc96g5
          - name: COUCHDB_PASSWORD
            valueFrom:
              secretKeyRef:
                key: password
                name: couchdb-secret-7ck2cc96g5
          image: couchdb:3.3.2
          name: db-seeder
        restartPolicy: Never
- apiVersion: networking.k8s.io/v1
  kind: Ingress
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"networking.k8s.io/v1","kind":"Ingress","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"frontend","environment":"dev","version":"v1.0.0"},"name":"rxminder-ingress","namespace":"rxminder-dev"},"spec":{"ingressClassName":"nginx","rules":[{"host":"rxminder-dev.local","http":{"paths":[{"backend":{"service":{"name":"rxminder-frontend-service","port":{"number":80}}},"path":"/","pathType":"Prefix"}]}}]}}
    labels:
      app: rxminder
      component: frontend
      environment: dev
      version: v1.0.0
    name: rxminder-ingress
    namespace: rxminder-dev
  spec:
    ingressClassName: nginx
    rules:
    - host: rxminder-dev.local
      http:
        paths:
        - backend:
            service:
              name: rxminder-frontend-service
              port:
                number: 80
          path: /
          pathType: Prefix
- apiVersion: networking.k8s.io/v1
  kind: NetworkPolicy
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"networking.k8s.io/v1","kind":"NetworkPolicy","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"database","environment":"dev","version":"v1.0.0"},"name":"rxminder-database-policy","namespace":"rxminder-dev"},"spec":{"egress":[{"ports":[{"port":5984,"protocol":"TCP"}],"to":[{"podSelector":{"matchLabels":{"component":"database"}}}]}],"ingress":[{"from":[{"podSelector":{"matchLabels":{"component":"frontend"}}}],"ports":[{"port":5984,"protocol":"TCP"}]}],"podSelector":{"matchLabels":{"component":"database"}},"policyTypes":["Ingress","Egress"]}}
    labels:
      app: rxminder
      component: database
      environment: dev
      version: v1.0.0
    name: rxminder-database-policy
    namespace: rxminder-dev
  spec:
    egress:
    - ports:
      - port: 5984
        protocol: TCP
      to:
      - podSelector:
          matchLabels:
            component: database
    ingress:
    - from:
      - podSelector:
          matchLabels:
            component: frontend
      ports:
      - port: 5984
        protocol: TCP
    podSelector:
      matchLabels:
        component: database
    policyTypes:
    - Ingress
    - Egress
- apiVersion: networking.k8s.io/v1
  kind: NetworkPolicy
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"networking.k8s.io/v1","kind":"NetworkPolicy","metadata":{"annotations":{},"labels":{"app":"rxminder","component":"frontend","environment":"dev","version":"v1.0.0"},"name":"rxminder-frontend-policy","namespace":"rxminder-dev"},"spec":{"egress":[{"ports":[{"port":5984,"protocol":"TCP"}],"to":[{"podSelector":{"matchLabels":{"component":"database"}}}]},{"ports":[{"port":80,"protocol":"TCP"}],"to":[{"podSelector":{"matchLabels":{"component":"frontend"}}}]}],"ingress":[{"from":[{"podSelector":{"matchLabels":{"component":"frontend"}}}],"ports":[{"port":80,"protocol":"TCP"}]}],"podSelector":{"matchLabels":{"component":"frontend"}},"policyTypes":["Ingress","Egress"]}}
    labels:
      app: rxminder
      component: frontend
      environment: dev
      version: v1.0.0
    name: rxminder-frontend-policy
    namespace: rxminder-dev
  spec:
    egress:
    - ports:
      - port: 5984
        protocol: TCP
      to:
      - podSelector:
          matchLabels:
            component: database
    - ports:
      - port: 80
        protocol: TCP
      to:
      - podSelector:
          matchLabels:
            component: frontend
    ingress:
    - from:
      - podSelector:
          matchLabels:
            component: frontend
      ports:
      - port: 80
        protocol: TCP
    podSelector:
      matchLabels:
        component: frontend
    policyTypes:
    - Ingress
    - Egress
kind: List
metadata: {}

## Migration Path
- Legacy shell scripts remain available for backward compatibility
- Gradual migration: dev → staging → production
- Zero-downtime deployment capability

Co-authored-by: Assistant <assistant@anthropic.com>
2025-09-07 20:47:10 -07:00
William Valentin
e47150f80a feat: Add container registry support and Kustomize foundation
- Add registry secret template for private container registry authentication
- Fix frontend deployment to use imagePullSecrets for private registry
- Enhance deploy-k8s.sh with registry authentication handling
- Add PVC storage size validation to prevent storage reduction errors
- Add graceful StatefulSet update error handling
- Fix template variable substitution for DOCKER_IMAGE
- Remove conflicting static PVC file that had unprocessed template variables
- Add Kustomize structure as alternative to shell script templates:
  - Base configuration with common resources
  - Development overlay with dev-specific configurations
  - Support for environment-specific image tags and resource limits

Registry setup requires setting REGISTRY_USERNAME, REGISTRY_PASSWORD, and
optionally REGISTRY_HOST in .env file for private registry authentication.
2025-09-07 20:28:23 -07:00
William Valentin
2913f879ca feat: Add undeploy and Docker cleanup targets to Makefile 2025-09-07 18:58:33 -07:00
William Valentin
22e996e698 Refactor Mailgun config to use getEnvVar and improve checks
- Replace getEnv with getEnvVar for environment variable access - Update
MailgunConfig types to allow undefined values - Enhance
isMailgunConfigured to check for undefined and empty values - Update
isDevelopmentMode to check production status - Improve test mocks for
environment variable handling
2025-09-07 18:36:55 -07:00
William Valentin
16d025e747 Add comprehensive test suite and update configuration
- Add Jest testing framework configuration
- Add test files for services, types, and utilities
- Update package.json with Jest dependencies and test scripts
- Enhance pre-commit checks to include testing
- Add proper environment validation and error handling in mailgun service
2025-09-07 18:18:25 -07:00
William Valentin
bfebb34b7a Clean up whitespace in CouchDB factory and add coverage directory to gitignore 2025-09-07 16:18:32 -07:00
William Valentin
bffd13e6fc feat(build): add backend-focused testing commands
- Add 'make full-check-backend' for fast backend testing without E2E
- Add 'make test-backend' for unit and integration tests only
- Update 'test:integration' to use Jest instead of bun for consistency
- Improve command descriptions for clarity
- Enable fast development workflow by skipping E2E tests when not needed
2025-09-07 16:14:58 -07:00
William Valentin
2e3fbaf1e6 fix(auth): resolve service import and dependency issues
- Replace dynamic imports with static imports for better test compatibility
- Fix circular dependency issues between auth service and CouchDB factory
- Use correct CouchDB service methods (createUserWithPassword, etc.)
- Remove unused imports and improve code organization
- Fix email verification service to work properly with mocked dependencies
- Ensure proper error handling and service interaction patterns
2025-09-07 16:14:25 -07:00
William Valentin
38699c6724 test(auth): enhance auth integration tests with comprehensive coverage
- Restructure tests with better organization by functionality
- Add comprehensive test coverage for all auth flows
- Include OAuth authentication testing (registration and login)
- Add password management tests (change password, reset password)
- Test error scenarios and edge cases
- Improve type safety with proper interfaces
- Fix mock configuration and service interaction testing
- Add tests for user registration, login, and verification flows
2025-09-07 16:13:50 -07:00
William Valentin
65c846d7c5 test(auth): improve email verification service tests
- Restructure tests with better organization and describe blocks
- Add comprehensive test coverage for all service methods
- Test edge cases including expired tokens and database errors
- Add integration scenario tests for full verification flow
- Fix TypeScript issues with mock user creation
- Improve test isolation and mock management
- Add tests for unique token generation and error handling
2025-09-07 16:13:14 -07:00
William Valentin
e7097ee102 feat(test): enhance test setup with comprehensive mocking
- Add proper TypeScript types for all mocks
- Implement UUID library mocking for unique token generation
- Add comprehensive fetch, FormData, Blob, and File API mocks
- Include crypto, performance, and observer API mocks
- Add utility functions for test helpers
- Improve console suppression for cleaner test output
- Fix localStorage and sessionStorage implementation
2025-09-07 16:12:35 -07:00
William Valentin
b4a9318324 test: enhance E2E and integration testing infrastructure
- Add comprehensive TypeScript types to E2E test helpers
- Improve medication, auth, modal, and wait helper classes with proper typing
- Enhance test data with readonly type assertions for better immutability
- Update integration tests with better error handling and assertions
- Improve Playwright type definitions for better IDE support
- Add environment variable support to manual test scripts
2025-09-07 15:22:33 -07:00
William Valentin
172bb2bd74 refactor: improve service layer logging and configuration
- Change email service logging from console.log to console.warn for better visibility
- Update mailgun and couchdb configuration with improved error handling
- Enhance database seeder with better logging and error management
- Improve service factory patterns for better testability
2025-09-07 15:22:04 -07:00
William Valentin
58a4988b58 feat: add cross-platform environment utility
- Create universal environment variable utility for Vite and Node.js
- Support both import.meta.env (browser/Vite) and process.env (Node.js)
- Add environment detection helpers (isBrowser, isNode, isTest, isProduction)
- Safely handle environment access across different runtime contexts
- TypeScript support with proper type definitions
2025-09-07 15:21:36 -07:00
William Valentin
2814237e71 deps: add testing dependencies and update configuration
- Add Babel core, presets for env and TypeScript support
- Add babel-jest for JavaScript transformation in Jest
- Add node-fetch and @types/node-fetch for HTTP testing
- Update TypeScript config for better Jest compatibility
- Update bun.lock with new dependency resolutions
2025-09-07 15:21:27 -07:00
William Valentin
c5d3631cb6 feat: configure Jest testing infrastructure
- Update Jest config with module name mapping for uuid and node-fetch
- Add Babel transform for mixed JS/TS support
- Configure transformIgnorePatterns for ES modules
- Add comprehensive test mocks for uuid and node-fetch
- Setup import.meta environment variables for Jest compatibility
- Increase test timeout to 30 seconds for integration tests
2025-09-07 15:20:59 -07:00
William Valentin
315303b120 Fix pre-commit script to properly handle multiple files and resolve ESLint warnings 2025-09-07 13:34:39 -07:00