Skip to content

flexycode/CTFDMBSL_FINAL_PROJECT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

70 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ซ Pharmaceutical Supplychain Management

Subject & Section: CTFDMBSL - COM231

Professor: Mrs. Jensen A. Santillanย ย  ย 

No. of Units: 3 Units

๐Ÿง  Introduction

PharmaXLedger

PharmaXLedger is a comprehensive pharmaceutical supply chain management platform that leverages modern web technologies to provide secure, transparent tracking and management of pharmaceutical shipments with advanced inventory management capabilities.

๐Ÿฆ Case Study: Pharmaceutical Supply Chain Management

Overview

The Pharmaceutical Supply Chain Management application serves as a comprehensive solution for managing the distribution of generic medicines. It features a user-friendly interface that allows healthcare professionals to search for products, inquire about availability, and make purchases seamlessly. The application also includes robust classification systems for different types of medications, ensuring that users can easily find what they need. Our goal is to revolutionize the pharmaceutical supply chain by enhancing efficiency, security, and accessibility.

โœจ Introduction

Project Overview: PharmaXLedger is an internal web-based supply chain management system designed for a group of pharmaceutical companies, including a parent company and its subsidiaries. It facilitates real-time inventory tracking, supplier coordination, and seamless order processing within a secure, private environment.

Problem Statement: The pharmaceutical industry faces significant challenges in supply chain management, including:

  • Lack of real-time visibility across the entire supply chain
  • Data silos between different departments and subsidiary companies
  • Inefficient manual tracking processes leading to errors and delays
  • Compliance risks due to inadequate documentation and tracking
  • Difficulty in quickly responding to supply chain disruptions
  • Poor inventory management leading to stockouts and expired medicines

Objectives:

General Objective: To develop a centralized, real-time pharmaceutical supply chain management system for internal use across a network of related companies.

Specific Objectives:

  • Implement end-to-end tracking of pharmaceutical products from manufacturer to end customer
  • Create a comprehensive medicine inventory management system with stock tracking
  • Enable real-time notifications and alerts for critical supply chain events
  • Generate comprehensive analytics and reports for inventory, shipment, and compliance tracking
  • Design a relational database that maintains relationships between entities while ensuring data integrity
  • Facilitate seamless communication between different departments and subsidiary companies
  • Ensure regulatory compliance through proper documentation and audit trails

๐Ÿ’ป Techstacks # 1

Frontend:

  • Programming Language: TypeScript
  • Frontend: React.js 18, HTML5, CSS3 +
  • Build tool and Development server: Vite
  • Tailwind CSS for styling
  • Shadcn UI component library
  • React Router for navigation
  • Tanstack React Query for data fetching

Backend:

  • Authentication: Supabase
  • Database: Posgresql integrated in Supabase
  • Supabase Edge Functions for serverless computing

๐Ÿš€ Future Features Use case

  • AI Integration: TensorFlow, Scikit-learn
  • Blockchain: Ethereum, Smart Contracts, Solidity, DeFi
  • Payment Gateway: Stripe, Paypal

Table of Contents

Features

  • Secure Authentication: Email/password authentication with role-based access control
  • Shipment Tracking: Real-time tracking of pharmaceutical shipments
  • Inventory Management: Track and manage pharmaceutical inventory
  • Admin Dashboard: Comprehensive admin panel for system management
  • User Management: User registration and profile management
  • Support System: In-app support chat for user assistance
  • Responsive Design: Works seamlessly across desktop and mobile devices

Technology Stack

  • Frontend:

    • React 18 with TypeScript
    • Tailwind CSS for styling
    • Shadcn UI component library
    • React Router for navigation
    • Tanstack React Query for data fetching
  • Backend:

    • Supabase for authentication, database, and storage
    • PostgreSQL database
    • Supabase Edge Functions for serverless computing

System Design

3.1 System Architecture

PharmaXLedger implements a modern client-server architecture with a distributed database approach to handle pharmaceutical supply chain data. The system is designed with the following key architectural components:

Frontend Layer:

  • React SPA with TypeScript providing a responsive user interface
  • Component-based architecture for reusability and maintainability
  • State management using React hooks and context API

API Layer:

  • RESTful API services via Supabase
  • Authentication and authorization middleware
  • Data validation and transformation services

Database Layer:

  • PostgreSQL relational database for structured data storage
  • Hybrid data distribution strategy:
    • Vertical fragmentation for sensitive data (separating user profiles from transaction data)
    • Selective replication for high-availability of critical data
    • Query optimization through indexing and materialized views

Function Layer:

  • Edge Functions for specialized business logic
  • Event-driven architecture for real-time updates
  • Background processing for report generation and analytics

Integration Points:

  • External API connections for shipping carrier data
  • Webhook support for third-party integrations

The system employs a hybrid data management approach:

  • Relational Database Core: Primary data storage using PostgreSQL
  • Object-Relational Mapping: TypeScript interfaces map database entities to application objects
  • XML Data Exchange: For interoperability with legacy pharmaceutical systems
    • XML schemas defined for standardized data exchange
    • XPath/XQuery for processing incoming XML data

3.2 Design Diagrams

System Design

Enhanced System Architecture

PharmaXLedger implements a modern client-server architecture with comprehensive inventory management:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                 โ”‚     โ”‚                 โ”‚      โ”‚                 โ”‚
โ”‚   React UI      โ”‚โ”€โ”€โ”€โ”€โ–ถโ”‚   Supabase API  โ”‚โ—€โ”€โ”€โ”€โ”€โ–ถโ”‚   PostgreSQL    โ”‚
โ”‚                 โ”‚     โ”‚                 โ”‚      โ”‚   Database      โ”‚
โ”‚ - Inventory Mgmtโ”‚     โ”‚ - Auth & RLS    โ”‚      โ”‚ - Inventory     โ”‚
โ”‚ - Shipments     โ”‚     โ”‚ - Real-time     โ”‚      โ”‚ - Shipments     โ”‚
โ”‚ - Dashboard     โ”‚     โ”‚ - Edge Functionsโ”‚      โ”‚ - Stock Moves   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜      โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
         โ”‚                        โ”‚                        โ”‚
         โ”‚                        โ–ผ                        โ”‚
         โ”‚               โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”               โ”‚
         โ”‚               โ”‚  Edge Functions โ”‚               โ”‚
         โ”‚               โ”‚ - Notifications โ”‚               โ”‚
         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ - Stock Alerts  โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                         โ”‚ - Batch Jobs    โ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Enhanced Entity Relationship Diagram (ERD)

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  profiles   โ”‚       โ”‚ medicine_   โ”‚       โ”‚ stock_      โ”‚
โ”‚             โ”‚       โ”‚ inventory   โ”‚       โ”‚ movements   โ”‚
โ”‚ id (PK)     โ”‚โ—€โ”€โ”€โ”   โ”‚             โ”‚โ”€โ”€โ”    โ”‚             โ”‚
โ”‚ first_name  โ”‚   โ”‚   โ”‚ id (PK)     โ”‚  โ”‚    โ”‚ id (PK)     โ”‚
โ”‚ last_name   โ”‚   โ””โ”€โ”€โ”€โ”‚ user_id(FK) โ”‚  โ””โ”€โ”€โ”€โ–ถโ”‚ medicine_id โ”‚
โ”‚ email       โ”‚       โ”‚ medicine_   โ”‚       โ”‚ movement_   โ”‚
โ”‚ role        โ”‚       โ”‚ name        โ”‚       โ”‚ type        โ”‚
โ”‚ company     โ”‚       โ”‚ stock_qty   โ”‚       โ”‚ quantity    โ”‚
โ”‚ status      โ”‚       โ”‚ reorder_lvl โ”‚       โ”‚ prev_stock  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚ expiry_date โ”‚       โ”‚ new_stock   โ”‚
      โ”‚               โ”‚ batch_no    โ”‚       โ”‚ created_at  โ”‚
      โ”‚               โ”‚ category    โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
      โ–ผ               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ”‚
โ”‚ shipments   โ”‚              โ”‚
โ”‚             โ”‚              โ”‚
โ”‚ id (PK)     โ”‚              โ”‚
โ”‚ user_id(FK) โ”‚              โ”‚
โ”‚ medicine_   โ”‚โ—€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
โ”‚ name        โ”‚
โ”‚ tracking_no โ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ status      โ”‚       โ”‚ tracking_   โ”‚       โ”‚ support_    โ”‚
โ”‚ origin      โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ–ถโ”‚ events      โ”‚       โ”‚ conversationsโ”‚
โ”‚ destination โ”‚       โ”‚             โ”‚       โ”‚             โ”‚
โ”‚ quantity    โ”‚       โ”‚ id (PK)     โ”‚       โ”‚ id (PK)     โ”‚
โ”‚ batch_no    โ”‚       โ”‚ shipment_id โ”‚       โ”‚ user_id(FK) โ”‚
โ”‚ expiry_date โ”‚       โ”‚ event_type  โ”‚       โ”‚ title       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚ location    โ”‚       โ”‚ status      โ”‚
      โ”‚               โ”‚ description โ”‚       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
      โ”‚               โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜              โ”‚
      โ–ผ                                           โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”              โ–ผ
โ”‚ payments    โ”‚       โ”‚ notificationsโ”‚       โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚             โ”‚       โ”‚             โ”‚       โ”‚ support_    โ”‚
โ”‚ id (PK)     โ”‚       โ”‚ id (PK)     โ”‚       โ”‚ messages    โ”‚
โ”‚ user_id(FK) โ”‚       โ”‚ user_id(FK) โ”‚       โ”‚             โ”‚
โ”‚ amount      โ”‚       โ”‚ title       โ”‚       โ”‚ id (PK)     โ”‚
โ”‚ status      โ”‚       โ”‚ content     โ”‚       โ”‚ convo_id(FK)โ”‚
โ”‚ currency    โ”‚       โ”‚ read        โ”‚       โ”‚ sender_id   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜       โ”‚ content     โ”‚
                                           โ”‚ is_admin    โ”‚
                                           โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Implementation

4.1 Technology Stack

PharmaXLedger leverages a modern technology stack optimized for web-based pharmaceutical supply chain management:

Frontend:

  • React 18 with TypeScript for type safety and improved developer experience
  • Tailwind CSS for responsive, utility-first styling
  • Shadcn UI component library for consistent design language
  • React Router for client-side routing
  • Tanstack React Query for data fetching and state management

Backend:

  • Supabase for authentication, database operations, and storage
    • Row-Level Security (RLS) for granular data access control
    • PostgreSQL database with PostGIS extensions for location tracking
    • Real-time subscriptions for live updates
  • Edge Functions for specialized business logic and third-party integrations

DevOps:

  • Git for version control
  • CI/CD pipeline for automated testing and deployment
  • Containerized development environment

Security:

  • JWT-based authentication
  • Role-based access control
  • Data encryption for sensitive information
  • Audit logging for compliance tracking

4.2 Implementation Process

The implementation of PharmaXLedger followed an iterative development approach:

Phase 1: Planning and Architecture Design

  • Requirements gathering from stakeholders
  • Database schema design and normalization
  • API endpoint definition
  • Component hierarchy planning

Phase 2: Core Implementation

  • Database setup with initial schema and RLS policies
  • Authentication system implementation
  • Basic UI framework and navigation
  • Core data models and services

Phase 3: Feature Development

  • Shipment tracking system with real-time updates
  • Inventory management functionality
  • Notification system for status changes
  • Reporting and analytics dashboard

Phase 4: Integration and Testing

  • Third-party API integrations for shipping carriers
  • End-to-end testing of critical workflows
  • Performance optimization
  • Security auditing

Key Implementation Challenges and Solutions:

  1. Challenge: Complex relational data model with multiple entities and relationships. Solution: Implemented a normalized database schema with foreign key constraints and indices for performance.

  2. Challenge: Real-time tracking updates across multiple clients. Solution: Leveraged Supabase's real-time subscription capabilities using PostgreSQL's LISTEN/NOTIFY.

  3. Challenge: Secure data access control based on user roles. Solution: Implemented row-level security policies at the database level with role-specific access rules.

  4. Challenge: Performance issues with large shipment tracking logs. Solution: Added pagination, implemented query optimization, and created materialized views for frequent reports.

Evaluation

5.1 Evaluation Criteria

PharmaXLedger was evaluated based on the following criteria:

Functional Requirements:

  • Completeness of supply chain tracking features
  • Accuracy of shipment status updates
  • Reliability of notification system
  • Comprehensiveness of reporting capabilities

Non-functional Requirements:

  • Performance: Response time under load
  • Scalability: Ability to handle growing data volume
  • Usability: Ease of use for different user roles
  • Security: Protection of sensitive data
  • Reliability: System uptime and data integrity

Integration Capability:

  • Interoperability with external systems
  • API conformance to standards
  • Data exchange format compatibility

5.2 Testing Methodology

The evaluation employed a multi-tiered testing approach:

Unit Testing:

  • Individual component testing using React Testing Library
  • API endpoint testing with automated test cases
  • Database query performance testing

Integration Testing:

  • End-to-end workflow testing
  • API integration testing
  • Database transaction integrity testing

Performance Testing:

  • Load testing with simulated concurrent users
  • Response time measurements under various loads
  • Database query execution time analysis

User Acceptance Testing:

  • Stakeholder review sessions
  • Role-based testing scenarios
  • Interface usability assessment

Implementation

Enhanced Technology Implementation

The implementation now includes comprehensive inventory management with the following key components:

Phase 1: Foundation (March 2025)

  • Project initialization and repository setup
  • Database schema design with ERD modeling
  • Technology stack selection

Phase 2: Core Development (April 2025)

  • Frontend development with React and TypeScript
  • Supabase integration for backend services
  • Authentication system implementation
  • Basic shipment tracking functionality

Phase 3: Advanced Features (May-June 2025)

  • Medicine inventory management system
  • Stock movement tracking and alerts
  • Enhanced user interface with dashboard improvements
  • Real-time notifications and updates

Key Implementation Features:

  1. Inventory Management System

    • Comprehensive medicine catalog with detailed information
    • Stock level monitoring with automatic reorder alerts
    • Expiry date tracking and notifications
    • Batch number management for traceability
  2. Enhanced Shipment Tracking

    • Integration with inventory for automatic stock updates
    • Real-time tracking with detailed event logs
    • Medicine-specific shipping requirements
  3. Real-time Updates

    • Live inventory updates across all connected clients
    • Instant notifications for low stock and expiring medicines
    • Real-time shipment status updates

Getting Started

Prerequisites

  • Node.js (v18+)
  • npm or yarn
  • Supabase account (for backend services)

Installation

  1. Clone the repository
git clone https://github.com/your-username/pharmaxledger.git
cd pharmaxledger
  1. Install dependencies
npm install
  1. Set up environment variables Create a .env file in the root directory:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
  1. Start the development server
npm run dev

Application Flow

Enhanced User Workflows

Inventory Management Flow

  1. User adds medicines to inventory with detailed information
  2. System tracks stock levels and monitors expiry dates
  3. Automatic alerts for low stock and approaching expiry
  4. Stock movements are logged for audit trails
  5. Reports generated for inventory analysis

Shipment Creation Flow

  1. User creates shipment from available inventory
  2. System automatically updates stock levels
  3. Tracking number generated with real-time updates
  4. Medicine-specific shipping requirements applied
  5. Delivery confirmation updates inventory status

-->

๐Ÿš€ Screenshot of Project Overview

๐ŸŒŸ Design Overview

๐ŸŒŸ SignIn Page

๐ŸŒŸ SignUp Page

๐ŸŒŸ PharmaXLedger Dashboard

๐ŸŒŸ Inventory

๐Ÿš€ Coming Soon!!!

๐ŸŒŸ Account Settings

๐ŸŒŸ Creating a Pharmaceutical Shipment

๐ŸŒŸ Payment Status

๐ŸŒŸ Customer Support

๐ŸงŠ Database Schema

Supabase Schema ( Not Final!!!)

๐ŸงŠ Data Integration in Supabase / Database Schema

Database Schema

The PharmaXLedger database consists of the following main tables designed to handle pharmaceutical supply chain operations with comprehensive inventory management:

