From 03532fdbf95e3c4842a7fb7d54d2f3829ebb7f37 Mon Sep 17 00:00:00 2001 From: Preetham123555 Date: Mon, 1 Jun 2026 16:01:01 +0530 Subject: [PATCH 1/2] feat: add comprehensive API documentation for FastAPI backend --- backend/main.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/backend/main.py b/backend/main.py index e9288d1..ee2b859 100644 --- a/backend/main.py +++ b/backend/main.py @@ -3,9 +3,28 @@ import ai_model import os +from pydantic import BaseModel +from typing import List, Optional + +class Observation(BaseModel): + label: str + value: str + +class AnalysisResponse(BaseModel): + filename: str + diagnosis: str + confidence: float + risk_level: str + heatmap: Optional[str] = None + observations: List[Observation] + os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" -app = FastAPI() +app = FastAPI( + title="Healthway Diagnostics - Neural Retina API", + version="1.0.0", + description="EfficientNet-B0 powered Diabetic Retinopathy detection with Grad-CAM explainability." +) app.add_middleware( CORSMiddleware, allow_origins=["*"], @@ -14,7 +33,15 @@ allow_headers=["*"], ) -@app.post("/analyze") +@app.post( + "/analyze", + summary="Analyze a retinal fundus image", + response_model=AnalysisResponse, + responses={ + 400: {"description": "Invalid or non-retinal image"}, + 500: {"description": "Model inference error"} + } +) async def analyze_image(file: UploadFile = File(...)): image_bytes = await file.read() From d4c2b91c57f7c2d60e4a0bfed6b51e41e69637a1 Mon Sep 17 00:00:00 2001 From: Preetham123555 Date: Tue, 2 Jun 2026 16:56:00 +0530 Subject: [PATCH 2/2] feat: add environment variable management using python-dotenv --- backend/.env.example | 1 + backend/main.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 backend/.env.example diff --git a/backend/.env.example b/backend/.env.example new file mode 100644 index 0000000..159b8bb --- /dev/null +++ b/backend/.env.example @@ -0,0 +1 @@ +KMP_DUPLICATE_LIB_OK=TRUE diff --git a/backend/main.py b/backend/main.py index ee2b859..c97ac2b 100644 --- a/backend/main.py +++ b/backend/main.py @@ -5,6 +5,8 @@ from pydantic import BaseModel from typing import List, Optional +from dotenv import load_dotenv +load_dotenv() class Observation(BaseModel): label: str @@ -18,7 +20,7 @@ class AnalysisResponse(BaseModel): heatmap: Optional[str] = None observations: List[Observation] -os.environ["KMP_DUPLICATE_LIB_OK"] = "TRUE" + app = FastAPI( title="Healthway Diagnostics - Neural Retina API",