We’re building an admin-only module in our BI platform so we can safely plug in customers’ databases and pull data for analysis. Admins need to add, view, update, and delete connection records, and quickly run a “test connection” to confirm credentials work before using them. Security is non‑negotiable: host, port, username, and password must be encrypted before we store anything, and sensitive fields should never be exposed in responses.

Deliver a Micronaut REST API backed by PostgreSQL. Core endpoints should cover CRUD for data sources (e.g., POST /v1/datasources, GET /v1/datasources/{id}, DELETE /v1/datasources/{id}, and an Update endpoint such as PUT /v1/datasources/{id}). Provide a dedicated POST /v1/datasources/{id}/test endpoint that opens a short‑lived connection to the target database and returns a simple success/failure result with an error message when applicable, without leaking credentials.

Access is restricted via JWT bearer auth (admin only). Use 422 for invalid configurations and 400 when a test attempt fails. When reading or listing, mask or omit sensitive fields like passwords.