{"id":50928359,"url":"https://github.com/persteenolsen/fastapi-jwt-auth-ml-two","last_synced_at":"2026-06-17T01:31:10.088Z","repository":{"id":352233661,"uuid":"1214373029","full_name":"persteenolsen/fastapi-jwt-auth-ml-two","owner":"persteenolsen","description":"Python FastAPI with JWT Auth serving ML for House Price Prediction (v2)","archived":false,"fork":false,"pushed_at":"2026-05-04T09:25:44.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-04T11:28:45.165Z","etag":null,"topics":["fastapi","jwt","machine-learning","python"],"latest_commit_sha":null,"homepage":"https://fastapi-jwt-auth-ml-two.vercel.app/docs","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/persteenolsen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-18T13:40:39.000Z","updated_at":"2026-05-04T09:25:47.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/persteenolsen/fastapi-jwt-auth-ml-two","commit_stats":null,"previous_names":["persteenolsen/fastapi-jwt-auth-ml-two"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/persteenolsen/fastapi-jwt-auth-ml-two","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/persteenolsen%2Ffastapi-jwt-auth-ml-two","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/persteenolsen%2Ffastapi-jwt-auth-ml-two/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/persteenolsen%2Ffastapi-jwt-auth-ml-two/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/persteenolsen%2Ffastapi-jwt-auth-ml-two/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/persteenolsen","download_url":"https://codeload.github.com/persteenolsen/fastapi-jwt-auth-ml-two/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/persteenolsen%2Ffastapi-jwt-auth-ml-two/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34430688,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastapi","jwt","machine-learning","python"],"created_at":"2026-06-17T01:31:09.280Z","updated_at":"2026-06-17T01:31:10.060Z","avatar_url":"https://github.com/persteenolsen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🏠 v2 - House Price Prediction API (FastAPI + JWT + ML)\n\nLast updated:\n\n- 20-04-2026\n\nA simple but production-style Machine Learning API built with FastAPI, JWT authentication, and a scikit-learn pipeline model.\n\nThis project demonstrates how to move from a basic ML script to a full backend service.\n\n---\n\n## 🚀 Features\n\n- JWT authentication\n- Machine Learning model (scikit-learn pipeline)\n- Lazy-loaded model for performance\n- Pydantic v2 request validation\n- FastAPI REST API\n- Synthetic housing dataset generator\n\n---\n\n## 📁 Project Structure\n\napp.py → FastAPI backend (auth + prediction API)  \ntrain.py → Model training script  \ngenerate_data.py → Dataset generator (optional)  \nhousing_v2.csv → Generated dataset  \nmodel.pkl → Trained ML model  \nrequirements.txt → Dependencies  \n.env → Environment variables  \n\n---\n\n## ⚙️ Installation\n\n### 1. Clone project\n\ngit clone \u003cyour-repo-url\u003e  \ncd \u003cyour-project-folder\u003e  \n\n---\n\n### 2. Create virtual environment\n\npython -m venv venv  \n\nActivate virtual environment:\n\nWindows:\nvenv\\Scripts\\activate  \n\nMac/Linux:\nsource venv/bin/activate  \n\n---\n\n### 3. Install dependencies\n\npip install -r requirements.txt  \n\n---\n\n## 🔐 Environment Variables (.env)\n\nCreate a file named `.env`:\n\nSECRET_KEY=your_secret_key_here  \nFAKE_USERNAME=admin  \nFAKE_PASSWORD=1234  \n\n---\n\n## 🧠 Train the Model\n\n(Optional) Generate dataset:\n\npython generate_data.py  \n\nTrain model:\n\npython train.py  \n\nThis creates:\n\nmodel.pkl  \n\n---\n\n## 🚀 Run the API\n\npython app.py  \n\nAPI runs at:\n\nhttp://127.0.0.1:8000  \n\n---\n\n## 📡 API Endpoints\n\n### 🔐 Login\n\nPOST /login  \n\nRequest:\n{\n  \"username\": \"admin\",\n  \"password\": \"1234\"\n}\n\nResponse:\n{\n  \"token\": \"your_jwt_token\"\n}\n\n---\n\n### 🏠 Predict House Price\n\nPOST /predict  \n\nHeader:\nAuthorization: Bearer \u003ctoken\u003e  \n\nRequest:\n{\n  \"size\": 140,\n  \"rooms\": 4,\n  \"year_built\": 2005,\n  \"location\": \"suburb\",\n  \"condition\": \"good\"\n}\n\nResponse:\n{\n  \"user\": \"admin\",\n  \"input\": {\n    \"size\": 140,\n    \"rooms\": 4,\n    \"year_built\": 2005,\n    \"location\": \"suburb\",\n    \"condition\": \"good\"\n  },\n  \"predicted_price\": 312450.55\n}\n\n---\n\n## 🧠 Tech Stack\n\n- FastAPI\n- scikit-learn\n- pandas\n- PyJWT\n- Uvicorn\n- Pydantic v2\n\n---\n\n## 📈 What this project demonstrates\n\n- ML pipelines (not just scripts)\n- REST API design for ML systems\n- JWT authentication\n- Model deployment basics\n- Data preprocessing with ColumnTransformer\n\n---\n\n## 🚀 Next improvements\n\n- Add PostgreSQL for storing predictions\n- Real user authentication system\n- Model versioning\n- Docker deployment\n- Logging + monitoring\n\n---\n\n## 👨‍💻 Author\n\nBuilt as a learning project for combining Machine Learning with backend engineering","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpersteenolsen%2Ffastapi-jwt-auth-ml-two","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpersteenolsen%2Ffastapi-jwt-auth-ml-two","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpersteenolsen%2Ffastapi-jwt-auth-ml-two/lists"}