A modern, full-featured supply chain traceability platform built with Next.js, TypeScript, Tailwind CSS, and Prisma. This project enables transparent asset management, service subscriptions, payments, access control, QR code generation, and mobile app distribution.
- Features
- Tech Stack
- Architecture Overview
- Requirements
- Setup & Installation
- Environment Variables
- Folder Structure
- User Flows
- API & UI Overview
- Subscription & Payment Logic
- Access Control
- QR Code & App Download
- Docker & Deployment
- Troubleshooting
- Contribution
- License
- Service Management: Create, update, delete, and list services and subscriptions. Admins can define service plans, pricing, and durations.
- Subscription & Payment: Users can subscribe, renew, or upgrade services. Payments are processed via Cardano (ADA) blockchain, with transaction hashes stored for traceability.
- Access Control: All key features (minting, utilities, services) are protected and only accessible to users with an active subscription. UI and backend both enforce access rules.
- QR Code Generator: Generate QR codes for mobile app download (APK, App Store, Google Play). QR codes are branded and can be scanned by any device.
- Collection & Utilities: Organize and manage asset collections, upload and manage files, and use utility tools for supply chain management.
- Mobile App Download: Distribute the Android APK directly, or link to App Store/Google Play. Download links and QR codes are always up-to-date.
- Dockerized: All services can be run in Docker containers for easy deployment and scaling. Includes production and development Dockerfiles.
- Frontend: Next.js (App Router), React 19, TypeScript, Tailwind CSS
- Backend: Next.js API routes, Prisma ORM (PostgreSQL)
- Authentication: NextAuth.js (supports social and wallet login)
- Blockchain: Cardano Mesh SDK for on-chain payments and asset management
- Other: Docker, Docker Compose, Husky (git hooks), Jest (testing)
- Monorepo: All client, contract, and schema code in a single repository for easy management.
- Prisma ORM: Centralized data model for users, services, subscriptions, payments, products, collections, and more. See
prisma/schema.prismafor details. - Next.js App Router: Modern routing, server components, and API endpoints. All business logic is colocated with UI for maintainability.
- Access Control: Implemented at both UI (menu-list, route guards) and backend (API checks). Unauthorized users are redirected or shown disabled UI.
- Payment Logic: Cardano blockchain integration for secure, auditable payments. Transaction hashes are stored and verified.
- Mobile App Distribution: APK is placed in
public/, QR code generator and store badges are in the UI. Download page and QR code generator are always in sync.
- Node.js 20+
- PostgreSQL (local or cloud)
- (Optional) Docker & Docker Compose for containerized deployment
- Cardano wallet (for payment testing)
git clone <repo-url>
cd client
npm install- Copy
.env.exampleto.envand fill in all required variables:DATABASE_URL(PostgreSQL connection string)BLOCKFROST_API_KEY,KOIOS_TOKEN(Cardano API keys)NEXT_PUBLIC_APP_NETWORK(mainnet, preview, preprod)NEXT_PUBLIC_APP_URL_MAINNET,NEXT_PUBLIC_APP_URL_PREVIEWIPFS_ENDPOINT,NEXT_PUBLIC_IPFS_GATEWAY(optional)
npx prisma generate
npx prisma migrate devnpm run dev- The app will be available at
http://localhost:3000by default.
All environment variables are documented in src/constants/app-environment.ts and .env.example.
DATABASE_URL- PostgreSQL connection stringBLOCKFROST_API_KEY,KOIOS_TOKEN- Cardano blockchain API keysNEXT_PUBLIC_APP_NETWORK- Network selection (mainnet, preview, preprod)NEXT_PUBLIC_APP_URL_MAINNET,NEXT_PUBLIC_APP_URL_PREVIEW- Public URLs for different networksIPFS_ENDPOINT,NEXT_PUBLIC_IPFS_GATEWAY- For IPFS integration (optional)
src/app- Next.js app routes & pages (dashboard, services, utilities, etc.)src/components- UI components (menu, QR code, subscription, etc.)src/services- Business logic (CRUD, payment, subscription, access control)prisma/- Prisma schema & migrationspublic/- Static files (APK, images, QR badges, store badges)contract/- Cardano smart contract scripts (Aiken)
- Step 1: User logs in or registers (NextAuth.js, wallet or social login)
- Step 2: User navigates to Services page and selects a service plan
- Step 3: User initiates payment (ADA via Cardano wallet). The UI guides the user through wallet connection and transaction signing.
- Step 4: On successful payment, the backend verifies the transaction and creates/renews the subscription in the database. Payment details (amount, txHash, date) are stored for audit.
- Step 5: User can view, renew, or upgrade their subscription at any time. Upgrades to more expensive plans are handled with proration and correct end date calculation.
- Step 1: On login, the app checks the user's subscription status via API.
- Step 2: Menu items and routes (mint, home, utilities, services) are enabled/disabled based on subscription status. This is enforced in both UI (
menu-list.tsx) and backend (API route guards). - Step 3: If a user without an active subscription tries to access a protected route, they are redirected to the subscription/payment page or shown a disabled UI.
- Step 1: User navigates to the QR code generator or download page.
- Step 2: The app displays QR codes for APK, App Store, and Google Play download links. Store badges are shown for easy access.
- Step 3: The APK file is placed in
public/app-release.apkfor direct download. App Store and Google Play links are configurable. - Step 4: Users scan the QR code with their mobile device to download or install the app.
- Step 1: User manages collections and assets via the utilities section.
- Step 2: Users can upload files, manage metadata, and use utility tools for supply chain management.
- Service CRUD:
/dashboard/services(list, create, update, delete services) - Subscription Page:
/dashboard/services/subscription(view current status, renew, upgrade) - Payment Page:
/dashboard/services/payment(initiate and confirm payment) - Collection Management:
/dashboard/utilities/collection(manage asset collections) - QR Code Generator:
/dashboard/utilities/qrcode(generate and download QR codes) - APK Download:
/download(direct APK download or via QR code) - Access Control: All protected routes check subscription status before rendering content.
- All payment and subscription logic is implemented in
src/services/database/payment/index.ts. - New Subscription:
- User selects a plan and pays via Cardano wallet.
- Backend verifies payment and creates a new subscription record.
- Renewal:
- If the user already has a subscription, the end date is extended.
- Upgrade:
- If the user upgrades to a more expensive plan, the system calculates the new end date and updates the subscription accordingly.
- Payment Records:
- All payments are recorded with user ID, subscription ID, amount, currency, txHash, and payment date.
- Access Control:
- Subscription status is checked before allowing access to protected features/routes.
- UI Enforcement:
- Menu and routes are dynamically enabled/disabled based on subscription status. See
src/components/menu-list.tsxandsrc/constants/routes.ts. - Disabled menu items are visually distinct and cannot be clicked.
- Menu and routes are dynamically enabled/disabled based on subscription status. See
- Backend Enforcement:
- API routes check subscription status before processing requests.
- Unauthorized users are redirected or shown an error message.
- QR Code Generator:
- Implemented in
src/components/qrcode-generator.tsx. - Generates QR codes for APK, App Store, and Google Play download links.
- Store badges are in
public/assets/and displayed alongside QR codes.
- Implemented in
- APK Download:
- Place the latest APK in
public/app-release.apk. - The download page and QR code generator will automatically link to the latest APK.
- Place the latest APK in
- App Store/Google Play:
- Links are configurable and displayed with QR codes and badges.
- Build & run with Docker:
docker-compose up --build
- Dockerfile and docker-compose.yml are provided for both production and local development.
- Port Configuration:
- The app runs on port 3000 by default. Change
APP_PORTin.envordocker-compose.ymlif needed.
- The app runs on port 3000 by default. Change
- Database:
- Ensure PostgreSQL is running and accessible from the container.
- Production Deployment:
- Use
Dockerfilefor production builds. For Portainer or other orchestrators, useDockerfile.portaineranddocker-compose-portainer.yml.
- Use
- Database Issues:
- Ensure PostgreSQL is running and
DATABASE_URLis correct. - Run
npx prisma migrate devto apply migrations.
- Ensure PostgreSQL is running and
- Docker Issues:
- Check for port conflicts and ensure all services are healthy.
- Use
docker-compose logsto view logs and debug issues.
- Payment/Subscription Issues:
- Check Cardano API keys and network settings.
- Ensure the wallet is funded and connected.
- Review logs for errors in payment or subscription flows.
- General Debugging:
- Use
npm run lintto check for code issues. - Use
npm run testto run tests (if implemented). - Check browser console and server logs for errors.
- Use
We welcome contributions from the community! To contribute:
- Fork the repository and create a new branch for your feature or bugfix.
- Write clear, well-documented code and include tests if possible.
- Run
npm run lintand ensure all checks pass. - Submit a pull request with a clear description of your changes.
- For major changes, please open an issue or discussion first.
MIT. See LICENSE for details.