Health Risk API (PJCT01) A FastAPI-powered health risk assessment API that accepts patient vitals and lifestyle data, then returns a computed health risk analysis. Built with Python, SQLAlchemy, Pydantic, and PostgreSQL (Neon). Deployed on Render. Live Docs: https://pjct01.onrender.com/docs — Table of Contents Overview Tech Stack Setup & Installation Environment Variables API Endpoints — Overview PJCT01 exposes a single intelligent endpoint that accepts a patient’s medical profile — age, sex, BMI inputs, vitals, smoking habits, and existing conditions — and returns a structured health risk response. Designed as a backend service to be consumed by health-facing frontends or other APIs. — Tech Stack Layer Technology Framework FastAPI ORM SQLAlchemy Validation Pydantic Database PostgreSQL (Neon) Runtime Python 3.11+ Deployment Render — Setup & Installation
git clone https://github.com/techbyFEMI/pjct01.git
cd pjct01
python -m venv venv
source venv/bin/activate # Linux/macOS
venv\Scripts\activate # Windows
pip install -r requirements.txt
.env file in the root directory (see Environment Variables below).uvicorn app:app --reload
The API will be available at http://localhost:8000.
Interactive docs at http://localhost:8000/docs.
—
Environment Variables
Create a .env file in the project root:
postgreSQL=postgresql+asyncpg://user:password@host/dbname
The database URL variable is named
postgreSQL— keep this exact casing in your deployment config.API Endpoints
POST /medicinfoeptAccepts a patient’s health profile and returns a risk assessment. Request Body —application/json{ "age": 28, "sex": "male", "weight": 75.0, "height": 1.78, "smokeRate": "never", "bloodPressure": 120.0, "heartRate": 72.0, "bodyTemperature": 36.6, "existingConditions": ["asthma"] }Field Reference Field Type Required Notes
ageinteger ✓ Max 120sexmale/female✓ Enumweightfloat ✓ In kilogramsheightfloat ✓ In metressmokeRatestring (enum) ✓frequently,moderate, orneverbloodPressurefloat ✓ Systolic, in mmHgheartRatefloat ✓ In BPMbodyTemperaturefloat ✓ In °CexistingConditionsarray of strings ✓ Pass empty array[]if none Response —200 OK{ "risk_level": "...", "details": "..." }Error Response —
422 Unprocessable EntityReturned when required fields are missing or fail validation.{ "detail": [ { "loc": ["body", "age"], "msg": "field required", "type": "value_error.missing" } ] }
Notes Render free-tier instances spin down after inactivity — the first request may take 30–60 seconds to cold-start. All fields in the request body are required; there are no optional fields.
existingConditionsaccepts any string values (e.g."diabetes","hypertension","asthma"). Pass an empty array[]if the patient has none.