Core Tables

1. Profiles Table

Stores user profile information and company details.

CREATE TABLE public.profiles (
  id UUID PRIMARY KEY,
  email TEXT NOT NULL,
  first_name TEXT,
  last_name TEXT,
  role TEXT NOT NULL DEFAULT 'customer',
  status TEXT NOT NULL DEFAULT 'Active',
  phone TEXT,
  company_name TEXT,
  website TEXT,
  address TEXT,
  city TEXT,
  state TEXT,
  zip_code TEXT,
  country TEXT
);

2. Medicine Inventory Table

Central table for managing pharmaceutical inventory with comprehensive medicine details.

CREATE TABLE public.medicine_inventory (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  user_id UUID NOT NULL,
  medicine_name TEXT NOT NULL,
  generic_name TEXT,
  brand_name TEXT,
  category TEXT,
  description TEXT,
  dosage_form TEXT,
  strength TEXT,
  manufacturer TEXT,
  batch_number TEXT,
  stock_quantity INTEGER NOT NULL DEFAULT 0,
  reorder_level INTEGER DEFAULT 10,
  unit_price NUMERIC,
  currency TEXT DEFAULT 'PHP',
  expiry_date DATE,
  storage_conditions TEXT,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
);

3. Stock Movements Table

Tracks all stock changes for audit and inventory management.

CREATE TABLE public.stock_movements (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  user_id UUID NOT NULL,
  medicine_id UUID,
  movement_type TEXT NOT NULL,
  quantity_changed INTEGER NOT NULL,
  previous_stock INTEGER NOT NULL,
  new_stock INTEGER NOT NULL,
  reference_id UUID,
  notes TEXT,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
);

4. Shipments Table

Enhanced shipment management with detailed medicine information.

CREATE TABLE public.shipments (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  user_id UUID NOT NULL,
  origin TEXT NOT NULL,
  destination TEXT NOT NULL,
  weight NUMERIC,
  status TEXT NOT NULL DEFAULT 'pending',
  tracking_number TEXT NOT NULL,
  recipient_name TEXT,
  recipient_email TEXT,
  recipient_phone TEXT,
  payment_status TEXT DEFAULT 'unpaid',
  estimated_delivery TIMESTAMP WITH TIME ZONE,
  shipping_cost NUMERIC,
  currency TEXT DEFAULT 'PHP',
  service_type TEXT DEFAULT 'Standard Delivery',
  
  -- Medicine-specific fields
  medicine_name TEXT,
  medicine_category TEXT,
  dosage TEXT,
  quantity INTEGER,
  batch_number TEXT,
  expiry_date DATE,
  storage_requirements TEXT,
  special_instructions TEXT,
  
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
);

5. Tracking Events Table

Stores detailed tracking events for each shipment.

CREATE TABLE public.tracking_events (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  shipment_id UUID NOT NULL,
  event_type TEXT NOT NULL,
  location TEXT,
  description TEXT,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
);

6. Support System Tables

Enhanced support system for customer service.

-- Support Conversations
CREATE TABLE public.support_conversations (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  user_id UUID NOT NULL,
  title TEXT NOT NULL,
  status TEXT NOT NULL DEFAULT 'open',
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
  updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
);

-- Support Messages
CREATE TABLE public.support_messages (
  id UUID NOT NULL DEFAULT gen_random_uuid() PRIMARY KEY,
  conversation_id UUID NOT NULL,
  sender_id UUID NOT NULL,
  content TEXT NOT NULL,
  is_admin BOOLEAN NOT NULL DEFAULT false,
  read BOOLEAN NOT NULL DEFAULT false,
  created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()
);

SQL/PostgreSQL Implementation

Enhanced Database Functions

The system uses several PostgreSQL functions for automated user management and inventory tracking:

-- User Profile Creation Function
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS trigger
LANGUAGE plpgsql
SECURITY DEFINER
AS $function$
BEGIN
  INSERT INTO public.profiles (id, email, first_name, last_name)
  VALUES (
    NEW.id,
    NEW.email,
    NEW.raw_user_meta_data->>'first_name',
    NEW.raw_user_meta_data->>'last_name'
  );
  RETURN NEW;
