{"id":31886915,"url":"https://github.com/cnoret/real-time-fraud-detection","last_synced_at":"2026-07-22T15:32:59.329Z","repository":{"id":315897752,"uuid":"1060795185","full_name":"cnoret/real-time-fraud-detection","owner":"cnoret","description":"End-to-end real-time fraud detection pipeline with Airflow, Hugging Face, Neon (Postgres), Streamlit dashboard, and MLflow tracking.","archived":false,"fork":false,"pushed_at":"2025-09-21T12:41:57.000Z","size":20444,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-20T23:43:38.677Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cnoret.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2025-09-20T15:58:01.000Z","updated_at":"2025-09-21T12:42:00.000Z","dependencies_parsed_at":"2025-09-21T14:43:17.487Z","dependency_job_id":null,"html_url":"https://github.com/cnoret/real-time-fraud-detection","commit_stats":null,"previous_names":["cnoret/real-time-fraud-detection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cnoret/real-time-fraud-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnoret%2Freal-time-fraud-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnoret%2Freal-time-fraud-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnoret%2Freal-time-fraud-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnoret%2Freal-time-fraud-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cnoret","download_url":"https://codeload.github.com/cnoret/real-time-fraud-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cnoret%2Freal-time-fraud-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35768236,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-22T02:00:06.236Z","response_time":124,"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":[],"created_at":"2025-10-13T05:54:13.827Z","updated_at":"2026-07-22T15:32:59.297Z","avatar_url":"https://github.com/cnoret.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🕵️ Real-Time Fraud Detection Project\n\nEnd-to-end fraud detection pipeline with **Airflow**, **Hugging Face Spaces**, **Neon (Postgres)**, and a **Streamlit dashboard**.  \n\n---\n## ✨ Features\n\n- **Airflow DAGs**:\n  - Fetch real-time transactions (Jedha API based on Kaggle dataset.)\n  - Preprocess + send to Hugging Face model\n  - Store results in NeonDB\n- **Streamlit Dashboard**:\n  - KPIs, fraud probability trends, interactive filters\n  - Auto-refresh, CSV export\n  - Deployed on Hugging Face Spaces\n- **EDA Notebook** for dataset exploration\n- **API scripts** for serving and testing the fraud detection model\n\n---\n\n## 📂 Project Structure\n\n```\n.\n├── airflow/               # Airflow environment (docker-compose, dags, plugins, logs)\n│   ├── dags/              # DAGs (MVP, graph, etc.)\n│   ├── config/            # configs\n│   └── docker-compose.yml # Airflow local stack\n│\n├── api-deploy/            # Deployment configs for fraud API\n├── client_realtime.py     # Local client to test API\n├── dashboard/             # (Optional) dashboard assets\n├── src/\n│   └── streamlit_app.py   # Streamlit dashboard (deployed on HF)\n│\n├── notebooks/\n│   └── EDA_training.ipynb # Exploratory Data Analysis and Machine Learning\n│\n├── fraud_api.py           # Fraud detection API\n├── fraud_model.pkl        # Trained model (local storage)\n├── fraudTest.csv          # Dataset (generated)\n│\n├── requirements.txt       # Project dependencies\n├── .env                   # Secrets\n└── README.md              # Project documentation\n```\n\n\u003e ⚠️ Large dataset (EDA, Training) `fraudTest.csv` is **not pushed** to the repo.  \n\u003e You can download it from [this link](https://lead-program-assets.s3.eu-west-3.amazonaws.com/M05-Projects/fraudTest.csv).  \n\n---\n\n## 🚀 How to Run\n\n### 1. Airflow (local)\n```bash\ncd airflow\ndocker-compose up\n```\n- DAGs will appear in Airflow UI (`http://localhost:8080`)\n- Runs every 5 minutes → fetch → predict → store in Neon\n\n### 2. Streamlit Dashboard (local)\n```bash\ncd src\nstreamlit run streamlit_app.py\n```\n→ App available at `http://localhost:8501`\n\n### 3. Streamlit on Hugging Face\n- Push `streamlit_app.py` as `app.py` and `requirements.txt` to your Space\n- Add NeonDB URI as a **secret**:\n  ```\n  NEON_DB_URI=postgresql://user:password@host/db?sslmode=require\n  ```\n\n---\n\n## ⚙️ Requirements\n\nMain dependencies (see `requirements.txt`):\n```\nstreamlit\npsycopg2-binary\npandas\nstreamlit\nplotly\napache-airflow\n```\n\n---\n\n## 📊 Architecture\n\n```\nJedha API (transactions) \n   → Airflow DAG \n      → Hugging Face Space (fraud model API) \n         → NeonDB (Postgres) \n            → Streamlit dashboard (HF Space)\n```\n\n---\n\n## 🔮 Future Improvements\n\n- **Cloud Storage Archive (S3)**:  \n  Store raw + enriched transactions in S3 (JSON/Parquet) for auditing \u0026 retraining.\n- **Alerts**: Slack/Email notifications when fraud probability \u003e threshold.\n- **ML Pipeline**: Automated retraining from archived data.\n- **Scalability**: Deploy Airflow on managed service.\n- **Database connection handling**:  \n  Current Streamlit app uses a direct `psycopg2` connection.  \n  In production, it would be better to:\n  - Add automatic reconnection with retries (to avoid `connection already closed` errors when Neon suspends idle sessions).\n  - Enable TCP keepalives to reduce silent timeouts.\n  - Or switch to **SQLAlchemy** with connection pooling (`pool_pre_ping=True`) for a robust, production-ready setup.\n---\n\n## 👤 Author\n\n**Christophe Noret**  \n- [GitHub](https://github.com/cnoret)  \n- [LinkedIn](https://www.linkedin.com/in/christophenoret)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnoret%2Freal-time-fraud-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcnoret%2Freal-time-fraud-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcnoret%2Freal-time-fraud-detection/lists"}