<<<<<<< HEAD MediFlow is an AI-powered Tuberculosis (TB) diagnostic platform that uses Machine Learning for triage and blockchain-backed cryptographic proofs for accountability and an immutable audit trail.
Healthcare systems increasingly rely on AI, but many deployments suffer from an “AI black box” problem and weak auditability. MediFlow closes the accountability gap by hashing and recording decision artifacts so that predictions and validations can be verified later without exposing sensitive patient data.
- Hashing (SHA-256): Creates tamper-evident fingerprints of predictions, model versions, and related metadata.
- Digital signatures (HMAC / asymmetric signatures): Allows actors (system/clinician) to sign validations so actions are attributable and non-repudiable.
- Blockchain / distributed ledger: Stores the audit trail as append-only records (Solidity/EVM in this repo).
app/
api/ # FastAPI endpoints
core/ # Configuration
models/ # Pydantic schemas
resources/ # ML model weights
services/ # Business logic (diagnosis & blockchain)
utils/ # Hashing & security helpers
main.py # FastAPI app entrypoint
blockchain/ # Foundry (Solidity) project
scripts/ # Utility scripts (data generation, training)
Frontend/ # Vite/React frontend
======= MediFlow is an AI-powered Tuberculosis (TB) diagnostic platform that leverages Machine Learning for triage and Blockchain for accountability and an immutable audit trail.
- AI Triage: Uses a hybrid engine (Rule-Based + Random Forest) to assess TB risk based on clinical symptoms.
- Blockchain Accountability: Records every AI prediction and doctor validation on an immutable ledger (Solidity/Ethereum).
- Privacy First: Only non-reversible hashes of patient data are stored on-chain, ensuring patient privacy while maintaining a complete audit trail.
- Modular Architecture: Cleanly separated into API, Services, and Blockchain layers.
ai-backend/
├── app/
│ ├── api/ # FastAPI Endpoints
│ ├── core/ # Configuration
│ ├── models/ # Pydantic Schemas
│ ├── services/ # Business Logic (Diagnosis & Blockchain)
│ ├── utils/ # Hashing & Security
│ └── resources/ # ML Model weights
├── blockchain/ # Foundry (Solidity) project
│ ├── src/ # Smart Contracts
│ └── forge build/ # Compiled artifacts
├── scripts/ # Utility scripts (Data gen, Training)
├── tests/ # Test suite
└── README.md
a1b6ff2f6a05662b15fe7db073692ef0643c0b24
- Python 3.10+ <<<<<<< HEAD
- Foundry (optional, for Solidity): https://book.getfoundry.sh/getting-started/installation
-
Install dependencies:
pip install -r requirements.txt
=======
- Foundry (for Solidity)
- Install dependencies:
pip install fastapi uvicorn joblib pandas numpy web3 pydantic
a1b6ff2f6a05662b15fe7db073692ef0643c0b24
2. Run the API:
```bash
python -m app.main
<<<<<<< HEAD
- Compile contracts:
=======
- Compile the contracts:
a1b6ff2f6a05662b15fe7db073692ef0643c0b24
cd blockchain
forge build<<<<<<< HEAD 2. (Optional) Deploy locally with Anvil:
anvilThe triage engine is hybrid:
- Rule-based guardrails (WHO-style red flags)
- Random Forest model for probabilistic risk classification
- AI generates a prediction.
- A SHA-256 hash is computed for the decision payload.
- The hash (and an anonymized patient identifier hash) is recorded on-chain.
- A clinician validates/overrides the decision and the validation is linked to the original record.
- Ombati Benson — Machine Learning Engineer
- Kelvin Kipchumba — Full Stack Developer
- Denzel William — Blockchain Engineer
- Kihiu James — Machine Learning Engineer
- David Oyugi — Digital Solutions Analyst
- Ian Kariuki — Healthcare Systems Lead =======
- (Optional) Deploy to a local node (Anvil):
# In a separate terminal anvil # Deploy forge create --rpc-url http://localhost:8545 --private-key <YOUR_PRIVATE_KEY> src/MediFlow.sol:MediFlow
The hybrid diagnostic engine combines:
- Rule-Based Tier: Implements WHO clinical guidelines for immediate red-flag detection (e.g., Hemoptysis).
- ML Tier: A Random Forest model trained on synthetic/real TB data to identify complex symptom patterns.
Every diagnostic decision follows this flow:
- AI generates a prediction.
- A unique SHA256 hash of the prediction is created.
- The hash and an anonymized patient ID hash are recorded on the blockchain.
- A doctor reviews the case and signs their decision using an HMAC-based digital signature.
- The doctor's validation is linked to the original AI prediction on-chain.
a1b6ff2f6a05662b15fe7db073692ef0643c0b24