END;
$function$

-- Admin User Check Function
CREATE OR REPLACE FUNCTION public.is_admin_user()
RETURNS BOOLEAN AS $$
BEGIN
  RETURN EXISTS (
    SELECT 1 FROM public.profiles 
    WHERE id = auth.uid() AND role = 'admin'
  );
END;
$$ LANGUAGE plpgsql SECURITY DEFINER STABLE;

Row Level Security (RLS) Policies

Comprehensive RLS policies ensure data privacy and access control:

-- Medicine Inventory RLS Policies
CREATE POLICY "Users can view own inventory" ON public.medicine_inventory
  FOR SELECT USING (auth.uid() = user_id);

CREATE POLICY "Users can manage own inventory" ON public.medicine_inventory
  FOR ALL USING (auth.uid() = user_id);

-- Stock Movements RLS Policies  
CREATE POLICY "Users can view own stock movements" ON public.stock_movements
  FOR SELECT USING (auth.uid() = user_id);

CREATE POLICY "Users can create stock movements" ON public.stock_movements
  FOR INSERT WITH CHECK (auth.uid() = user_id);

-- Admin policies for full access
CREATE POLICY "Admins can view all inventory" ON public.medicine_inventory
  FOR SELECT USING (public.is_admin_user());

CREATE POLICY "Admins can view all stock movements" ON public.stock_movements
  FOR SELECT USING (public.is_admin_user());

Performance Indexes

Strategic indexing for optimal performance:

-- Inventory management indexes
CREATE INDEX idx_medicine_inventory_user_id ON public.medicine_inventory(user_id);
CREATE INDEX idx_medicine_inventory_category ON public.medicine_inventory(category);
CREATE INDEX idx_medicine_inventory_expiry ON public.medicine_inventory(expiry_date);
CREATE INDEX idx_medicine_inventory_stock ON public.medicine_inventory(stock_quantity);

-- Stock movement indexes
CREATE INDEX idx_stock_movements_user_id ON public.stock_movements(user_id);
CREATE INDEX idx_stock_movements_medicine_id ON public.stock_movements(medicine_id);
CREATE INDEX idx_stock_movements_created_at ON public.stock_movements(created_at);

-- Enhanced shipment indexes
CREATE INDEX idx_shipments_medicine_name ON public.shipments(medicine_name);
CREATE INDEX idx_shipments_expiry_date ON public.shipments(expiry_date);

Real-time Subscriptions

Enhanced real-time functionality for inventory and shipment updates:

-- Enable real-time for inventory tables
ALTER TABLE public.medicine_inventory REPLICA IDENTITY FULL;
ALTER TABLE public.stock_movements REPLICA IDENTITY FULL;

-- Add tables to real-time publication
ALTER PUBLICATION supabase_realtime ADD TABLE public.medicine_inventory;
ALTER PUBLICATION supabase_realtime ADD TABLE public.stock_movements;

๐ŸงŠ Flow Chart

๐ŸงŠ Entity Attribute Value Model

๐Ÿš€ Coming Soon!!!

๐ŸงŠ Normalization

Full Overview of Normalization is in the Folder of documentation

๐ŸงŠ Entity Relationship Diagram

Proposal Version ( v.1 )

Final Version ( v.2 Not Final!!)

๐ŸงŠ Sequence Diagram

๐ŸงŠ Cloud Architecture

๐Ÿš€ Coming Soon!!!

๐Ÿ“ Repository Structure

coming soon

๐Ÿ† Contributingย ย ย ย 

Contributingย ย ย ย ย 

If you would like to contribute to the Flight Booking App, please follow these steps:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes and commit them.
  4. Push your changes to your forked repository.
  5. Submit a pull request to the main repository.

๐Ÿง  Submitting Changes

๐Ÿง  Contributions are welcome! If you have ideas for improvements or want to add more exercises, follow these steps:

  1. Fork the repository.
  2. Create a new branch.
  3. Make your changes and commit them.
  4. Push to your fork and submit a pull request. ๐Ÿ’•๐Ÿ’•๐Ÿ’•๐Ÿ’•

