๐ A comprehensive platform for managing user profiles and NFT certificates with blockchain integration.
- SIWE Authentication - Sign-In with Ethereum
- Profile Management - Avatar, personal info with IPFS storage
- NFT Certificate Sync - Fetch and display educational certificates from blockchain
- Dual Sync Modes - EduHub registry or allowlist-based filtering
- Auto Carousel - Beautiful NFT certificate display
- Responsive UI - Modern design with Tailwind CSS
- Frontend: Next.js 15.4.6, React 19, Tailwind CSS
- Backend: Next.js API Routes
- Database: PostgreSQL with Prisma ORM
- Blockchain: Ethers.js, wagmi, RainbowKit
- Storage: IPFS via Pinata
- NFT Data: Alchemy API
# Database
DATABASE_URL="postgresql://username:password@host:port/dbname"
# Session Management
SESSION_SECRET="your-super-secret-key-minimum-32-characters"
# Blockchain Network
CHAIN_ID=84532
# Base Sepolia = 84532, Ethereum Sepolia = 11155111
# RPC Provider
RPC_URL="https://base-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}"
# For Ethereum Sepolia: https://eth-sepolia.g.alchemy.com/v2/${ALCHEMY_API_KEY}
# Alchemy API (for NFT data)
ALCHEMY_API_KEY="your-alchemy-api-key"
ALCHEMY_NETWORK="base-sepolia"
# Options: "base-sepolia", "eth-sepolia"
# IPFS Storage (choose one)
PINATA_JWT="your-pinata-jwt-token"
# OR
WEB3STORAGE_TOKEN="your-web3storage-token"
# NFT Contract Filtering
EDUHUB_CONTRACT="0x62cd4e0C5B0D4587861a21710ed15ba1823a6341"
CERT_CONTRACTS="0x53654af9b177adcceeff7c9c10112de21c75fbbd5,0x7eb5ec96b0a1d9d753c68d56a99e241782fde47f,0xc75de08a33d98620d9722acb51f7d1e49660c412"
# Next.js Public Variables
NEXT_PUBLIC_CHAIN_ID=84532
NEXT_PUBLIC_APP_NAME="UNI Chain Profile"
NEXT_PUBLIC_APP_URL="https://your-app.vercel.app"
# Optional: Cron/Task Security
TASK_SECRET="your-cron-task-secret"
# Development Only
TEST_USER_ADDRESS="0x286db307079C9C92b55D20b33e4eAB6d2A588E54"- Vercel Account - vercel.com
- PostgreSQL Database - Managed service (Railway, PlanetScale, Supabase, etc.)
- Alchemy Account - For NFT data API
- Pinata Account - For IPFS storage
-
Create a PostgreSQL database on your preferred provider:
- Railway: railway.app (Recommended)
- PlanetScale: planetscale.com
- Supabase: supabase.com
- Neon: neon.tech
-
Copy the
DATABASE_URLconnection string
-
Connect Repository
# Install Vercel CLI (optional) npm i -g vercel # Or deploy via GitHub integration
-
Project Settings
- Framework Preset: Next.js
- Root Directory:
web - Build Command:
npm run build - Output Directory:
.next - Install Command:
npm install
-
Environment Variables
Go to your Vercel project โ Settings โ Environment Variables:
DATABASE_URL=postgresql://... SESSION_SECRET=your-super-secret-key-minimum-32-characters ALCHEMY_API_KEY=your-alchemy-api-key ALCHEMY_NETWORK=base-sepolia CHAIN_ID=84532 RPC_URL=https://base-sepolia.g.alchemy.com/v2/your-alchemy-api-key PINATA_JWT=your-pinata-jwt-token EDUHUB_CONTRACT=0x62cd4e0C5B0D4587861a21710ed15ba1823a6341 CERT_CONTRACTS=0x53654af9b177adcceeff7c9c10112de21c75fbbd5,0x7eb5ec96b0a1d9d753c68d56a99e241782fde47f,0xc75de08a33d98620d9722acb51f7d1e49660c412 NEXT_PUBLIC_CHAIN_ID=84532 NEXT_PUBLIC_APP_NAME=UNI Chain Profile NEXT_PUBLIC_APP_URL=https://your-app.vercel.app
-
Deploy
git push origin main # Vercel will auto-deploy
After first deployment, run database migration:
# Option 1: Via Vercel CLI
vercel env pull .env.local
npm run db:migrate
# Option 2: Via Vercel Functions (add build hook)
# Will run automatically during buildTest these features:
- โ Homepage loads
- โ Connect wallet (MetaMask, etc.)
- โ Sign-In with Ethereum (SIWE)
- โ Profile page accessible
- โ Avatar upload works
- โ NFT certificate sync works
- โ Profile editing and saving
# Clone repository
git clone https://github.com/Hpgbao2204/database-uni-chain.git
cd database-uni-chain
# Install dependencies
npm install
# Setup environment
cp web/.env.example web/.env
# Edit .env with your values
# Run database migration
cd web && npm run db:push
# Start development server
npm run devdatabase-uni-chain/
โโโ web/ # Next.js application
โ โโโ app/ # App router
โ โ โโโ api/ # API routes
โ โ โโโ profile/ # Profile page
โ โ โโโ page.tsx # Homepage
โ โโโ lib/ # Utilities
โ โโโ prisma/ # Database schema
โ โโโ public/ # Static files
โโโ scripts/ # Utility scripts
โโโ readEduNFTScript.ts # EduHub NFT reader
โโโ readCertNFTScript.ts # Allowlist NFT reader
โโโ README.md
GET /api/me- Get current user sessionGET /api/nonce- Get SIWE noncePOST /api/verify- Verify SIWE signatureGET /api/profile- Get user profilePOST /api/profile- Update user profilePOST /api/ipfs/upload- Upload file to IPFSGET /api/sync-nfts- Get stored NFT certificatesPOST /api/sync-nfts- Sync NFTs from blockchain
Two modes available:
POST /api/sync-nfts?mode=eduhubFilters NFTs using EduHub contract's isEduNFT() function.
POST /api/sync-nfts?mode=allowlistFilters NFTs using predefined contract allowlist.
-
Database Connection Error
- Verify
DATABASE_URLformat - Check database server status
- Ensure database exists
- Verify
-
SIWE Authentication Fails
- Check
SESSION_SECRETis set - Verify wallet network matches
CHAIN_ID - Clear browser cookies/localStorage
- Check
-
NFT Sync Not Working
- Verify
ALCHEMY_API_KEYis valid - Check contract addresses in
CERT_CONTRACTS - Ensure target address has NFTs
- Verify
-
IPFS Upload Fails
- Check
PINATA_JWTtoken validity - Verify file size limits (2MB max)
- Check file type restrictions
- Check
# Check Vercel logs
vercel logs
# Database status
npm run db:studio
# Test NFT scripts locally
npm run nft:cert [address]- โ Environment variables never exposed to client
- โ Session secrets properly configured
- โ SIWE message validation
- โ File upload size/type restrictions
- โ Database input sanitization
Monitor these metrics in production:
- Database connection health
- API response times
- IPFS upload success rates
- NFT sync success rates
- User authentication flows
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue on GitHub
- Contact: [your-email@example.com]
Built with โค๏ธ for the blockchain education community
- PostgreSQL + Prisma database
- Base Sepolia testnet support
- Pinata IPFS upload แบฃnh avatar
- Profile Management APIs (GET/POST)
- File Validation (2MB limit, image types)
- IPFS Gateway display images
- Zod Schema Validation
- NFT Certificate sync tแปซ Base Sepolia
- Advanced Profile fields (skills, achievements)
- Profile Sharing & export features
- Next.js 14 (App Router)
- TypeScript
- TailwindCSS
- RainbowKit + Wagmi
- React Hook Form + Zod
- Next.js API Routes
- NextAuth.js (SIWE adapter)
- Prisma ORM
- PostgreSQL
- Pinata IPFS API
- Ethereum wallet support
- Base Sepolia testnet
- SIWE authentication
- IPFS decentralized storage
git clone <repo-url>
cd database-uni-chainpnpm install# Copy environment files
cp web/.env.example web/.env
# Update vแปi credentials cแปงa bแบกn:
# - Database URL (PostgreSQL)
# - NextAuth Secret
# - Pinata JWT Tokencd web
pnpm db:push # Tแบกo database schemapnpm dev # Start Next.js serverVisit: http://localhost:3000
database-uni-chain/
โโโ web/ # Next.js application
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ auth/ # NextAuth.js routes
โ โ โ โโโ ipfs/ # IPFS upload API
โ โ โ โโโ profile/ # Profile management
โ โ โโโ profile/ # Profile editing page
โ โ โโโ page.tsx # Main dashboard
โ โโโ lib/
โ โ โโโ auth.ts # NextAuth config
โ โ โโโ db.ts # Prisma client
โ โ โโโ wagmi.ts # Wagmi config
โ โโโ prisma/
โ โ โโโ schema.prisma # Database schema
โ โโโ components/ # React components
โโโ contracts/ # Smart contracts (future)
โโโ scripts/ # Deployment scripts
โโโ docs/ # Documentation
GET /api/auth/session- Get current sessionPOST /api/auth/signin- SIWE login
GET /api/profile- Get user profilePOST /api/profile- Update profile
POST /api/ipfs/upload- Upload image to IPFS
- Click Connect Wallet
- Chแปn wallet (MetaMask, Coinbase, etc.)
- Switch to Base Sepolia network
- Click Sign-In with Ethereum
- Sign message trong wallet
- Session sแบฝ ฤฦฐแปฃc tแบกo
- Click Edit Profile
- Upload avatar image (โค2MB)
- ฤiแปn thรดng tin: name, bio, email
- Click Save Profile
- Avatar hiแปn thแป tแปซ IPFS gateway
- Profile data ฤฦฐแปฃc lฦฐu trong database
- Share profile link vแปi others
# Database
DATABASE_URL="postgresql://..."
# NextAuth.js
NEXTAUTH_SECRET="random-secret-key"
NEXTAUTH_URL="http://localhost:3000"
# Pinata IPFS
PINATA_JWT="eyJhbGciOiJIUzI1NiIs..."๐ Chi tiแบฟt setup: Xem PINATA_SETUP.md
- Start server:
pnpm dev - Connect wallet + authenticate
- Test profile upload & editing
- Verify IPFS image display
# Test profile API
curl -X GET http://localhost:3000/api/profile
# Test IPFS upload (with auth)
curl -X POST http://localhost:3000/api/ipfs/upload \
-H "Content-Type: multipart/form-data" \
-F "file=@avatar.jpg""PINATA_JWT not configured"
- Setup Pinata API key theo hฦฐแปng dแบซn
"Wallet connection failed"
- Switch to Base Sepolia testnet
- Add network manually nแบฟu cแบงn
"Database connection error"
- Kiแปm tra PostgreSQL running
- Verify DATABASE_URL correct
"Image upload failed"
- File size โค2MB
- Supported formats: JPEG, PNG, WebP, GIF
- Sync NFT certificates tแปซ Base Sepolia
- Display achievements & credentials
- Verify blockchain ownership
- Skill verification system
- Profile templates & themes
- Export profile as PDF/JSON
- Social sharing features
- Mainnet deployment
- Performance optimization
- Security audit
- Mobile app support
- Fork repository
- Create feature branch
- Make changes & test
- Submit pull request
MIT License - see LICENSE file
- Issues: GitHub Issues
- Discord: [UNI Chain Community]
- Email: support@unichain.dev
Built with โค๏ธ for UNI Chain community