Skip to content

zzhan111/med2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Med2 Pharmacy Management System

A lightweight pharmacy management system with AI features and third-party integrations.

Features

  • 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

Tech Stack

  • 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

Prerequisites

  • Node.js (v16 or higher)
  • npm or yarn
  • Docker (optional, for containerized deployment)

Getting Started

Local Development

  1. Clone the repository:

    git clone <repository-url>
    cd med2-pharmacy-system
  2. Install backend dependencies:

    npm install
  3. Install frontend dependencies:

    cd frontend
    npm install
    cd ..
  4. Set up environment variables:

    cp .env.example .env

    Then update the .env file with your actual values.

  5. Run database migrations:

    npm run db:migrate
  6. Start the backend server:

    npm run dev
  7. In a new terminal, start the frontend:

    cd frontend
    npm run dev

Using Docker

  1. Build and run the containers:

    docker-compose up -d
  2. Run database migrations:

    docker-compose exec app npx sequelize-cli db:migrate

API Documentation

The API is organized around REST principles with predictable resource-oriented URLs. All responses are returned as JSON.

Base URL

http://localhost:3000/api

Available Endpoints

Medicine Management

  • GET /medicine - Get all medicines
  • POST /medicine - Create a new medicine
  • GET /medicine/:id - Get a specific medicine
  • PUT /medicine/:id - Update a medicine
  • DELETE /medicine/:id - Delete a medicine
  • GET /medicine/search/:barcode - Search medicine by barcode

Inventory Management

  • GET /inventory - Get all inventory items
  • POST /inventory - Create a new inventory item
  • PUT /inventory/:id - Update an inventory item
  • PATCH /inventory/:id/adjust - Adjust inventory quantity

Sales Management

  • GET /sale - Get all sales
  • POST /sale - Create a new sale
  • GET /sale/:id - Get a specific sale
  • PUT /sale/:id - Update a sale

Customer Management

  • GET /customer - Get all customers
  • POST /customer - Create a new customer
  • GET /customer/:id - Get a specific customer
  • PUT /customer/:id - Update a customer

Supplier Management

  • GET /supplier - Get all suppliers
  • POST /supplier - Create a new supplier
  • GET /supplier/:id - Get a specific supplier
  • PUT /supplier/:id - Update a supplier

User Authentication

  • POST /user/login - User login
  • GET /user/profile - Get user profile

AI Consultation

  • POST /ai/chat - Chat with the AI assistant
  • GET /ai/conversations - Get conversation history

Third-Party Integrations

  • POST /integration/street-erp/sync-medicine - Sync medicine to Street ERP
  • POST /integration/msfx/validate-trace - Validate drug trace code
  • GET /integration/msfx/trace-info/:traceCode - Get drug trace information

Environment Variables

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 -

Frontend Development

The frontend is built with React and uses Vite as the build tool. To start the development server:

cd frontend
npm run dev

The frontend will be available at http://localhost:5173 and proxies API requests to the backend.

Deployment

For production deployment, we recommend using Docker Compose:

docker-compose up -d

Make sure to set up SSL certificates and configure environment variables in the docker-compose.yml file before deploying to production.

License

This project is licensed under the MIT License."# med2"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors