A comprehensive web application built to streamline dental lab workflows, connecting dentists (doctors) with laboratories and lab staff. Supports direct lab assignment and marketplace-style auto-assignment with real-time collaboration features.
- Reduces administrative overhead for dentists and labs
- Accelerates order turnaround via marketplace and auto-assignment
- Centralizes communication, files, and invoices
- Enforces security and compliance via database-level RLS & file validation
- Real-time collaboration with chat, notifications, and live updates
- Optimized for performance with PWA support and offline capabilities
| Role | Focus Areas |
|---|---|
| Non-technical stakeholders | Product overview, user flows, quick usage steps |
| Developers | Codebase layout, local setup, architecture, API & DB schema |
| DevOps / SRE | Deployment, environment variables, monitoring, migrations |
| QA Engineers | Test users, E2E test instructions and troubleshooting |
- Node.js v18+ (recommended via nvm)
- npm/yarn/pnpm/bun package manager
- Supabase project (for Postgres, Auth, Storage, Edge Functions)
- Optional: Playwright for E2E tests
git clone https://github.com/RaheemEmad/lab-link-system.git
cd lab-link-system
npm ci- Copy
.env.exampleto.env.local - Supply credentials for Supabase, Sentry, and other integrations:
# Frontend Environment Variables
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
VITE_APP_TITLE=LabLink
VITE_SENTRY_DSN=your_sentry_dsn_optional
VITE_API_BASE_URL=your_api_base_urlnpm run devThe app runs on port 5173 (Vite default) - navigate to http://localhost:5173
npm run create-test-usersThe project includes Replit-ready configuration. Ensure environment variables are present in workspace settings.
| Component | Technology | Deployment Target |
|---|---|---|
| Frontend | Vite/React 18.3.1 | Vercel, Netlify, Cloudflare Pages |
| Backend | Supabase | Supabase Cloud |
| Edge Functions | Supabase Edge Functions | Supabase Dashboard |
| Database | PostgreSQL | Supabase Managed |
| PWA | Vite PWA Plugin | CDN + Service Worker |
| Variable | Purpose | Required |
|---|---|---|
VITE_SUPABASE_URL |
Supabase project URL | β |
VITE_SUPABASE_ANON_KEY |
Supabase anonymous key | β |
VITE_APP_TITLE |
Application title | β |
VITE_SENTRY_DSN |
Error tracking | β |
VITE_API_BASE_URL |
Custom API proxy | β |
| Variable | Purpose | Required |
|---|---|---|
SUPABASE_SERVICE_ROLE_KEY |
Privileged operations | β |
SUPABASE_URL |
Supabase project URL | β |
DATABASE_URL |
Database connection | β |
SENTRY_DSN |
Error tracking | β |
NODE_ENV |
Environment | β |
PORT |
Server port | β |
| Command | Purpose |
|---|---|
npm run dev |
Start Vite dev server with SEO verification |
npm run build |
Create production build with optimizations |
npm run build:dev |
Create development build |
npm run preview |
Serve build locally |
npm run lint |
ESLint linting |
npm run format |
Prettier formatting |
npm run test |
Unit tests |
npm run create-test-users |
Automated test user creation |
npm run verify-test-data |
Validate test fixtures |
npm run verify:seo |
Verify SEO files and metadata |
npm run generate:sitemap |
Generate sitemap.xml |
npx playwright test |
Run E2E tests |
[Browser / Mobile UI]
β
[Frontend (Vite/React 18)]
β
[Supabase Client SDK]
β
[Supabase Edge Functions]
β
[Postgres (RLS + WAL)]
β
[Storage: file uploads]
β
[Service Worker (PWA)]
- Roles:
doctor,lab_staff,admin(RLS policies enforce per-row access) - Marketplace:
auto_assign_pendingorders, eligible labs apply - Notifications: Real-time via Postgres changes β client subscription channels
- Files: Storage with server-side validation (file type, size, content-type checks)
- Chat: Real-time messaging with file sharing and typing indicators
- PWA: Offline support, installable app, background sync
40+ migrations documented in supabase/migrations/
users,user_roles,labs,orders,order_itemsapplications,invoices,files,notificationsaudit_logs,badges,challenges,migrations_meta,settingschat_messages,chat_participants,message_reactions
CREATE POLICY "Doctors can view own orders"
ON orders FOR SELECT
USING (auth.uid() = doctor_id);Migrations are applied using Supabase CLI or psql.
- Supabase Auth handles signup/signin
- Social providers configurable via Supabase dashboard
- Onboarding requires
onboarding_completed = truefor marketplace access - Multi-factor authentication support
- Doctors: CRUD their own orders, view own chat/files
- Lab Staff: Access orders assigned to their lab or applied marketplace orders
- Admins: Elevated privileges via service role
- Chat Access: Only participants can view/edit messages
| Function | Purpose |
|---|---|
secure-login |
Server-side login flows with privileged keys |
file-validation |
Validate uploaded files (MIME types, magic bytes, size) |
invoice-generator |
Create invoice PDFs |
webhook-handler |
Process external webhooks |
chat-notifications |
Send real-time chat notifications |
Deploy with: supabase functions deploy
// Order updates
const subscription = supabase
.channel('order-updates')
.on('postgres_changes', {
event: '*',
schema: 'public',
table: 'orders',
filter: `doctor_id=eq.${doctorId}`
}, payload => {
// Handle update
})
.subscribe();
// Chat messages
const chatSubscription = supabase
.channel(`chat-${conversationId}`)
.on('postgres_changes', {
event: '*',
schema: 'public',
table: 'chat_messages',
filter: `conversation_id=eq.${conversationId}`
}, payload => {
// Handle new message
})
.subscribe();| Endpoint | Method | Purpose |
|---|---|---|
/edge/secure-login |
POST | Server-side login |
/edge/validate-file |
POST | File validation before upload |
/edge/generate-invoice |
POST | Invoice PDF generation |
/edge/webhook |
POST | External notifications |
/edge/chat-notifications |
POST | Chat real-time notifications |
Fetch Orders:
const { data, error } = await supabase
.from('orders')
.select('*')
.eq('doctor_id', supabase.auth.getUser().id);Apply to Marketplace Order:
// Insert into applications table
await supabase
.from('applications')
.insert({
lab_id: labId,
order_id: orderId,
staff_id: userId
});Send Chat Message:
await supabase
.from('chat_messages')
.insert({
conversation_id: conversationId,
sender_id: userId,
content: messageText,
attachment_ids: attachmentIds
});- React 18.3.1 + TypeScript
- Vite 5.4.19 build tool with SWC
- shadcn-ui component library
- Tailwind CSS 3.4 styling
- React Query 5.83 for data fetching
- Framer Motion 12.23 for animations
- React Router 6.30 for routing
- Zod 3.25 for schema validation
- PWA Plugin 0.21 for offline support
src/
βββ components/ # Reusable UI components
βββ pages/ # Page-level components/routes
βββ lib/ # API/supabase helpers, types, utilities
βββ hooks/ # Custom React hooks
βββ utils/ # Utility functions
supabase/
βββ migrations/ # Database migrations
βββ functions/ # Edge functions
βββ policies/ # RLS policies
public/
βββ manifest.json # PWA manifest
βββ service-worker.js # Service worker for offline
scripts/
βββ generate-sitemap.ts # SEO sitemap generation
βββ verify-seo-files.ts # SEO verification
- Upload to Supabase Storage
- Validate via edge function before persisting
- Store metadata in
filestable referencing storage paths - Support for multiple file formats (DCM, STL, OBJ, images)
- Offline support with service worker
- Installable app (add to home screen)
- Push notifications
- Background sync for pending orders
- Optimized asset caching
# Run all tests
npx playwright test
# UI mode (recommended for debugging)
npx playwright test --ui
# Headed mode (see browser)
npx playwright test --headed
# Run specific test file
npx playwright test e2e/auto-assign-workflow.spec.tsTest Files:
order-creation.spec.ts- Order form and creation floworder-workflow.spec.ts- Complete order lifecyclechat-functionality.spec.ts- Real-time messagingauto-assign-workflow.spec.ts- Marketplace auto-assignmenterror-cases.spec.ts- Error handling and edge casesinvoicing.spec.ts- Invoice generationload-testing.spec.ts- Performance and stress testing
| Role | Password | Lab ID | |
|---|---|---|---|
| Doctor | doctor.test@lablink.test |
TestDoctor123! |
N/A |
| Lab Staff | lab.staff@lablink.test |
TestLabStaff123! |
00000000-0000-0000-0000-000000000001 |
# Run load tests (staging environment only)
npx playwright test e2e/load-testing.spec.ts --workers=10For detailed load testing guide, see e2e/load-testing-README.md
- Row-Level Security (RLS) in Postgres
- Supabase Auth for sessions and JWTs
- Edge Functions for sensitive server-side operations
- Multi-factor authentication support
- Secure password hashing with bcrypt
// Server-side checks
const allowedTypes = ['dcm', 'stl', 'obj', 'jpg', 'png', 'pdf'];
const maxSize = 50 * 1024 * 1024; // 50MB
const mimeTypes = ['image/jpeg', 'image/png', 'application/pdf'];- Implement at edge function or CDN level
- Protect resource-intensive endpoints
- Prevent chat message spam
- Throttle file uploads
All privileged actions write to audit_logs including:
user_id,action,resource_idtimestamp,ip_address,changes
- DOMPurify for HTML sanitization
- XSS protection via Content Security Policy
- CSRF tokens for state-changing operations
| Component | Monitoring Tool |
|---|---|
| Frontend Errors | Sentry (VITE_SENTRY_DSN) |
| Server Errors | Sentry (Server DSN) |
| Database Performance | Supabase Analytics |
| Application Logs | Console + Structured Logging |
| PWA Analytics | Web Vitals, offline usage |
Automated testing and deployment pipelines configured in .github/workflows/
Key Stages:
- Lint & Format Check
- Type Checking
- Unit Tests
- E2E Tests (Playwright)
- Build Optimization
- Deployment to Staging/Production
- Build:
npm run build(optimized production bundle) - Deploy Static Assets: Vercel/Netlify/Cloudflare Pages
- Database Migrations: Supabase CLI (auto on deployment)
- Edge Functions:
supabase functions deploy - Service Worker: Auto-updated via PWA plugin
| Issue | Solution |
|---|---|
| "User not found" in tests | Run npm run create-test-users |
| "No available orders" in marketplace | Create order with auto_assign_pending = true |
| Authentication fails locally | Check Supabase environment variables in .env.local |
| Edge function permission errors | Verify SUPABASE_SERVICE_ROLE_KEY is set |
| Playwright test failures | Use data-testid attributes for stable selectors |
| File upload rejected | Check file validation edge function logs |
| PWA not installing | Ensure HTTPS in production, check manifest.json |
| Chat messages not syncing | Verify Realtime enabled in Supabase dashboard |
| SEO verification fails | Run npm run verify:seo to check metadata |
Enable debug logging:
// In development
const supabase = createClient(url, key, {
auth: {
debug: true
}
});feature/- New featuresfix/- Bug fixeschore/- Maintenance tasksdocs/- Documentation updatesperf/- Performance improvements
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'feat: Add amazing feature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
# Lint code
npm run lint
# Format code
npm run format
# Run tests
npm run test
# Check SEO compliance
npm run verify:seo- Use conventional commits:
feat:,fix:,docs:,style:,refactor:,perf:,test: - Reference issues:
fixes #123 - Keep commits atomic and focused
- Auto-assign marketplace functionality
- Real-time chat and notifications
- PWA offline support
- Mobile app optimization
- Advanced analytics dashboard
- SLA management features
- Advanced analytics & performance dashboards
- Automated SLA reminders
- SLA-based routing in auto-assign
- Multi-tenant separation for labs
- Integration APIs for third-party systems
- Bulk order import/export
- Mobile app (React Native)
- Enhanced push notifications
- ML-based lab recommendations
- ETA prediction algorithms
- Marketplace monetization flows
- Video consultation support
- AR/3D preview capabilities
const subscription = supabase
.channel('order-updates')
.on('postgres_changes', {
schema: 'public',
table: 'orders',
event: '*'
}, payload => {
console.log('Order changed:', payload);
})
.subscribe();.
βββ README.md # This file
βββ .env.example # Environment template
βββ e2e/ # Playwright tests and test data
βββ src/ # Frontend application code
βββ supabase/ # Database migrations, RLS policies, functions
βββ public/ # Static assets & PWA manifest
βββ scripts/ # Build and utility scripts
βββ .github/workflows/ # CI/CD pipelines
βββ playwright.config.ts # Playwright configuration
βββ vite.config.ts # Vite configuration
βββ tailwind.config.ts # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
βββ package.json # Dependencies and scripts
βββ LICENSE # MIT License
- Use React Query for server state management
- Leverage code splitting with React Router lazy loading
- Optimize images with modern formats (WebP)
- Enable compression in production
- Monitor Core Web Vitals with Sentry
- Use service worker for intelligent caching
- React DevTools browser extension
- Redux DevTools for state inspection
- Supabase Studio for database inspection
- Playwright Inspector for E2E debugging
- Network tab in Chrome DevTools
- All environment variables properly set
- Service role keys never exposed
- RLS policies enabled on all tables
- File uploads validated server-side
- HTTPS enabled in production
- CSP headers configured
- Rate limiting enabled
- Audit logging configured
- Supabase Documentation
- React Documentation
- Vite Guide
- Playwright Testing
- Tailwind CSS
- shadcn/ui Components
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using modern web technologies and best practices.
| Role | Contact |
|---|---|
| Product/Feature Inquiries | Product Owner |
| Infrastructure & Deployment | DevOps Team |
| Code & Pull Requests | Create PR against main branch |
| Bug Reports | Create issue with reproduction steps |
LabLink - Streamlining dental lab workflows through innovative technology solutions.
Last updated: July 2026 | Created with Vite + React + Supabase