Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OneStopMed 🏥

AI-Powered Clinical Workbench & Prescription Generator for Indian Medical Practitioners

Features · Tech Stack · Setup · Deploy · Roadmap


Overview

OneStopMed is a full-stack medical application built to modernize the prescription workflow for doctors in India. It combines a lightning-fast drug search engine (powered by SQLite FTS5 across 200,000+ medicines), a medical-grade PDF generator, and a secure doctor authentication system — all wrapped in a clean, modern React interface.

Doctors can search drugs by brand or generic name, build prescriptions with smart auto-complete, save reusable templates, and generate professionally formatted PDF prescriptions — ready to print and sign.


🚀 Key Features

⚡ Instant Drug Search

  • Full-text search across 200,000+ Indian medicines using SQLite FTS5 with Porter stemming.
  • Handles partial matches and typos (e.g., "dolo""DOLO 650 Tablet").
  • Returns brand name, generic composition, drug type, and manufacturer — in milliseconds.

📄 Medical-Grade PDF Generation

  • Generates high-resolution, vector-based PDF prescriptions using WeasyPrint + Jinja2 templates.
  • Auto-populates doctor credentials (name, qualification, NMC Reg. No., clinic details).
  • Includes patient vitals (age, weight, BP, allergies), diagnosis, Rx table, and follow-up instructions.
  • Clean, print-ready layout with proper medical formatting (℞ symbol, structured fields).

💊 Prescription Templates

  • Save frequently used prescription sets as reusable templates.
  • Instantly load, rename, or delete saved templates.
  • Templates are doctor-specific and stored securely in Supabase.

🔐 Secure Doctor Authentication

  • Supabase Auth with JWT-based session management.
  • Registration flow with admin approval (pending registrations table).
  • Passwords hashed with bcrypt before storage.
  • Protected API routes — every endpoint validates the JWT token server-side.

👤 Doctor Profile Management

  • Editable profile with fields: full name, qualification, clinic name, clinic address, phone, NMC registration number.
  • Profile data is automatically embedded into generated prescriptions.

🧠 Smart Auto-Complete

  • Real-time drug suggestions as you type — with keyboard navigation (↑/↓/Enter/Escape).
  • Auto-fills generic composition and drug type on selection.
  • Prevents prescription errors by validating against the curated database.

📋 Prescription History

  • Every generated prescription is logged to Supabase with full patient + medicine data.
  • Enables future analytics and audit trail capabilities.

🛠️ Tech Stack

Layer Technology Purpose
Frontend React 19, TypeScript, Vite SPA with modern tooling
Styling Tailwind CSS, Shadcn/ui (Radix) Clean, accessible UI components
Routing React Router v7 Client-side navigation
Auth (Client) Supabase JS SDK Session management, JWT tokens
HTTP Client Axios API communication
Backend FastAPI (Python) High-performance async API
Server Uvicorn (ASGI) Production-grade ASGI server
Drug Search SQLite FTS5 Full-text search with Porter stemming
PDF Engine WeasyPrint + Jinja2 CSS-styled PDF rendering
Auth (Server) Supabase Admin + bcrypt JWT validation, password hashing
Database Supabase (PostgreSQL) Doctors, templates, prescriptions
Drug Data SQLite (42 MB, FTS5) 200k+ medicines from CSV ingestion
Icons Lucide React Consistent iconography

📂 Project Structure

OneStopMed_Prescription/
├── backend/                      # Python / FastAPI
│   ├── main.py                   # All API endpoints
│   ├── ingest.py                 # CSV → SQLite FTS5 data pipeline
│   ├── requirements.txt          # Python dependencies
│   ├── data/
│   │   ├── medicine_data.csv     # Raw drug dataset (~27 MB)
│   │   └── drugs.db              # SQLite FTS5 database (~42 MB)
│   └── templates/
│       └── prescription.html     # Jinja2 template for PDF layout
│
├── frontend/                     # React / Vite / TypeScript
│   ├── src/
│   │   ├── App.tsx               # Root component, routing, auth guard
│   │   ├── Login.tsx             # Login page
│   │   ├── Register.tsx          # Registration page
│   │   ├── supabaseClient.ts     # Supabase client initialization
│   │   ├── pages/
│   │   │   ├── Dashboard.tsx     # Main prescription builder UI
│   │   │   └── Profile.tsx       # Doctor profile editor
│   │   └── components/ui/        # Shadcn/ui components (12 files)
│   │       ├── Header.tsx        # App header with navigation
│   │       ├── button.tsx, card.tsx, dialog.tsx, input.tsx,
│   │       │   label.tsx, table.tsx, tabs.tsx, textarea.tsx,
│   │       │   badge.tsx, scroll-area.tsx, separator.tsx
│   │       └── ...
│   ├── vite.config.ts
│   ├── tailwind.config.js
│   └── package.json
│
├── my-app/                       # Next.js (Patient-facing / Landing)
│   ├── app/
│   │   ├── page.tsx              # Landing page
│   │   └── layout.tsx            # Root layout
│   └── package.json
│
├── .gitignore
└── README.md

