From e8804d67dff6da71861cd7e417cb2326e91846f0 Mon Sep 17 00:00:00 2001 From: Buay Kun Gach Date: Tue, 17 Mar 2026 10:30:10 +0300 Subject: [PATCH 1/3] chore: add .gitignore for python project Add comprehensive .gitignore covering: - Python bytecode and cache files - Virtual environments - Environment variables - Database files - IDE configurations - Testing artifacts --- .gitignore | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..43d6028 --- /dev/null +++ b/.gitignore @@ -0,0 +1,61 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Virtual environments +.venv/ +venv/ +ENV/ +env/ + +# Environment variables +.env +.env.local + +# Database files +*.db +*.sqlite +*.sqlite3 + +# IDE files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# Testing +.pytest_cache/ +.coverage +htmlcov/ + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Logs +*.log From 83a9ded098a4639d24dbe5b4507ddd9769fc7f0d Mon Sep 17 00:00:00 2001 From: Buay Kun Gach Date: Tue, 17 Mar 2026 10:38:04 +0300 Subject: [PATCH 2/3] refract: version health endpoint under /api/v1/ --- backend/app/main.py | 18 +++++++++++++++++- backend/tests/api/test_health.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 backend/tests/api/test_health.py diff --git a/backend/app/main.py b/backend/app/main.py index 6a33ed0..f2ac099 100644 --- a/backend/app/main.py +++ b/backend/app/main.py @@ -7,6 +7,7 @@ """ from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from .core.config import settings from .core.logging import configure_logging @@ -56,6 +57,15 @@ def create_app() -> FastAPI: errors.register_exception_handlers(app) + # Configure CORS for frontend integration + app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + app.include_router(projects_router) app.include_router(resources_router) app.include_router(locations_router) @@ -65,7 +75,13 @@ def create_app() -> FastAPI: app.include_router(alert_router) app.include_router(auth_router) - @app.get("/health", tags=["health"]) + @app.get("/", tags=["root"]) + async def root_redirect(): + """Redirect root URL to API documentation.""" + from fastapi.responses import RedirectResponse + return RedirectResponse(url="/docs") + + @app.get("/api/v1/health", tags=["health"]) async def healthcheck() -> dict[str, str]: """ Provide a basic health indicator confirming application availability. diff --git a/backend/tests/api/test_health.py b/backend/tests/api/test_health.py new file mode 100644 index 0000000..8fdfe6f --- /dev/null +++ b/backend/tests/api/test_health.py @@ -0,0 +1,17 @@ +"""Tests for the health check endpoint.""" + +from fastapi.testclient import TestClient + + +def test_health_check_returns_ok(client: TestClient) -> None: + """Health endpoint should return status ok.""" + response = client.get("/api/v1/health") + assert response.status_code == 200 + assert response.json() == {"status": "ok"} + + +def test_root_redirects_to_docs(client: TestClient) -> None: + """Root URL should redirect to API documentation.""" + response = client.get("/", follow_redirects=False) + assert response.status_code == 307 + assert response.headers["location"] == "/docs" From 7a52f7b6cd084c25177ecf5a3b75506a30a479f0 Mon Sep 17 00:00:00 2001 From: Buay Kun Gach Date: Tue, 17 Mar 2026 10:57:30 +0300 Subject: [PATCH 3/3] docs: add CI status badge to README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b0217c3..ab4004e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # LifeLine-ICT +![CI](https://github.com/buayism/LifeLine-ICT/actions/workflows/ci.yml/badge.svg) + ## Project Summary LifeLine-ICT is a digital infrastructure management platform that supports the