AI-Based Counterfeit Medicine Distribution Detection System
Jalur Obat is an AI-based application designed to monitor and analyze medicine distribution journeys in order to detect counterfeit risks. The system combines:
- A web application
- A Node.js backend
- A PostgreSQL database
- A Python-based AI service
The application records medicine journey data, evaluates risk using AI scoring, and classifies the overall safety status of distributed medicines.
Before running the project, ensure the following tools are installed:
- Visual Studio Code
- Git
- Node.js (npm included)
- Python (with venv support)
- PostgreSQL
- pgAdmin 4
-
Open a terminal.
-
Navigate to the directory where you want to store the project:
cd Documents -
Clone the repository:
git clone https://github.com/DlegendZ/Jalur-Obat.git
-
Enter the project directory:
cd jalur-obat
-
Open a terminal inside the project directory.
-
Install required dependencies:
npm install express pg dotenv cors
-
Confirm that the
node_modulesfolder is created.
-
Navigate to the backend folder:
cd backend -
Create a virtual environment:
python -m venv venv
-
Activate the virtual environment:
venv\Scripts\activate
-
Install required Python packages:
pip install -r requirement.txt
- Open pgAdmin 4.
- Create a new database (example name:
medicine_journey).
Execute the following DDL script inside the newly created database:
CREATE TABLE medicine_info (
report_id SERIAL PRIMARY KEY,
serial_number TEXT NOT NULL,
medicine_name TEXT NOT NULL,
current_location TEXT NOT NULL,
quantity INTEGER NOT NULL,
additional TEXT,
temperature NUMERIC(5,2) NOT NULL,
humidity NUMERIC(5,2) NOT NULL,
ai_score_fake_result NUMERIC(5,2),
ai_journey_score TEXT NOT NULL CHECK (
ai_journey_score IN ('Safe', 'Need Attention', 'Full Attention', 'Faked', 'Unknown')
),
overall_status TEXT NOT NULL CHECK (
overall_status IN ('Safe', 'Need Attention', 'Bad')
),
expedition_type TEXT NOT NULL CHECK (
expedition_type IN ('Land', 'Air', 'Sea')
),
created_at TIMESTAMP DEFAULT NOW(),
officer_id TEXT NOT NULL,
journey_status TEXT NOT NULL CHECK (
journey_status IN ('start', 'update', 'end')
)
);Grant privileges (replace YOUR_USERNAME with your PostgreSQL username):
GRANT ALL PRIVILEGES ON TABLE medicine_info TO YOUR_USERNAME;
GRANT USAGE, SELECT ON SEQUENCE medicine_info_report_id_seq TO YOUR_USERNAME;Update the .env file with your PostgreSQL credentials:
DB_USER=your_pgadmin_username
DB_PASSWORD=your_pgadmin_password
DB_NAME=medicine_journey
DB_HOST=localhost
DB_PORT=5432
-
Open a terminal in the directory containing
package.json. -
Run:
npm run dev
-
Open the application in a browser:
http://localhost:3000
-
Open Visual Studio Code.
-
Open the
jalur-obatproject. -
Open the terminal and navigate to the backend folder:
cd backend -
Activate the virtual environment:
venv\Scripts\activate
-
Start the AI server:
uvicorn app.main:app --reload
-
Navigate to the
appfolder (containsserver.js). -
Open a system terminal (CMD).
-
Run:
node server.js
-
The backend is now connected to the database.
- Frontend collects medicine journey data.
- Node.js backend stores and retrieves data from PostgreSQL.
- AI service evaluates risk and generates AI scores.
- Database stores all journey records and evaluation results.
Jalur Obat provides an integrated solution for tracking medicine distribution and detecting counterfeit risks through structured data collection and AI-based evaluation. Proper setup of dependencies, database configuration, and service execution is required to run the system successfully.