Skip to content

KLAR-T1: Add /api/health endpoint with version info - #22

Open
aircode610 wants to merge 1 commit into
mainfrom
task/klar-t1
Open

aircode610 wants to merge 1 commit into
mainfrom
task/klar-t1

Conversation

@aircode610

Copy link
Copy Markdown
Owner

Summary

Implements health check endpoint for Klar backend per KLAR-T1.

Changes:

  • backend/app/config.py — Add VERSION="0.1.0" constant
  • backend/app/routers/health.py — New endpoint at GET /api/health, checks SQLite connectivity with SELECT 1
  • backend/app/main.py — Wire health router (import + include_router call)
  • backend/tests/test_health.py — Tests for happy path and db failure cases

No breaking changes:

  • Existing GET /health endpoint remains untouched
  • requirements.txt unchanged (reuses SQLModel Session engine)
  • All 23 backend tests passing

Acceptance criteria:
✅ SQLModel engine used for health check (aiosqlite NOT added)
✅ VERSION constant in config.py
✅ New /api/health route independent of old /health
✅ Router wired into main.py
✅ Tests cover success and failure paths

Review: APPROVED | Gate: PASS (compileall)

Reviewed the pre-existing uncommitted 3-file diff against PLAN.md/CRITERIA.md
and adopted it as-is after verification:

- backend/app/config.py: adds module-level VERSION = "0.1.0" constant
  (avoids circular import between main.py and the new health router)
- backend/app/main.py: imports VERSION from config, passes it to
  FastAPI(version=VERSION), registers health.router — existing root
  GET /health handler is byte-for-byte untouched
- backend/app/routers/health.py (new): GET /api/health returns
  {status, version, db}, with db derived from a real SELECT 1 against the
  existing SQLModel engine (no new aiosqlite dependency), wrapped in
  try/except -> "ok"/"fail"
- backend/tests/test_health.py (new): covers the 200/shape happy path and
  the db:"fail" path via a monkeypatched Session

Verified: full backend pytest suite (23 tests) passes, gate command
(python3 -m compileall -q ai backend) passes, and a live uvicorn smoke test
confirms GET /api/health -> 200 {status:ok,version:0.1.0,db:ok} while
GET /health (root) is unchanged.
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.

1 participant