lib/hedera.ts- Hedera blockchain operations (batch registry creation, verification)lib/hedera2Client.ts- Hedera client configuration and initializationlib/verifySignature.ts- Digital signature verification for batches
lib/prisma.ts- Prisma ORM client (singleton pattern)prisma/schema.prisma- Database schema (organizations, batches, transfers, team members)
middleware.ts- Route protection and role-based access controlutils/routes.ts- Route definitions (public, auth, protected)utils/getRedirectPath.ts- Role-based dashboard routing
app/api/batches/route.ts- Create and list batchesapp/api/batches/[orgId]/route.ts- Get batches by organizationapp/api/verify/batch/[batchId]/route.ts- Verify batch on blockchainapp/api/verify/unit/[serialNumber]/route.ts- Verify individual units
app/api/transfer/ownership/route.ts- Initiate batch transfersapp/api/transfer/ownership/[transferId]/route.ts- Accept/reject transfersapp/api/transfers/route.ts- List all transfers
app/api/organizations/me/route.ts- Get current user's organizationapp/api/organizations/info/route.ts- Get organization detailsapp/api/organizations/[id]/route.ts- Organization CRUD operations
app/api/team-members/route.ts- Team member managementapp/api/register/team-member/route.ts- Team member registration
app/dashboard/manufacturer/page.tsx- Manufacturer dashboard (batch creation, QR generation)app/dashboard/hospital/page.tsx- Hospital dashboard (inventory, receiving)app/dashboard/drug-distributor/page.tsx- Distributor dashboard (warehouse, shipments)app/dashboard/pharmacy/page.tsx- Pharmacy dashboard (dispensing)app/dashboard/regulator/page.tsx- Regulatory oversight dashboard
components/manufacturer-page-component/- Manufacturer UI componentscomponents/hospital-page-component/- Hospital UI componentscomponents/distributor-page-component/- Distributor UI components
components/qr-scanner.tsx- QR code scanner componentcomponents/qr-generator.tsx- QR code generationlib/qrPayload.ts- QR payload structure and validation
lib/manufacturer-data.ts- Sample manufacturer datalib/mockaroo-service.ts- Mock data generation servicelib/transfer-utils.ts- Transfer helper functions
app/page.tsx- Landing page (hero, features, CTA)app/scan/page.tsx- Public scanning interfaceapp/verify/batch/[batchId]/page.tsx- Batch verification pageapp/privacy-policy/page.tsx- Privacy policyapp/terms-of-service/page.tsx- Terms of serviceapp/contact/page.tsx- Contact form
app/auth/login/page.tsx- Organization loginapp/auth/register/page.tsx- Organization registrationapp/auth/team-member-login/page.tsx- Team member login
- Manufacturer creates batch →
POST /api/batches - Hedera registry created →
lib/hedera.ts - Batch saved to database → Prisma
- QR codes generated →
components/QRGenerationComponent.tsx
- Initiate transfer →
POST /api/transfer/ownership - Blockchain event logged → Hedera
- Recipient receives notification
- Accept/reject →
PUT /api/transfer/ownership/[id] - Ownership updated in database
- User scans QR code →
app/scan/page.tsx - Redirect to verification →
/verify/batch/[batchId] - Fetch blockchain data →
GET /api/verify/batch/[batchId] - Display verification results
components/ui/- shadcn/ui base components (button, card, input, etc.)components/theme-provider.tsx- Dark/light modecomponents/theme-toggle.tsx- Theme switcher
components/batch-management.tsx- Batch CRUD operationscomponents/transfer-ownership.tsx- Transfer interfacecomponents/Transfers.tsx- Transfer historycomponents/team-management.tsx- Team member managementcomponents/AnalyticsDashboard.tsx- Analytics and charts
/dashboard/*- Requires authentication- Role-based access control per route
- Automatic redirection for unauthorized access
- Immutable records on Hedera
- Digital signatures for authenticity
- Public verification without authentication
- Mobile-first approach
- Tailwind CSS for styling
- Adaptive layouts for all screen sizes
- Mobile-optimized QR scanner
Organization- Companies in supply chainBatch- Medication batchesBatchUnit- Individual medication unitsTransfer- Ownership transfer recordsTeamMember- Organization team membersUser- Clerk authentication users
DATABASE_URL- PostgreSQL connectionNEXT_PUBLIC_CLERK_*- Clerk authenticationHEDERA_*- Hedera network credentialsNEXT_PUBLIC_APP_URL- Application URL
- TypeScript compilation
- Prisma client generation
- Next.js optimization
- Asset bundling
Note: This is a high-level overview. Each file contains specific implementation details. Refer to individual files for detailed logic and business rules.