1- # Aegion — Clinical Drug Safety Engine
1+ <!-- # Aegion — Clinical Drug Safety Engine
22
33Aegion is a clinical drug safety engine designed to detect potentially hazardous prescription drug interactions using a hybrid AI + rule-based architecture.
44
@@ -21,7 +21,7 @@ Built using local LLM inference with Ollama and Qwen 2.5, the system provides ex
2121
2222## Demo Video
2323
24- [ ![ Watch Demo] ( assets/screenshots/dashboard.png )] ( assets/videos/Aegion-recording.mp4 )
24+ [](https://youtu.be/zqVsmtyI1NQ )
2525
2626---
2727
@@ -277,4 +277,307 @@ Building Aegion involved practical engineering challenges across:
277277
278278<div align="center">
279279 <h2>Thank You</h2>
280- </div >
280+ </div> -->
281+
282+ # Aegion — Clinical Drug Safety Engine
283+
284+ Aegion is a clinical drug safety engine designed to detect potentially hazardous prescription drug interactions using a hybrid AI + rule-based architecture.
285+
286+ Built using local LLM inference with Ollama and Qwen 2.5, the system provides explainable clinical risk analysis, deterministic fallback validation, severity classification, and privacy-first on-premise deployment for healthcare environments.
287+
288+ ---
289+
290+ ## Tech Stack
291+
292+ ![ Python] ( https://img.shields.io/badge/Python-3776AB?style=for-the-badge&logo=python&logoColor=white )
293+ ![ FastAPI] ( https://img.shields.io/badge/FastAPI-009688?style=for-the-badge&logo=fastapi&logoColor=white )
294+ ![ React] ( https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB )
295+ ![ Vite] ( https://img.shields.io/badge/Vite-646CFF?style=for-the-badge&logo=vite&logoColor=white )
296+ ![ TailwindCSS] ( https://img.shields.io/badge/Tailwind_CSS-06B6D4?style=for-the-badge&logo=tailwindcss&logoColor=white )
297+ ![ SQLAlchemy] ( https://img.shields.io/badge/SQLAlchemy-D71F00?style=for-the-badge&logo=sqlalchemy&logoColor=white )
298+ ![ SQLite] ( https://img.shields.io/badge/SQLite-003B57?style=for-the-badge&logo=sqlite&logoColor=white )
299+ ![ Ollama] ( https://img.shields.io/badge/Ollama-000000?style=for-the-badge )
300+ ![ Qwen2.5] ( https://img.shields.io/badge/Qwen_2.5-7A42F4?style=for-the-badge )
301+ ![ Pydantic] ( https://img.shields.io/badge/Pydantic-E92063?style=for-the-badge&logo=pydantic&logoColor=white )
302+
303+ ---
304+
305+ ## Highlights
306+
307+ - Hybrid AI + deterministic rule-based interaction analysis
308+ - Fully local LLM inference using Ollama + Qwen 2.5
309+ - Privacy-first on-premise deployment architecture
310+ - Explainable clinical reasoning with severity classification
311+ - Intelligent fallback system for inference failures
312+ - TTL-based caching with ~ 95% faster repeated analyses
313+ - Unified FastAPI + React deployment
314+ - Operational observability with latency and cache tracking
315+
316+ ---
317+
318+ ## Demo Video
319+
320+ [ ![ Watch Demo] ( assets/screenshots/dashboard.png )] ( https://youtu.be/zqVsmtyI1NQ )
321+
322+ ---
323+
324+ # Why Aegion?
325+
326+ Modern AI healthcare systems often depend heavily on cloud inference and opaque model outputs, creating challenges around:
327+
328+ - patient data privacy
329+ - explainability
330+ - operational reliability
331+ - deterministic safety validation
332+
333+ Aegion explores a safer systems-oriented approach by combining:
334+
335+ - local LLM inference
336+ - rule-based validation
337+ - explainable interaction analysis
338+ - resilient fallback mechanisms
339+
340+ Instead of behaving like a generic AI chatbot, Aegion functions as an operational clinical safety engine.
341+
342+ ---
343+
344+ # Core Features
345+
346+ ### Hybrid AI + Rule-Based Analysis
347+
348+ Combines deterministic interaction rules with LLM-powered clinical reasoning.
349+
350+ ### Fully Local Inference
351+
352+ Runs entirely using Ollama + Qwen 2.5 without external API dependency.
353+
354+ ### Deterministic Fallback Engine
355+
356+ Automatically switches to structured rule validation when inference fails.
357+
358+ ### Explainable Clinical Output
359+
360+ Provides:
361+ - interaction mechanism
362+ - clinical impact
363+ - medical recommendations
364+ - monitoring guidance
365+
366+ instead of opaque AI responses.
367+
368+ ### Operational Observability
369+
370+ Tracks:
371+ - inference latency
372+ - cache hit/miss status
373+ - fallback usage
374+ - risk distribution
375+ - recent prescription analyses
376+
377+ ### Unified Deployment
378+
379+ Frontend and backend are integrated into a single FastAPI application for simplified deployment.
380+
381+ ---
382+
383+ # System Workflow
384+
385+ ``` text
386+ Prescription Input
387+ ↓
388+ Cache Lookup
389+ ↓
390+ Rule-Based Interaction Engine
391+ ↓
392+ Local LLM Clinical Reasoning
393+ ↓
394+ Severity Classification
395+ ↓
396+ Database Logging
397+ ↓
398+ Clinical Safety Response
399+ ```
400+
401+ ---
402+
403+ # Architecture Highlights
404+
405+ ## Local LLM Inference
406+
407+ Aegion uses Ollama with Qwen 2.5 to perform fully local inference.
408+
409+ ### Model Selection Rationale
410+
411+ A generalized LLM (Qwen 2.5) was intentionally chosen over domain-specific medical LLMs after extensive testing.
412+
413+ Generalized models demonstrated:
414+ - better adherence to strict system prompts
415+ - more reliable JSON formatting
416+ - fewer hallucinations
417+ - improved structured output consistency
418+
419+ compared to medically fine-tuned models that often over-generated responses or deviated from strict operational constraints.
420+
421+ This enables:
422+ - zero cloud dependency
423+ - offline capability
424+ - reduced privacy risk
425+ - safer structured inference workflows
426+
427+ ---
428+
429+ ## Deterministic Safety Layer
430+
431+ The system does not rely entirely on generative AI.
432+
433+ A deterministic fallback interaction engine independently validates known unsafe drug combinations using structured interaction rules.
434+
435+ This improves:
436+ - reliability
437+ - explainability
438+ - operational resilience
439+ - failure recovery
440+
441+ ---
442+
443+ ## Performance Optimization
444+
445+ A TTL-based caching layer stores previous prescription analyses to reduce repeated inference latency.
446+
447+ Repeated interaction checks can return responses approximately 95% faster.
448+
449+ ---
450+
451+ ## Database Abstraction
452+
453+ The persistence layer uses SQLAlchemy ORM, allowing easy migration from SQLite to PostgreSQL without major architectural changes.
454+
455+ ---
456+
457+ # Dashboard Capabilities
458+
459+ The Aegion dashboard provides:
460+
461+ - prescription analysis
462+ - interaction severity visualization
463+ - latency monitoring
464+ - cache observability
465+ - inference source tracking
466+ - recent clinical checks
467+ - fallback system visibility
468+
469+ The interface was intentionally designed to resemble operational healthcare systems rather than generic AI chat interfaces.
470+
471+ ---
472+
473+ # Project Structure
474+
475+ ``` text
476+ backend/
477+ ├── data/
478+ │ └── fallback_interactions.json
479+ ├── prompts/
480+ │ └── system_prompt.txt
481+ ├── test/
482+ ├── cache.py
483+ ├── database.py
484+ ├── db_models.py
485+ ├── engine.py
486+ ├── main.py
487+ └── requirements.txt
488+
489+ frontend/
490+ ├── api/
491+ ├── components/
492+ ├── constants/
493+ ├── context/
494+ ├── hooks/
495+ └── App.jsx
496+ ```
497+
498+ ---
499+
500+ # Running Aegion Locally
501+
502+ ## Clone the Repository
503+
504+ ``` bash
505+ git clone https://github.com/your-username/aegion.git
506+ cd aegion
507+ ```
508+
509+ ---
510+
511+ ## Install Backend Dependencies
512+
513+ ``` bash
514+ cd backend
515+ pip install -r requirements.txt
516+ ```
517+
518+ ---
519+
520+ ## Install Ollama
521+
522+ Download and install Ollama:
523+
524+ https://ollama.com
525+
526+ ---
527+
528+ ## Pull the Qwen Model
529+
530+ ``` bash
531+ ollama pull qwen2.5
532+ ```
533+
534+ ---
535+
536+ ## Run the Application
537+
538+ ``` bash
539+ uvicorn main:app --reload
540+ ```
541+
542+ The frontend is integrated directly into the FastAPI application, enabling single-command local deployment.
543+
544+ ---
545+
546+ # Screenshots & Media
547+
548+ ## Dashboard Overview
549+
550+ ![ Dashboard] ( assets/screenshots/dashboard.png )
551+
552+ ---
553+
554+ ## Clinical Interaction Analysis
555+
556+ ![ Analysis Modal] ( assets/screenshots/analysis.png )
557+
558+ ---
559+
560+ # Engineering Learnings
561+
562+ Building Aegion involved practical engineering challenges across:
563+
564+ - AI orchestration
565+ - local LLM inference
566+ - backend architecture
567+ - healthcare privacy constraints
568+ - caching optimization
569+ - explainable AI workflows
570+ - API design
571+ - reliability engineering
572+
573+ ---
574+
575+ # Future Improvements
576+
577+ - PostgreSQL migration
578+ - Dockerized deployment
579+ - Expanded clinical interaction datasets
580+ - Async inference optimization
581+ - EHR integration
582+ - Role-based authentication
583+ - Enhanced audit logging
0 commit comments