A lightweight pharmacy management system with AI features and third-party integrations.
- Medicine lifecycle management (inventory, sales, procurement)
- Multi-channel sales (physical store and online)
- AI-powered customer consultation with historical logs
- Integration with external systems (街顺ERP, 码上放心)
- Data synchronization between systems
- Prescription management and regulatory compliance
- Customer relationship management with VIP tracking
- Backend: Node.js + Express
- Database: SQLite (with option to upgrade to PostgreSQL)
- Frontend: React + Vite + Tailwind CSS
- AI Integration: OpenAI API
- Deployment: Docker + Docker Compose
- Node.js (v16 or higher)
- npm or yarn
- Docker (optional, for containerized deployment)
-
Clone the repository:
git clone <repository-url> cd med2-pharmacy-system
-
Install backend dependencies:
npm install
-
Install frontend dependencies:
cd frontend npm install cd ..
-
Set up environment variables:
cp .env.example .env
Then update the
.envfile with your actual values. -
Run database migrations:
npm run db:migrate
-
Start the backend server:
npm run dev
-
In a new terminal, start the frontend:
cd frontend npm run dev
-
Build and run the containers:
docker-compose up -d
-
Run database migrations:
docker-compose exec app npx sequelize-cli db:migrate
The API is organized around REST principles with predictable resource-oriented URLs. All responses are returned as JSON.
http://localhost:3000/api
GET /medicine- Get all medicinesPOST /medicine- Create a new medicineGET /medicine/:id- Get a specific medicinePUT /medicine/:id- Update a medicineDELETE /medicine/:id- Delete a medicineGET /medicine/search/:barcode- Search medicine by barcode
GET /inventory- Get all inventory itemsPOST /inventory- Create a new inventory itemPUT /inventory/:id- Update an inventory itemPATCH /inventory/:id/adjust- Adjust inventory quantity
GET /sale- Get all salesPOST /sale- Create a new saleGET /sale/:id- Get a specific salePUT /sale/:id- Update a sale
GET /customer- Get all customersPOST /customer- Create a new customerGET /customer/:id- Get a specific customerPUT /customer/:id- Update a customer
GET /supplier- Get all suppliersPOST /supplier- Create a new supplierGET /supplier/:id- Get a specific supplierPUT /supplier/:id- Update a supplier
POST /user/login- User loginGET /user/profile- Get user profile
POST /ai/chat- Chat with the AI assistantGET /ai/conversations- Get conversation history
POST /integration/street-erp/sync-medicine- Sync medicine to Street ERPPOST /integration/msfx/validate-trace- Validate drug trace codeGET /integration/msfx/trace-info/:traceCode- Get drug trace information
| Variable | Description | Default |
|---|---|---|
PORT |
Port for the server | 3000 |
DB_STORAGE |
Path to SQLite database file | ./db/med2-pharmacy.db |
JWT_SECRET |
Secret for JWT tokens | med2_pharmacy_secret_key |
JWT_EXPIRES_IN |
JWT expiration time | 24h |
OPENAI_API_KEY |
OpenAI API key for AI features | - |
OPENAI_MODEL |
OpenAI model to use | gpt-3.5-turbo |
STREET_ERP_API_KEY |
Street ERP API key | - |
MSFX_API_KEY |
Ma Shang Fang Xin API key | - |
The frontend is built with React and uses Vite as the build tool. To start the development server:
cd frontend
npm run devThe frontend will be available at http://localhost:5173 and proxies API requests to the backend.
For production deployment, we recommend using Docker Compose:
docker-compose up -dMake sure to set up SSL certificates and configure environment variables in the docker-compose.yml file before deploying to production.
This project is licensed under the MIT License."# med2"