A unified AI microservice designed to plug into a React + Node CRM for pharmacies. It exposes three endpoints behind a single service:
POST /api/chatbot— pharmacist-oriented assistant backed by OpenAI Responses APIPOST /api/recommend— related/alternative medicine suggestions (content + embeddings hybrid)POST /api/stock— lightweight stock-risk forecast (moving-average placeholder)
Bring your own OpenAI API key via
.env.
npm install
cp .env.example .env # or create .env
# edit .env and set OPENAI_API_KEY
npm run devThe service will start by default on http://localhost:3001.
Create a .env file with:
OPENAI_API_KEY=sk-... # required
PORT=3001 # optional
MODEL_RESPONSES=gpt-4o-mini # override if you want
MODEL_EMBEDDINGS=text-embedding-3-small
POST /api/chatbot
Body:
{ "query": "Posologie d'ibuprofène 400 mg pour un adulte ?" }POST /api/recommend
Body (any subset is fine):
{ "specialite": "ALGIK", "forme": "COMPRIME", "classe": "ANALGESIQUES" }POST /api/stock
Body:
{ "item": "PARACETAMOL 500mg", "history": [10,12,8,14,9,7,11] }If you place data/medicaments.csv (sample included), it will be indexed
for quick filtering by forme / classe and embeddings for similarity.
This project is easy to deploy as a container.
docker build -t pharma-ai-service .
docker run -p 3001:3001 -e OPENAI_API_KEY=$OPENAI_API_KEY pharma-ai-service- The stock endpoint uses a simple moving-average + threshold heuristic. Replace with Prophet/ARIMA in a separate service if you need time-series at scale.
- The recommend endpoint blends quick filters and vector similarity using OpenAI embeddings.
- The chatbot is grounded with a pharmacist system prompt and can be extended to call your internal knowledge base or a RAG layer.