⚡ Getting Started

Prerequisites

Tool Version Notes
Python 3.11+ Backend runtime
Node.js 18+ Frontend tooling
GTK3 Runtime Latest Required by WeasyPrint on Windows (install guide)
Supabase Project Create one at supabase.com

1. Clone the Repository

git clone https://github.com/your-username/OneStopMed_Prescription.git
cd OneStopMed_Prescription

2. Backend Setup

# Create and activate a virtual environment
python -m venv venv
venv\Scripts\activate          # Windows
# source venv/bin/activate     # macOS/Linux

# Install dependencies
pip install -r backend/requirements.txt

Create backend/.env with your Supabase credentials:

SUPABASE_URL=https://your-project.supabase.co
SUPABASE_KEY=your-service-role-key
CORS_ORIGINS=http://localhost:5173

(Optional) Rebuild the drug database from the raw CSV:

cd backend
python ingest.py

Start the API server:

uvicorn backend.main:app --reload

🟢 API is now live at http://127.0.0.1:8000 — interactive docs at /docs

3. Frontend Setup

cd frontend
npm install

Create frontend/.env.local:

VITE_API_BASE_URL=http://localhost:8000
VITE_SUPABASE_URL=https://your-project.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key

Start the dev server:

npm run dev

🟢 Frontend is now live at http://localhost:5173


☁️ Deployment

Backend → Render

  1. Push your code to GitHub.
  2. Create a new Web Service on Render.
  3. Connect the repository and set the Root Directory to backend.
  4. Render automatically installs Python dependencies and system packages (pango, cairo, gdk-pixbuf) for PDF generation.
  5. Add your environment variables (SUPABASE_URL, SUPABASE_KEY, CORS_ORIGINS) in the Render dashboard.

Frontend → Vercel

  1. Import the repository on Vercel.
  2. Set the Root Directory to frontend.
  3. Vercel auto-detects Vite and deploys.
  4. Add environment variables (VITE_API_BASE_URL, VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY) in the Vercel dashboard.

Important: Set VITE_API_BASE_URL to your Render backend URL (e.g., https://your-app.onrender.com).


🔌 API Reference

Method Endpoint Auth Description
POST /register Submit a doctor registration application
GET /me Get current doctor's profile
PUT /profile Update doctor profile
GET /search?q= Search drugs by name (min 2 chars)
POST /generate_pdf Generate a prescription PDF
POST /templates Create a new prescription template
GET /templates List all templates for the current doctor
PATCH /templates/{id} Rename a template
DELETE /templates/{id} Delete a template

🗄️ Database Schema (Supabase)

The application uses the following tables in Supabase (PostgreSQL):

Table Description
pending_registrations Stores doctor registration requests awaiting admin approval
doctors Approved doctor profiles (name, qualification, clinic info, NMC reg.)
prescription_templates Saved prescription templates per doctor
prescriptions Full prescription history with patient data and medicines

The drug search database (drugs.db) is a local SQLite FTS5 database — not stored in Supabase — for maximum search performance.


🗺️ Roadmap

  • Phase 1 — Fuzzy / Full-Text Drug Search API
  • Phase 2 — React Frontend & Prescription Builder UI
  • Phase 3 — PDF Generation Engine
  • Phase 4 — Cloud Deployment (Render + Vercel)
  • Phase 5 — Doctor Authentication & Login (Supabase Auth)
  • Phase 6 — Prescription History & Templates
  • Phase 7 — Patient-Facing Portal (Next.js)
  • Phase 8 — Dashboard Analytics (Appointment trends, patient footfall)
  • Phase 9 — WhatsApp Prescription Sharing Integration

🛡️ License & Disclaimer

License: Private / Proprietary

⚕️ Medical Disclaimer: OneStopMed is an assistive technology designed for registered medical practitioners. It does not replace professional medical judgment. All generated prescriptions must be physically reviewed, signed, and verified by a licensed doctor before being issued to patients.


🔒 Security Notes

  • All API keys and secrets are loaded from environment variables (.env files) — never hardcoded.
  • .env files are excluded from version control via .gitignore.
  • Supabase service role keys are used server-side only and never exposed to the client.
  • CORS origins are configurable via environment variables.
  • JWT tokens are validated on every protected endpoint.

Built by Tejas D. Jaiprakash
AIML Student & Full-Stack Developer

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages