Skip to content

Badr-dev01/pharma-ai-service

Repository files navigation

Pharma AI Service (Node.js)

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 API
  • POST /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.

Quickstart

npm install
cp .env.example .env # or create .env
# edit .env and set OPENAI_API_KEY
npm run dev

The service will start by default on http://localhost:3001.

Environment

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

Endpoints

1) Chatbot

POST /api/chatbot

Body:

{ "query": "Posologie d'ibuprofène 400 mg pour un adulte ?" }

2) Recommend

POST /api/recommend

Body (any subset is fine):

{ "specialite": "ALGIK", "forme": "COMPRIME", "classe": "ANALGESIQUES" }

3) Stock

POST /api/stock

Body:

{ "item": "PARACETAMOL 500mg", "history": [10,12,8,14,9,7,11] }

Data

If you place data/medicaments.csv (sample included), it will be indexed for quick filtering by forme / classe and embeddings for similarity.


Deploy

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

Notes

  • 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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors