This repository contains an autonomous, intelligent multi-agent pharmacy system built entirely on the 3-Layer Agent Architecture (Directives, Orchestrator, Execution).
- Agentic Chain of Thought (Observability): Integrated with LangGraph and LangSmith. Provides full trace logs proving the Supervisor checked Inventory AND Prescriptions before fulfilling orders.
- Conversational Ordering (STT/TTS): A React frontend that uses Web Speech API to capture audio, passes it to the FastAPI LangGraph backend, and speaks the response.
- Safety Guardrails: Strict Python deterministic tools that check MongoDB stock limits and Mock prescription limits.
- Proactive Refill Intelligence: A CRON background task that mathematically predicts when patients will run out of chronic medications based on sandbox purchase history.
- No-CMS Sandbox: Entirely custom FastAPI + MongoDB backend, replacing SQLite for superior async performance per requirements.
- AI/Orchestration: LangGraph, LangChain,
gpt-4o-mini(or local Ollama fallback) - Backend: Python, FastAPI, Motor (Async MongoDB), APScheduler (for refill crons).
- Frontend: React (Vite), TailwindCSS,
lucide-react. - Database: MongoDB
- Observability: LangSmith
- Ensure MongoDB is running locally on port
27017. - Open
.envand populate yourOPENAI_API_KEY(or swap to localChatOllamainagent_supervisor.py). - (Optional) Populate
LANGCHAIN_API_KEYin.envto view trace chains live in the browser.
- Navigate to the
backend/directory (or use the rootvenv). - Run data load (assuming you place mock excels in
/data):python execution/data_loader.py - Boot the server:
uvicorn backend.main:app --reload --port 8000
- Open a second terminal to
/frontend npm installnpm run dev- Access the UI at
http://localhost:5173.- Click "Test Chatbot" to place voice orders.
- Click "Admin View" to see live inventory depletion and CRON-generated refill alerts.
When you say "I need 20 pills of Paracetamol":
- Orchestrator (LangGraph) reads the NLP and checks
directives/agent_supervisor_sop.md. - It invokes the LangChain Tool
check_inventorywhich fires an HTTP request to our determinist API. - It invokes
check_prescriptionbased ondirectives/prescription_validation.md. - If BOTH pass, it invokes
execute_order, which writes to MongoDB. - The CRON job in
predict_refills.pycontinuously scans the new DB state to forecast future shortages.
Give a Star 🌟 to this repository!!