๐Ÿ‘‹ Contributors

Special thanks to all my groupmates:

  • ๐Ÿ˜Ž Jay Arre Talosigย - Machine Learning Engineer | Blockchain Developer | Bioinformatics Scientist | Blackhat

  • ๐ŸŽฒ Brian De Vera - Network Security Engineer | Cyber Security Engineer | Robotics Engineer | Whitehat

  • ๐Ÿ›ธ Anthonee Buno - Software Engineerย | Fullstack Developer ย 

  • ๐Ÿค– Chloe from Cyberlife - Necromancer | A Machine | Deviant

๐Ÿ›ธ FAQ

๐Ÿ›ธ Reporting Issues

Some changes need to be address
- Fix Bug in the Frontend
- Fix Bug in the Backend
- CRUD operation management in SQL Workbench
๐Ÿค– If you encounter any issues or have suggestions, please open an issue to let us know.

๐Ÿ”‘ Licenseย ย ย ย ย 

Coming Soon In the License tab 

National University of Manila Licenseย ย ย 

The National University of Manila License grants permission to students of the National University of Manila to use, modify, and distribute this project for educational purposes within the scope of their coursework and assignments.

Usageย 

  • You may use this project as a reference or learning material for your studies at the National University of Manila.
  • You may modify the project to suit your educational needs and requirements.
  • You may share the project with your fellow students or instructors for educational purposes.

Restrictions

  • You may not use this project for commercial purposes.
  • You may not redistribute or publish this project outside the National University of Manila without explicit permission.

Disclaimer

This project is provided "as is" without warranty of any kind, express or implied. The National University of Manila and the project contributors disclaim any liability or responsibility for any direct, indirect, incidental, special, exemplary, or consequential damages arising out of the use or misuse of this project.

๐Ÿ”ญ Acknowledgementsย ย ย ย ย 

โœจ Professor

Professor Mrs. Jensen Santillan is a highly respected academic and industry practitioner. Her expertise spans a wide range of areas, including Data Analytics, Data Science, Data Analysis, Data Structures, and Information Management. As a distinguished faculty member at the College of Computing and Information Technology at National University, she shares her knowledge and skills with students.

๐Ÿ“ซ Changelogs

Chronological list of updates, bug fixes, new features, and other modifications for PharmaXLedger Pharmaceutical Supply Chain Management.

๐Ÿ“ฆ Version 1.0.0 - March 22, 2025

Project Initialization

  • โœจ Created initial repository structure
  • โœจ Set up project folder organization
  • โœจ Established development workflow
  • ๐Ÿ”ง Initial project configuration and setup

๐Ÿ“Š Version 1.0.1 - March 26, 2025

Design & Architecture

  • โœจ Created comprehensive design concept for Pharmaceutical Supply Chain Management
  • ๐Ÿ“‹ Developed Entity Relationship Diagram (ERD)
  • ๐Ÿ“ Added ERD documentation files
  • ๐Ÿ—„๏ธ Designed database schema for SQL implementation
  • ๐Ÿƒ Created alternative MongoDB schema design
  • ๐Ÿ“– Enhanced project documentation

๐ŸŽจ Version 1.1.0 - April 7, 2025

Frontend Development

  • โœจ Initialized React frontend with TypeScript
  • ๐ŸŽจ Set up Tailwind CSS for styling
  • ๐Ÿงฉ Integrated Shadcn UI component library
  • ๐Ÿ“ฑ Created responsive design foundation
  • ๐Ÿ”ง Configured build tools and development environment

๐Ÿš€ Version 2.0.0 - April 17, 2025

Core Application Development

  • โœจ Developed comprehensive homepage for PharmaXLedger
  • ๐Ÿ“ Created wireframes for MedicineCatalog and ShoppingCart
  • ๐Ÿ‘จโ€๐Ÿ’ผ Built AdminDashboard and enhanced LandingPage
  • ๐Ÿ” Integrated Supabase for backend services
  • ๐Ÿ“ Implemented user registration (Sign Up) functionality
  • ๐Ÿ’Š Added medicine management forms
  • ๐Ÿ›’ Fixed critical bugs in ShoppingCart component
  • ๐Ÿ”‘ Resolved authentication issues in SignIn/SignOut flow

