Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Pharmacovigilance Alert System

A comprehensive full-stack application for managing pharmacovigilance alerts in compounding pharmacies. Built with Laravel (backend) and Vue.js (frontend) in a monorepo structure.

πŸ“‹ Table of Contents

🎯 Overview

This system enables compounding pharmacies to:

  • Identify customers who purchased medications with specific lot numbers
  • Send email alerts to affected customers
  • Track alert history with audit logging
  • Manage customer and order information

✨ Features

Core Features

  • βœ… User authentication (Laravel Sanctum)
  • βœ… Medication search by lot number and date range
  • βœ… Order retrieval with filtering
  • βœ… Customer management
  • βœ… Individual and bulk email alerts
  • βœ… Alert audit logging
  • βœ… Responsive UI with Vue.js

Bonus Features

  • βœ… Pagination support
  • βœ… Docker containerization
  • βœ… Clean architecture (MVC)
  • βœ… Input validation and error handling
  • βœ… Reusable Vue components
  • βœ… RESTful API design

πŸ›  Tech Stack

Backend

  • Framework: Laravel 13.x
  • Authentication: Laravel Sanctum
  • Database: MySQL 8.0
  • Mail: SMTP (Mailhog for development)

Frontend

  • Framework: Vue 3 (Composition API)
  • Build Tool: Vite
  • State Management: Pinia
  • Routing: Vue Router 4
  • HTTP Client: Axios

DevOps

  • Containerization: Docker & Docker Compose
  • Database UI: phpMyAdmin

πŸ— Architecture

pharmaco-vigilance-alert/
β”œβ”€β”€ backend/                 # Laravel API
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ Http/Controllers/Api/
β”‚   β”‚   β”œβ”€β”€ Mail/
β”‚   β”‚   └── Models/
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   β”œβ”€β”€ migrations/
β”‚   β”‚   └── seeders/
β”‚   └── routes/api.php
β”œβ”€β”€ frontend/                # Vue.js SPA
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ views/
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ stores/
β”‚   β”‚   └── router/
β”‚   └── package.json
β”œβ”€β”€ docker-compose.yml
└── README.md

πŸ“¦ Installation

Prerequisites

  • PHP 8.2+
  • Composer
  • Node.js 18+
  • MySQL 8.0
  • Docker (optional)

Method 1: Local Setup

Backend Setup

  1. Navigate to backend directory:
cd backend
  1. Install dependencies:
composer install
  1. Create database:
mysql -u root -p
CREATE DATABASE pharmacovigilance;
exit;
  1. Configure environment (already configured):
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=pharmacovigilance
DB_USERNAME=root
DB_PASSWORD=
  1. Run migrations and seed data:
php artisan migrate --seed
  1. Start the server:
php artisan serve

Backend will run on http://localhost:8000

Frontend Setup

  1. Navigate to frontend directory:
cd frontend
  1. Install dependencies:
npm install
  1. Start development server:
npm run dev

Frontend will run on http://localhost:5173

Method 2: Docker Setup

  1. Build and start containers:
docker-compose up -d
  1. Run migrations inside container:
docker exec -it pharmacovigilance_backend php artisan migrate --seed

Services:

πŸš€ Usage

Login Credentials

Admin Account:

  • Email: admin@pharmacovigilance.com
  • Password: password123

Manager Account:

  • Email: manager@pharmacovigilance.com
  • Password: password123

Workflow

  1. Login - Access the system with provided credentials
  2. Search - Navigate to Search page
  3. Filter - Enter lot number (e.g., 951357) and optional date range
  4. Review - View list of affected orders
  5. Alert - Send individual or bulk alerts
  6. Audit - Check Alert History for sent notifications

πŸ“‘ API Documentation

Authentication

POST /api/login

Login and get access token

Request:

{
  "email": "admin@pharmacovigilance.com",
  "password": "password123"
}

Response:

{
  "message": "Login successful",
  "user": {
    "id": 1,
    "name": "Pharmacovigilance Admin",
    "email": "admin@pharmacovigilance.com"
  },
  "token": "1|abc123..."
}

Medications

GET /api/medications/search

Search medications by lot number

Parameters:

  • lot_number (required): Medication lot number
  • start_date (optional): Start of date range
  • end_date (optional): End of date range

Alerts

POST /api/alerts/send

Send alert to single customer

Request:

{
  "customer_id": 1,
  "order_id": 5,
  "lot_number": "951357"
}

POST /api/alerts/send-bulk

Send bulk alerts

πŸ—„ Database Schema

Users

  • id, name, email, password, timestamps

Customers

  • id, name, email, phone, timestamps

Medications

  • id, name, lot_number (indexed), description, timestamps

Orders

  • id, customer_id (FK), purchase_date, total_amount, status, timestamps

Order_Items

  • id, order_id (FK), medication_id (FK), quantity, unit_price, subtotal, timestamps

Alerts

  • id, customer_id (FK), order_id (FK), user_id (FK), alert_type, message, sent_at, timestamps

πŸ’‘ Design Decisions

Architecture

  1. Monorepo Structure: Keeps frontend and backend together for easier development
  2. RESTful API: Follows REST principles for clean endpoints
  3. Token-Based Auth: Laravel Sanctum provides secure authentication
  4. Composition API: Vue 3 for better code organization
  5. Service Layer: Frontend services abstract API calls

Security

  • Password hashing with bcrypt
  • Token-based authentication
  • Input validation on both sides
  • SQL injection prevention through Eloquent ORM

Performance

  • Database indexing on lot_number
  • Pagination support
  • Eager loading to prevent N+1 queries
  • Axios interceptors for token management

🐳 Docker Deployment

Start Services

docker-compose up -d

Stop Services

docker-compose down

Reset Database

docker exec -it pharmacovigilance_backend php artisan migrate:fresh --seed

πŸ“ Sample Data

The system comes pre-seeded with:

  • 2 users (admin and manager)
  • 10 customers
  • 8 medications (including lot #951357)
  • 20 orders from the last 45 days

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages