A modern, offline-first prescription management application built with React and Supabase, featuring TOTP authentication and seamless online/offline synchronization.
β οΈ IMPORTANT: This project is currently NOT production-ready. See PRODUCTION_READINESS_REPORT.md for a complete security and compliance assessment before deployment.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Database Setup
- Development
- Build & Deployment
- Project Structure
- Security Considerations
- License
- π± Offline-First Architecture - Works without internet using IndexedDB
- π Automatic Sync - Bi-directional sync with Supabase when online
- π TOTP Authentication - Two-factor authentication with authenticator apps
- πΎ Local Storage - Prescriptions cached locally for instant access
- π Progressive Enhancement - Graceful degradation when offline
- π Real-time Sync Status - Visual indicators for connection and sync state
- π¨ Modern UI - Clean, mobile-responsive interface
- β‘ Fast Performance - Built with Vite for instant hot module reload
- Add, edit, and delete prescriptions
- Patient information (name, age, gender)
- Doctor details and SIP number
- Medication lists with dosage instructions
- Expiration tracking and status badges
- Medication validity warnings
- React 19.1.1 - UI framework
- Vite 7.1.7 - Build tool and dev server
- TanStack Router 1.133.36 - Type-safe routing
- Framer Motion 12.23.24 - Animations
- Supabase 2.76.1 - Backend-as-a-Service (PostgreSQL, Auth, RLS)
- IndexedDB (idb 8.0.3) - Local database for offline support
- OTPAuth 9.4.1 - TOTP two-factor authentication
- QRCode 1.5.4 - QR code generation for authenticator setup
- ESLint 9.36.0 - Code linting
- React Hooks ESLint Plugin - React-specific linting rules
- Node.js >= 18.0.0
- npm >= 9.0.0
- Supabase Account (free tier works) - Sign up here
-
Clone the repository
git clone https://github.com/yourusername/rx-ui.git cd rx-ui -
Install dependencies
npm install
-
Set up environment variables
# Copy the example env file copy .env.example .env # Edit .env with your Supabase credentials # Get these from: https://supabase.com/dashboard/project/_/settings/api
-
Configure Supabase
- Create a new project in Supabase Dashboard
- Copy your project URL and anon key
- Update
.envfile with these values
Create a .env file in the root directory:
# Supabase Configuration (Optional - app works offline-only without these)
VITE_SUPABASE_URL=https://your-project-id.supabase.co
VITE_SUPABASE_ANON_KEY=your-anon-key-hereNote: The app works in offline-only mode if Supabase is not configured. All data is stored locally in IndexedDB.
-
Enable Email Authentication (if using email/password login)
- Go to Authentication > Providers
- Enable Email provider
-
Set up TOTP (already implemented in app)
- TOTP secrets are stored in
totp_secretstable - No additional Supabase configuration needed
- TOTP secrets are stored in
- Open your Supabase project
- Go to SQL Editor
- Copy the contents of
supabase/schema.sql - Run the SQL script
This creates:
totp_secretstable - Stores TOTP authentication secretsprescriptionstable - Stores prescription data- Row Level Security (RLS) policies
- Indexes for performance
- Triggers for auto-updating timestamps
totp_secrets
- user_email (TEXT, PRIMARY KEY)
- secret (TEXT, NOT NULL)
- created_at (TIMESTAMPTZ)
- updated_at (TIMESTAMPTZ)prescriptions
- id (TEXT, PRIMARY KEY)
- user_id (TEXT, FOREIGN KEY -> totp_secrets.user_email)
- patient_name (TEXT, NOT NULL)
- gender (TEXT)
- age (TEXT)
- doctor_name (TEXT, NOT NULL)
- sip_number (TEXT)
- date (TEXT, NOT NULL)
- validity (TEXT)
- status (TEXT)
- medications (JSONB)
- synced (BOOLEAN)
- created_at (TIMESTAMPTZ)
- updated_at (TIMESTAMPTZ)npm run devThe app will be available at http://localhost:5173 (default Vite port)
| Command | Description |
|---|---|
npm run dev |
Start development server with HMR |
npm run build |
Build for production |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint to check code quality |
-
First-time Setup
- Open app, you'll see TOTP setup wizard
- Scan QR code with authenticator app (Google Authenticator, Authy, etc.)
- Verify with 6-digit code
- You're logged in!
-
Adding Prescriptions
- Click floating
+button (bottom-right) - Fill in patient and doctor information
- Add medications with dosage instructions
- Save - data is stored locally and synced to Supabase if online
- Click floating
-
Viewing Sync Status
- Check sync indicator (bottom-left)
- Click to see detailed sync statistics
- Manual refresh button available
npm run buildThis creates an optimized production build in the dist/ directory.
npm run previewTest the production build locally before deploying.
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel# Install Netlify CLI
npm i -g netlify-cli
# Deploy
netlify deploy --prod- Build the project:
npm run build - Upload
dist/folder to your hosting provider - Configure environment variables in hosting dashboard
- Set up custom domain and SSL
.env to version control!
For production:
- Set environment variables in hosting dashboard
- Use different Supabase projects for dev/staging/production
- Rotate credentials if accidentally exposed
rx-ui/
βββ .github/
β βββ copilot-instructions.md # GitHub Copilot configuration
βββ public/ # Static assets
βββ src/
β βββ assets/ # Images, fonts, etc.
β βββ components/ # React components
β β βββ ConnectionStatus.jsx
β β βββ Home.jsx
β β βββ Login.jsx
β β βββ PrescriptionDetail.jsx
β β βββ PrescriptionList.jsx
β β βββ SyncStatus.jsx
β β βββ SyncStatusDropdown.jsx
β β βββ TOTPSetup.jsx
β βββ data/ # Sample/seed data
β βββ hooks/ # Custom React hooks
β βββ lib/ # Core utilities
β β βββ auth.js # Authentication logic
β β βββ db.js # IndexedDB + Supabase sync
β β βββ supabase.js # Supabase client config
β β βββ utils.js # Helper functions
β βββ routes/ # Route components
β βββ App.jsx # Main app component
β βββ index.css # Global styles
β βββ main.jsx # App entry point
β βββ PrescriptionDetail.jsx # Legacy component
β βββ PrescriptionList.jsx # Legacy component
β βββ router.jsx # Router configuration
βββ supabase/
β βββ schema.sql # Database schema
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ eslint.config.js # ESLint configuration
βββ index.html # HTML entry point
βββ package.json # Dependencies and scripts
βββ PRODUCTION_READINESS_REPORT.md # Security assessment
βββ README.md # This file
βββ vite.config.js # Vite configuration
src/lib/db.js- Core sync logic between IndexedDB and Supabasesrc/lib/auth.js- TOTP authentication implementationsrc/lib/supabase.js- Supabase client and connection utilitiessupabase/schema.sql- Complete database schema with RLS
This project has critical security vulnerabilities. See PRODUCTION_READINESS_REPORT.md for details.
Critical Issues:
- β RLS policies allow public access to all data
- β TOTP secrets stored in plain text
- β No input validation or sanitization
- β Environment variables may be committed to git
- β No rate limiting on authentication attempts
MUST FIX:
- Fix RLS policies with proper user authentication
- Encrypt TOTP secrets at rest
- Remove
.envfrom git history (if committed) - Rotate all exposed credentials
- Add input validation and sanitization
- Implement rate limiting
- Add error boundaries
- Remove production console.logs
- Set up monitoring (Sentry)
- Configure CSP headers
If handling Protected Health Information (PHI) in the US:
- Obtain Business Associate Agreement (BAA) from Supabase
- Implement audit logging for all data access
- Set up data retention and deletion policies
- Configure automated backups
- Document security controls
- Conduct security audit
Currently: β No tests implemented
Recommended Test Stack:
- Vitest - Unit testing framework
- React Testing Library - Component testing
- Playwright or Cypress - E2e testing
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Use ESLint configuration provided
- Follow existing file structure patterns
- Add JSDoc comments for complex functions
- Keep components small and focused
- Use descriptive variable names
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Issues: GitHub Issues
- Documentation: This README and inline code comments
- Supabase Help: Supabase Documentation
- Fix all critical security issues
- Add comprehensive test coverage
- Implement proper error handling
- Add monitoring and alerting
- Complete documentation
- Multi-user support with proper auth
- Role-based access control
- Advanced search and filtering
- Export prescriptions to PDF
- Email notifications
- SSO integration
- Audit logging
- Advanced analytics
- API for third-party integration
- Mobile app (React Native)
# Clone and install
git clone https://github.com/yourusername/rx-ui.git
cd rx-ui
npm install
# Set up environment
copy .env.example .env
# Edit .env with your Supabase credentials
# Run database setup (copy contents of supabase/schema.sql into Supabase SQL Editor)
# Start development
npm run devOpen: http://localhost:5173
Built with β€οΈ using React + Vite + Supabase
Last Updated: October 29, 2025
Version: 0.0.0 (Pre-release)