An intelligent, autonomous pharmacy ordering system that uses AI agents to manage medicine ordering, predict refills, and automate procurement workflows. Features voice/text ordering, predictive analytics, and multi-agent automation.
- ๐ค Natural language ordering via voice or text
- ๐ Multi-language support (English, German, Arabic)
- ๐ง Intelligent medicine name parsing
- ๐ฌ Multi-turn conversation capability
- โ Prescription validation
- ๐ Automatic cart creation
- ๐ Learns from customer order history
- ๐ฎ Predicts medicine depletion dates
- ๐ Auto-suggests refills via notifications
- ๐ Visual prediction timelines
- ๐ฏ Personalized refill recommendations
- Ordering Agent: Assists customers during ordering
- Forecast Agent: Predicts refill and stock needs
- Procurement Agent: Automates purchase orders
- Safety Agent: Validates prescriptions and checks interactions
- ๐ง Email/SMS/WhatsApp notifications via Zapier
- ๐ Distributor API calls via n8n
- ๐ Webhook integration with CMS
- โก Real-time inventory updates
mediloon-pharmacy/
โโโ client/ # React frontend (JavaScript/JSX)
โ โโโ src/
โ โ โโโ pages/ # Page components
โ โ โโโ context/ # React contexts
โ โ โโโ App.jsx # Main app
โ โโโ public/ # Static assets
โโโ server/ # Node.js Express backend
โ โโโ controllers/ # Request handlers
โ โโโ routes/ # API routes
โ โโโ models/ # Database models
โ โโโ middleware/ # Auth, validation
โ โโโ sockets/ # Real-time handlers
โโโ ai-backend/ # Python FastAPI AI server
โ โโโ agents/ # LangChain agents
โ โโโ api/ # REST API endpoints
โ โโโ models/ # Database models
โ โโโ core/ # AI logic
- Framework: React 18 (Create React App)
- Language: JavaScript (JSX)
- Styling: CSS + inline styles
- UI Components: Custom components
- Voice: Web Speech API + Whisper
- State: React Context
- Real-time: Socket.io client
- Routing: React Router v6
- Framework: Node.js Express
- Language: JavaScript
- Database: MongoDB (Mongoose)
- Cache: Redis
- Authentication: JWT + bcrypt
- Real-time: Socket.io server
- Validation: express-validator
- Framework: FastAPI (Python 3.11+)
- AI/ML: LangChain, LangGraph, OpenAI GPT-4
- Database: MongoDB (Motor async driver)
- Cache: Redis
- Voice: OpenAI Whisper
- Node.js 18+ and npm
- Python 3.11+
- MongoDB 6.0+ (running locally or MongoDB Atlas)
- Redis 7.0+ (running locally)
Install and start MongoDB and Redis locally:
MongoDB:
- Download from https://www.mongodb.com/try/download/community
- Start:
mongod --dbpath <your-data-path>
Redis:
- Download from https://redis.io/download
- Start:
redis-server
cd ai-backend
# Activate virtual environment
venv\Scripts\activate # Windows
# or: source venv/bin/activate # Mac/Linux
# Install dependencies
pip install -r requirements.txt
# Set environment variables
copy .env.example .env # Windows
# or: cp .env.example .env # Mac/Linux
# Edit .env with your OpenAI API key
# Start server
python main.pyRuns on: http://localhost:8000
cd server
# Install dependencies
npm install
# Set environment variables
copy .env.example .env # Windows
# or: cp .env.example .env # Mac/Linux
# Edit .env with your JWT_SECRET and database URLs
# Start server
npm run devRuns on: http://localhost:3000
cd client
# Install dependencies
npm install
# Set environment variables
copy .env.example .env # Windows
# or: cp .env.example .env # Mac/Linux
# Start development server
npm startRuns on: http://localhost:3001
- Customer Interface: http://localhost:3001
- API Server: http://localhost:3000
- AI Backend API: http://localhost:8000/docs
- Health Checks:
- Express: http://localhost:3000/health
- FastAPI: http://localhost:8000/health
# Database
MONGODB_URI=mongodb://localhost:27017/mediloon
REDIS_URL=redis://localhost:6379
# AI/ML
OPENAI_API_KEY=your_openai_api_key
# Security
JWT_SECRET=your_jwt_secret_keyNODE_ENV=development
PORT=3000
MONGODB_URI=mongodb://localhost:27017/mediloon
REDIS_URL=redis://localhost:6379
JWT_SECRET=your_jwt_secret_key
FASTAPI_URL=http://localhost:8000
FASTAPI_API_KEY=your_internal_api_key
CORS_ORIGIN=http://localhost:3001REACT_APP_API_URL=http://localhost:3000
REACT_APP_SOCKET_URL=http://localhost:3000-
Voice Ordering
- Click the microphone button
- Say: "I need 30 tablets of Aspirin 100mg"
- Confirm the parsed order
- Complete checkout
-
Text Ordering
- Type in the chat: "I need metformin 500mg"
- The AI assistant will guide you through options
- Add to cart and checkout
-
Predictive Refills
- View your medicine timeline
- Get automatic refill notifications
- One-click reorder
-
Inventory Management
- Monitor stock levels
- View predictive alerts
- Approve auto-procurement
-
Agent Monitoring
- View agent activity logs
- Monitor conversation quality
- Review safety alerts
-
Analytics
- Order patterns
- Prediction accuracy
- Customer satisfaction
graph TD
A[Customer Request] --> B[Ordering Agent]
B --> C{Valid Order?}
C -->|Yes| D[Safety Agent]
C -->|No| B
D --> E{Prescription Required?}
E -->|Yes| F[Request Prescription]
E -->|No| G[Forecast Agent]
F --> G
G --> H{Stock Available?}
H -->|Yes| I[Add to Cart]
H -->|No| J[Procurement Agent]
J --> K[Order from Supplier]
K --> I
Ordering Agent
- Handles natural language conversations
- Parses medicine names and quantities
- Manages multi-turn dialogues
- Confirms alternatives and variants
Forecast Agent
- Analyzes order history
- Predicts depletion dates
- Calculates refill timelines
- Triggers proactive notifications
Procurement Agent
- Monitors inventory levels
- Creates purchase orders automatically
- Integrates with supplier APIs via n8n
- Optimizes order quantities
Safety Agent
- Validates prescription requirements
- Checks drug interactions
- Verifies dosage appropriateness
- Flags potential safety issues
POST /api/auth/register Register new user
POST /api/auth/login Login user
POST /api/auth/logout Logout user
POST /api/auth/refresh Refresh token
GET /api/auth/me Get current user
PATCH /api/auth/profile Update profile
GET /api/orders Get user orders
GET /api/orders/:id Get order by ID
POST /api/orders/process Process order (proxy to AI)
GET /api/medicines List medicines
GET /api/medicines/:id Get medicine details
POST /api/v1/orders/text Process text order
POST /api/v1/orders/voice Process voice order
POST /api/v1/orders/confirm Confirm order
GET /api/v1/orders/user/:id Get user orders
GET /api/v1/predictions/user/:id Get user predictions
GET /api/v1/medicines List medicines
# Backend tests
cd backend
pyServer tests
cd server
npm test
# AI Backend tests
cd ai-backend
pytest tests/ -v --cov
# Client tests
cd client
Docker deployment will be added in future updates. For now, follow manual deployment:
1. Set up MongoDB and Redis on your server
2. Deploy AI Backend (FastAPI) - see [ai-backend/README.md](ai-backend/README.md)
3. Deploy Server (Express) - see [server/README.md](server/README.md)
4. Build and deploy Client (React) - see [client/README.md](client/README.md)
Configure environment variables for production and use a process manager like PM2 for Node.js service
### Manual Deployment
See [DEPLOYMENT.md](./DEPLOYMENT.md) for detailed deployment instructions.
## ๐ Monitoring
- **Express Health**: `GET http://localhost:3000/health`
- **FastAPI Health**: `GET http://localhost:8000/health`
- **Socket.io Status**: Check browser console for connection status
## ๐ Security
- JWT-based authentication with bcrypt password hashing
- Role-based access control (RBAC)
- Socket.io authentication via JWT
- Express rate limiting
- Input validation with express-validator
- CORS configuration
- Environment variable protection
## ๐ Multi-Language Support
Supported languages:
- ๐ฌ๐ง English
- ๐ฉ๐ช German (Deutsch)
- ๐ธ๐ฆ Arabic (ุงูุนุฑุจูุฉ)
## ๐ License
MIT License
## ๐ Support
- **Issues**: Create an issue on GitHub
- **Documentation**: See individual README files in server/, client/, ai-backend/
## ๐ฏ Roadmap
- โ
Voice/text ordering with AI
- โ
Multi-agent system (LangChain)
- โ
Real-time updates via Socket.io
- โ
JWT authentication
- โ
React frontend with routing
- ๐ Complete AI integration (frontend โ AI backend)
- ๐ Voice recording and Whisper integration
- ๐ Admin dashboard
- ๐ Analytics and reporting
- ๐ Docker containerization
- ๐ Production deployment
---
**Built with โค๏ธ for HackFusion Hackathon**
- [ ] Mobile app (React Native)
- [ ] Voice assistant integration (Alexa, Google Home)
- [ ] Blockchain for prescription verification
- [ ] AR medicine scanner
- [ ] Telemedicine integration
- [ ] Insurance claim automation
## ๐ฅ Team
Built with โค๏ธ by the Mediloon team for HackFusion 2025
---
**Note**: This is a hackathon project demonstrating AI-driven pharmacy automation. For production use, ensure compliance with local pharmaceutical regulations and data privacy laws.