A student-only marketplace platform for buying and selling textbooks, electronics, furniture, and other items within college communities. Built with Next.js, MongoDB, and blockchain payment integration.
UniMarket is a verified student marketplace that connects buyers and sellers within the same academic community. The platform ensures security through .edu email verification and student ID validation, while providing a seamless trading experience with zero transaction fees.
- Email-based authentication with .edu domain validation
- Student ID verification using OCR and AI (OpenRouter API)
- Automatic name extraction from student IDs
- Role-based access (Buyer/Seller)
- Secure session management with NextAuth.js
- User profiles with name and username (email) display
- Create, edit, and manage product listings
- Multiple image uploads with automatic compression
- Product categorization and search
- Product boosting for increased visibility
- Wishlist functionality
- Product comparison tools
- Real-time chat between buyers and sellers
- Image support in messages
- Conversation management
- Message read receipts
- Automatic buyer/seller role detection based on product context
- Product context in conversations
- Blockchain payments via Solana and Ethereum/Arbitrum
- Payment history tracking
- Transaction verification
- Support for listing fees and product boosts
- Seller earnings tracking (separate ETH and SOL balances)
- Platform wallet integration for seller claims
- Separate claim buttons for ETH and SOL earnings
- User profiles and avatars
- Order management
- Review and rating system
- Price alerts
- Saved searches
- Activity feed
- Analytics dashboard for sellers
- Next.js 16.0.3 (App Router)
- React 19.2.0
- TypeScript
- Tailwind CSS 4.1.17
- Radix UI components
- Framer Motion for animations
- Wagmi and Viem for Ethereum integration
- Solana Web3.js for Solana integration
- Next.js API Routes
- NextAuth.js for authentication
- MongoDB 5.9.2 for database
- bcryptjs for password hashing
- Nodemailer/Resend for email services
- Solana blockchain integration
- Ethereum/Arbitrum integration
- Hardhat for smart contract development
- Local blockchain node support
- Cloudinary for image hosting
- Tesseract.js for OCR
- OpenRouter API for AI-powered ID verification (using OpenAI GPT models)
- bs58 for Solana keypair encoding/decoding
Before you begin, ensure you have the following installed:
- Node.js 20.x or higher
- npm or yarn
- MongoDB (local or Atlas connection string)
- Git
- Clone the repository:
git clone <repository-url>
cd blockchain_hackathon- Install dependencies:
npm install-
Set up environment variables (see Environment Variables section)
-
Start the development server:
npm run devThe application will be available at http://localhost:3000
Create a .env.local file in the root directory with the following variables:
# Database
MONGODB_URI=mongodb://localhost:27017/college-marketplace
# Or for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/database-name
# NextAuth
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-here
# Application URL
NEXT_PUBLIC_APP_URL=http://localhost:3000
# Email Configuration (choose one)
# Option 1: Resend
RESEND_API_KEY=your-resend-api-key
# Option 2: Nodemailer (SMTP)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your-email@gmail.com
SMTP_PASS=your-app-password
# Cloudinary (for image hosting)
CLOUDINARY_CLOUD_NAME=your-cloud-name
CLOUDINARY_API_KEY=your-api-key
CLOUDINARY_API_SECRET=your-api-secret
# OpenRouter API (for ID verification)
OPENROUTER_API_KEY=your-openrouter-api-key
OPENROUTER_API_URL=https://openrouter.ai/api/v1/chat/completions
OPENROUTER_MODEL=openai/gpt-5.1-codex-mini
# Platform Wallet Configuration (for seller claims)
# Ethereum/Arbitrum platform wallet private key
PLATFORM_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
NEXT_PUBLIC_PLATFORM_ETH_ADDRESS=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
# Solana platform wallet private key (base58 or JSON array format)
PLATFORM_SOL_PRIVATE_KEY=your-solana-private-key
NEXT_PUBLIC_PLATFORM_SOL_ADDRESS=12SogrSHvLfLV9jnjDmhjgq1tgGBcGvFXvSv1XNAhWR7
# Blockchain Configuration
# Solana
NEXT_PUBLIC_SOLANA_NETWORK=devnet
# Or: mainnet-beta, testnet
NEXT_PUBLIC_SOLANA_RPC=http://127.0.0.1:8899
# Or for public: https://api.devnet.solana.com
# Ethereum/Arbitrum
NEXT_PUBLIC_ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc
# Or for local: http://localhost:8545You can generate a secure secret using:
openssl rand -base64 32The application uses MongoDB and automatically creates collections as needed. No manual schema setup is required.
- Ensure MongoDB is running locally or you have a MongoDB Atlas connection string
- Update
MONGODB_URIin your.env.localfile - Start the application - collections will be created automatically on first use
The project includes a database reset script for development purposes. This will drop all collections and allow you to start with a fresh database.
Warning: This will delete all data in your database.
To reset the database:
npm run reset-dbOr run directly:
node scripts/reset-database.jsThe script will:
- Connect to your MongoDB database using
MONGODB_URI - List all existing collections
- Drop all collections
- Confirm the reset is complete
After resetting, you'll need to:
- Create a new user account
- Verify your email
- Upload your student ID for verification
- Start creating listings
npm run devStarts the development server with hot-reloading at http://localhost:3000
npm run build
npm startnpm run lintblockchain_hackathon/
├── app/ # Next.js app directory
│ ├── auth/ # Authentication pages
│ ├── browse/ # Product browsing
│ ├── chat/ # Messaging system
│ ├── components/ # React components
│ │ ├── ui/ # UI component library
│ │ └── ... # Feature components
│ ├── dashboard/ # User dashboard
│ ├── onboarding/ # Student ID verification
│ ├── payments/ # Payment history
│ ├── products/ # Product pages
│ ├── seller/ # Seller-specific pages
│ └── ...
├── pages/
│ └── api/ # API routes
│ ├── auth/ # Authentication endpoints
│ ├── messages/ # Chat endpoints
│ ├── payments/ # Payment endpoints
│ ├── products/ # Product endpoints
│ └── ...
├── lib/ # Utility libraries
│ ├── blockchain/ # Blockchain integration
│ │ ├── claim.ts # Seller earnings claims (ETH/SOL)
│ │ ├── payment.ts # Payment processing
│ │ ├── arbitrum.ts # Arbitrum/Ethereum integration
│ │ └── solana.ts # Solana integration
│ ├── format.ts # Name formatting utilities
│ ├── mongodb.ts # Database connection
│ └── ...
├── scripts/ # Utility scripts
│ └── reset-database.js # Database reset script
├── components/ # Shared components
└── public/ # Static assets
POST /api/auth/register- Register new userPOST /api/auth/verifyEmail- Verify email addressPOST /api/auth/sendVerification- Resend verification email
GET /api/products- List products with filtersPOST /api/products- Create new productGET /api/products/[id]- Get product detailsPUT /api/products/[id]- Update productDELETE /api/products/[id]- Delete product
GET /api/messages- Get user conversationsPOST /api/messages- Create new conversationGET /api/messages/[conversationId]- Get conversation messagesPOST /api/messages/[conversationId]- Send message
GET /api/payments- Get payment historyPOST /api/payments/confirm- Confirm paymentPOST /api/payments/verify- Verify transaction
GET /api/seller/earnings- Get seller earnings breakdown (ETH and SOL)POST /api/seller/claim- Claim seller earnings (ETH or SOL)
GET /api/users/current- Get current userGET /api/users/[id]- Get user profileGET /api/users/stats- Get user statistics
POST /api/id/upload- Upload student ID for verification (extracts name, student ID, university)
The application supports Solana payments through the Phantom wallet adapter. Transactions are processed on the Solana network (configurable between devnet, testnet, and mainnet).
Ethereum and Arbitrum payments are handled through Wagmi and Viem. The application supports:
- MetaMask and Gemini Wallet connection
- Transaction signing and confirmation
- Local Arbitrum node support for development
- Platform wallet integration for seller earnings claims
Sellers can track and claim their earnings separately for ETH and SOL:
- Earnings are tracked separately by payment method
- Separate claim buttons for ETH and SOL earnings
- Claims are sent from the platform wallet to the seller's connected wallet
- Automatic wallet address detection from connected wallet
- Transaction verification and confirmation
For local development, you can run a local Arbitrum node:
./START_LOCAL_NODES.shThis script starts a local Hardhat node for testing blockchain transactions.
The application includes automatic image compression for uploads:
- Images are compressed client-side before upload
- Maximum dimensions: 1920x1920 pixels
- JPEG quality: 80% (reduced to 30% if still over 500KB)
- Maximum file size: 10MB before compression
Users must verify their .edu email address before accessing the platform. Verification emails are sent using either:
- Resend API (recommended)
- SMTP via Nodemailer
The platform uses OCR and AI to verify student IDs:
- User uploads a photo of their student ID
- Tesseract.js extracts text from the image
- OpenRouter API (using OpenAI GPT models) verifies and extracts structured information
- Extracted name is automatically saved to the user's profile
- User is marked as verified upon successful validation
The verification process extracts:
- Full name (automatically set as account name)
- Student ID number
- University/Institution name
- Expiration date (if available)
- Push your code to GitHub
- Import the repository in Vercel
- Add environment variables in Vercel dashboard
- Deploy
The application can be deployed to any platform that supports Next.js:
- Netlify
- AWS Amplify
- Railway
- DigitalOcean App Platform
Ensure all environment variables are set in your deployment platform.
- TypeScript for type safety
- ESLint for code linting
- Functional components with hooks
- Server components where appropriate
- Use MongoDB collections as needed
- Collections are created automatically
- Use indexes for frequently queried fields
- All API routes are in
pages/api/ - Use NextAuth session for authentication
- Validate input data
- Return appropriate HTTP status codes
- Verify
MONGODB_URIis correct - Check MongoDB is running (if local)
- Verify network access (if using Atlas)
- Ensure
NEXTAUTH_SECRETis set - Check
NEXTAUTH_URLmatches your domain - Verify email service is configured
- Check Cloudinary credentials
- Verify file size limits
- Check network connectivity
- Verify wallet is connected
- Check network configuration (devnet/testnet/mainnet)
- Ensure sufficient balance for transactions
- Verify platform wallet private keys are set correctly
- Check platform wallet has sufficient balance for claims
- Ensure OpenRouter API key is set
- Verify OpenRouter API URL and model are configured
- Check image quality and format (JPEG/PNG, max 5MB)
- Ensure student ID is clearly visible in the image
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is private and proprietary. All rights reserved.
For issues and questions, please open an issue in the repository or contact the development team.
Built with Next.js, React, MongoDB, and various open-source libraries. Special thanks to the Radix UI team for the excellent component library.