Imported from Adriandecode/HIPAA-Compliant-AI-Healthcare-System (
backend/AGENTS.md). Install upstream withnpx skills add Adriandecode/HIPAA-Compliant-AI-Healthcare-System --skill backend. Copyright stays with the author.
AGENTS.md - Backend
Scoped rules for
backend/. Read rootAGENTS.mdfirst.
Key Module Ownership
For a deep reference of all 50+ backend modules, check CONTEXT.md. Here is a high-level summary:
- AI Layer:
core_ai.py(Central entry point for all LLM/Ollama inference),prompt_registry.py(Prompt templates),agent.py(Supervisor agent),chat_context.py(RAG builder). - Data & DB:
models.py(SQLAlchemy models),database.py(Session engine),schemas/(Pydantic schemas),rag.py(Vector store). - ML & Predictions:
prediction.py(Initializes and runs disease prediction models diabetes/heart/liver/kidney/lungs),explainability.py(SHAP). - Hospital Workflows:
hospital_operations.py,monitoring.py,diagnostics.py,pharmacy.py,billing.py,discharge.py,nursing.py,care_events.py. - Interoperability & Compliance:
abdm.py(India ABDM API),fhir.py(FHIR R4 helpers),interoperability.py(Bundle exports),audit.py(PHI-safe auditing).
Rules
- AI Provider Abstraction: Never import
google.generativeaiorhttpxfor AI calls outsidecore_ai.py. Usecore_ai.generate(),core_ai.chat(),core_ai.chat_stream(),core_ai.embed_text(), or the relevantcore_aiprovider helper. - Prompt Management: Never inline system prompts in route handlers. Register them in
prompt_registry.pyand retrieve viaget_prompt("name"). - Database Sessions: Route handlers must use
backend.database.get_db, usually asDepends(database.get_db). Never createSessionLocal()manually in route handlers. - Schema Changes: Update
models.py,schemas.py, andmain.pymigration/startup logic together when changing persisted fields. - Error Handling: Log errors with
logger.error(), never expose stack traces to clients. Return structured{"detail": "..."}errors. - HIPAA Awareness: Health data (predictions, records, chat logs) must be scoped to
current_user.id. Never return another user's data. - ML Models: Model files (
*.pkl) currently live inbackend/andmodels/. Loading is centralized inprediction.initialize_models().
Recommended Tests
python -m pytest tests/ -v -k "test_chat or test_auth or test_prediction"