Skip to content

Tejas-dj/OneStopMed-v1

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

No releases published

Packages

 
 
 

Contributors