๐Ÿ”’ Version 2.0.1 - April 19, 2025

Security & Optimization

  • ๐Ÿข Created private repository for enhanced security
  • ๐Ÿ“‹ Added comprehensive application setup documentation
  • ๐Ÿ› Fixed remaining ShoppingCart.tsx issues
  • ๐Ÿ”„ Conducted full system revision and optimization
  • ๐Ÿ“– Updated deployment and running instructions

๐ŸŒŸ Version 3.0.0 - May 27, 2025

Third Phase Revision

  • ๐Ÿ”„ Major system overhaul with updated technology stack
  • โšก Performance improvements and optimization
  • ๐Ÿ›ก๏ธ Enhanced security measures
  • ๐ŸŽจ UI/UX improvements and modernization
  • ๐Ÿ“Š Improved data handling and state management

๐Ÿ’Š Version 4.0.0 - June 1, 2025

Medicine Inventory Management System

  • โœจ NEW FEATURES: Comprehensive medicine inventory management

    • ๐Ÿ“ฆ Medicine stock tracking with real-time updates
    • ๐Ÿ“Š Stock level monitoring and low stock alerts
    • ๐Ÿ“… Expiry date tracking and notifications
    • ๐Ÿท๏ธ Batch number management for traceability
    • ๐Ÿ’ฐ Unit pricing and cost management
    • ๐Ÿญ Manufacturer and supplier information
    • ๐Ÿ“‹ Medicine categorization and search functionality
  • ๐Ÿ”„ MAJOR CHANGES: Renamed shipment management for clarity

    • ๐Ÿ“ฆ Previous "Inventory" renamed to "Shipments"
    • ๐Ÿ’Š New "Inventory" now refers to medicine stock management
    • ๐Ÿšš Enhanced shipment tracking with inventory integration
  • ๐Ÿ—„๏ธ DATABASE ENHANCEMENTS:

    • ๐Ÿ†• Added medicine_inventory table for stock management
    • ๐Ÿ“ˆ Added stock_movements table for audit trails
    • ๐Ÿ”„ Enhanced shipments table with medicine details
    • ๐Ÿ” Implemented Row Level Security (RLS) policies
    • โšก Added performance indexes for optimized queries
  • ๐ŸŽจ UI/UX IMPROVEMENTS:

    • ๐Ÿ“Š New inventory dashboard with stock analytics
    • โž• Medicine addition modal with comprehensive forms
    • ๐Ÿ” Advanced search and filtering capabilities
    • ๐Ÿ“ฑ Responsive design for mobile inventory management
    • ๐ŸŽจ Enhanced visual indicators for stock status
  • ๐Ÿ”ง TECHNICAL IMPROVEMENTS:

    • โšก Real-time inventory updates across all clients
    • ๐Ÿ”” Automated notifications for inventory events
    • ๐Ÿ“Š Enhanced data validation and error handling
    • ๐Ÿ—๏ธ Improved component architecture and reusability

๐Ÿ”ฎ Future Roadmap

  • ๐Ÿ“ˆ Advanced analytics and reporting dashboard
  • ๐Ÿค– AI-powered demand forecasting
  • ๐Ÿ“ฑ Mobile application development
  • ๐ŸŒ API integrations with external suppliers
  • ๐Ÿ”„ Automated reordering system
  • ๐Ÿ“‹ Regulatory compliance tracking
  • ๐Ÿฅ Multi-location inventory management

Legend:

  • โœจ New Feature
  • ๐Ÿ”„ Changed/Updated
  • ๐Ÿ› Bug Fix
  • ๐Ÿ”ง Technical Improvement
  • ๐Ÿ“– Documentation
  • ๐ŸŽจ UI/UX Enhancement
  • ๐Ÿ” Security
  • ๐Ÿ“Š Data/Analytics
  • ๐Ÿš€ Performance

๐ŸงŠ CTFDMBSL FINAL PROJECT


mystreak

mystreak

ย ย ย ย 

About

๐Ÿ’ซ CTFDMBSL: DATABASE SYSTEMS COM231

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •