Skip to content

Conversation

@Suraj-kumar00
Copy link
Contributor

@Suraj-kumar00 Suraj-kumar00 commented Jan 17, 2026

📋 Description

  • Add HealthController and HealthService with MySQL and Redis health checks
  • Add VersionController and VersionService for Git commit and build info
  • Update JwtUserIdValidationFilter to bypass authentication for monitoring endpoints
  • Add git-commit-id-plugin and build-info goal to Maven configuration

Closes #102


✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

http://localhost:8081/health

{
  "status": "DOWN",
  "timestamp": "2026-01-17T13:00:46.469321333Z",
  "components": {
    "mysql": {
      "status": "DOWN",
      "details": {
        "type": "MySQL",
        "host": "mysql-container",
        "port": "3306",
        "database": "db_iemr",
        "error": "java.sql.SQLException: Access denied for user 'root'@'172.18.0.5' (using password: YES)",
        "errorType": "RuntimeException"
      }
    },
    "redis": {
      "status": "UP",
      "details": {
        "type": "Redis",
        "host": "redis-container",
        "port": 6379,
        "responseTimeMs": 649,
        "version": "7.2.4"
      }
    }
  }
}

http://localhost:8081/version

{
  "git.commit.id": "unknown",
  "git.build.time": "2026-01-17T12:49:12+0000",
  "build.version": "3.1.0",
  "build.time": "2026-01-17T12:48:59.753Z",
  "current.time": "2026-01-17 18:38:41"
}

Summary by CodeRabbit

  • New Features

    • Added a health check endpoint to monitor system component status (MySQL and Redis).
    • Added a version information endpoint to retrieve application version details, including build and git metadata.
    • Health and version endpoints are now exempt from authentication requirements.
  • Chores

    • Enhanced build process to generate git commit information and build timestamp metadata.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add HealthController and HealthService with MySQL and Redis health checks
- Add VersionController and VersionService for Git commit and build info
- Update JwtUserIdValidationFilter to bypass authentication for monitoring endpoints
- Add git-commit-id-plugin and build-info goal to Maven configuration

Closes PSMRI#102
@coderabbitai
Copy link

coderabbitai bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

The changes introduce health and version information endpoints to the application. A git-commit-id-plugin and build-info execution are added to the build configuration to generate build metadata. New REST controllers expose /health and /version endpoints backed by services that perform component health checks (MySQL, Redis) and aggregate version information. A JWT filter is updated to skip authentication for these new endpoints.

Changes

Cohort / File(s) Summary
Build Configuration
pom.xml
Added git-commit-id-plugin to generate git.properties with commit ID and build time; added build-info goal execution to Spring Boot Maven plugin for build metadata generation during package process.
Health Endpoint
src/main/java/com/iemr/flw/controller/health/HealthController.java
src/main/java/com/iemr/flw/service/health/HealthService.java
New HealthController REST endpoint GET /health delegates to HealthService.checkHealth(), returning component health statuses (MySQL, Redis) with response times and version info; returns HTTP 200 (UP) or 503 (DOWN). HealthService aggregates health checks with connection validation, version retrieval, and comprehensive logging.
Version Endpoint
src/main/java/com/iemr/flw/controller/version/VersionController.java
src/main/java/com/iemr/flw/service/version/VersionService.java
New VersionController REST endpoint GET /version returns aggregated version information including Git, build metadata, and current IST timestamp. VersionService loads git.properties and build-info.properties with fallback to Maven properties and ObjectMapper JSON conversion with error handling.
Filter Updates
src/main/java/com/iemr/flw/utils/JwtUserIdValidationFilter.java
Added early skip logic in JwtUserIdValidationFilter.doFilter to bypass JWT validation for /health and /version endpoints; removed redundant path variable re-definitions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant HealthController
    participant HealthService
    participant MySQL
    participant Redis

    Client->>HealthController: GET /health
    HealthController->>HealthService: checkHealth()
    
    par MySQL Health Check
        HealthService->>MySQL: Validate connection
        MySQL-->>HealthService: Connection OK
        HealthService->>MySQL: Query version
        MySQL-->>HealthService: MySQL version
    and Redis Health Check
        HealthService->>Redis: PING
        Redis-->>HealthService: PONG
        HealthService->>Redis: Fetch version
        Redis-->>HealthService: Redis version
    end
    
    HealthService-->>HealthController: Map{status, components, timestamp}
    HealthController-->>Client: ResponseEntity (HTTP 200/503)
Loading
sequenceDiagram
    participant Client
    participant VersionController
    participant VersionService
    participant GitProperties
    participant BuildProperties
    participant TimeFormatter

    Client->>VersionController: GET /version
    VersionController->>VersionService: getVersionInfo()
    
    par Property Loading
        VersionService->>GitProperties: Load git.properties
        GitProperties-->>VersionService: Git metadata
    and Build Info
        VersionService->>BuildProperties: Load build-info.properties
        alt Properties Found
            BuildProperties-->>VersionService: Build metadata
        else Fallback
            VersionService->>BuildProperties: Load Maven properties
            BuildProperties-->>VersionService: Maven fallback data
        end
    end
    
    VersionService->>TimeFormatter: Format current time (IST)
    TimeFormatter-->>VersionService: Timestamp
    
    VersionService-->>VersionController: Map{git, build, timestamp}
    VersionController-->>Client: HTTP 200 + Version JSON
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 hops with delight
Git commits hide in properties so bright,
Health checks and versions bloom in the light,
MySQL and Redis now dance through the night,
The filter skips past with a Swift little might—
Our burrow's metabolism shines ever right! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 3
❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR implements health and version monitoring endpoints, but the linked issue #102 requests only a version bump from 3.7.0 to 3.10.0. The PR does not demonstrate fulfillment of this specific requirement. Update pom.xml to set the project version from 3.7.0 to 3.10.0, or clarify if version monitoring endpoints satisfy the version bump requirement.
Out of Scope Changes check ⚠️ Warning The PR introduces health and version monitoring endpoints with controllers, services, and Maven plugins, which appear beyond the scope of issue #102's simple version bump requirement (3.7.0 to 3.10.0). Verify whether the expanded scope aligns with project goals or clarify if these features were intentionally added beyond the original issue requirements.
Docstring Coverage ⚠️ Warning Docstring coverage is 13.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(flw-api): implement /health and /version monitoring endpoints' clearly and concisely summarizes the main changes—adding two new REST endpoints for health and version monitoring.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Suraj-kumar00
Copy link
Contributor Author

Hi @drtechie, @vanitha1822, and @vishwab1
Please review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C4GT Community]: Implement /health and /version Endpoints Across All API Repositories

1 participant