Skip to content

photsathonspd1-create/cardvault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

111 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸƒ CardVault Thailand

Marketplace ΰΈ‹ΰΈ·ΰΉ‰ΰΈ­-ΰΈ‚ΰΈ²ΰΈ’ΰΈΰΈ²ΰΈ£ΰΉŒΰΈ” TCG ΰΈ—ΰΈ΅ΰΉˆΰΉƒΰΈ«ΰΈΰΉˆΰΈ—ΰΈ΅ΰΉˆΰΈͺΰΈΈΰΈ”ΰΉƒΰΈ™ΰΈ›ΰΈ£ΰΈ°ΰΉ€ΰΈ—ΰΈ¨ΰΉ„ΰΈ—ΰΈ’

Tech Stack

  • Framework: Next.js 14 (App Router + Server Actions)
  • Language: TypeScript (strict mode)
  • Database: PostgreSQL + Prisma 5
  • Auth: NextAuth.js v5 (JWT)
  • UI: Tailwind CSS v3 + shadcn/ui
  • Rate Limiting: Upstash Redis
  • Card OCR: Tesseract.js
  • Card API: Pokemon TCG API (pokemontcg.io)

Features

  • 🏠 Homepage with hero section, featured listings, browse by series
  • πŸ” Browse listings with filters (series, condition, price, graded)
  • πŸ“„ Listing detail with image gallery, seller info, buy button
  • πŸ” Email + Password authentication + LINE Login (OAuth)
  • πŸ’³ Omise payment integration (PromptPay QR + Credit Card)
  • πŸ“Š Seller analytics with revenue charts + tier progress
  • πŸ›‘οΈ KYC verification system
  • πŸ’Ž Subscription plans (FREE / PRO / BUSINESS)
  • πŸ† Seller tier auto-upgrade (Bronze β†’ Silver β†’ Gold β†’ Verified Pro)
  • πŸ“± Community forum with TCG categories
  • πŸ” Scammer database + public check page
  • πŸ“ˆ Price history charts (30/90/180 days)
  • πŸ”” Email + in-app notification system
  • πŸ›‘οΈ Edge middleware (auth guard + security headers)
  • πŸ“ Multi-step create listing form
  • πŸ“Š Seller dashboard with listings and orders
  • πŸ›’ Order flow: buy β†’ checkout β†’ payment β†’ confirmation
  • πŸ’° Escrow system with auto-release (7 days)
  • πŸ‘€ User profile with seller badge and reviews
  • πŸ”§ Admin panel: listing approval, user management, disputes
  • πŸ–ΌοΈ Card identification via OCR (Tesseract.js) + Pokemon TCG API
  • ⚑ Rate limiting on all sensitive endpoints

Quick Start

Prerequisites

  • Node.js 18+
  • PostgreSQL 14+

1. Install dependencies

npm install

2. Set up environment

cp .env.example .env.local
# Edit .env.local with your credentials (see .env.example for all options)

3. Set up database

# Generate Prisma client
npx prisma generate

# Push schema to database
npx prisma db push

# Seed with mock data
npm run db:seed

4. Run development server

npm run dev

Open http://localhost:3000

Test Accounts

Role Email Password
Admin admin@cardvault.co.th password123
Seller seller1@example.com password123
Seller seller3@example.com password123
Buyer buyer1@example.com password123

Project Structure

cardvault/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ (auth)/          # Login, Register pages
β”‚   β”œβ”€β”€ (main)/          # Main layout with header/footer
β”‚   β”‚   β”œβ”€β”€ browse/      # Browse listings
β”‚   β”‚   β”œβ”€β”€ listing/     # Listing detail
β”‚   β”‚   β”œβ”€β”€ checkout/    # Checkout flow
β”‚   β”‚   β”œβ”€β”€ orders/      # Buyer orders
β”‚   β”‚   └── profile/     # User profile
β”‚   β”œβ”€β”€ sell/            # Seller pages
β”‚   β”‚   β”œβ”€β”€ new/         # Create listing (multi-step)
β”‚   β”‚   β”œβ”€β”€ listings/    # My listings
β”‚   β”‚   └── orders/      # Seller orders
β”‚   β”œβ”€β”€ admin/           # Admin panel
β”‚   β”‚   β”œβ”€β”€ listings/    # Approve/reject listings
β”‚   β”‚   β”œβ”€β”€ disputes/    # Manage disputes
β”‚   β”‚   └── users/       # User management
β”‚   └── api/             # API routes
β”‚       β”œβ”€β”€ auth/        # NextAuth + register
β”‚       β”œβ”€β”€ listings/    # CRUD listings
β”‚       β”œβ”€β”€ orders/      # Create orders
β”‚       β”œβ”€β”€ cards/       # Card identification (OCR)
β”‚       β”œβ”€β”€ upload/      # File upload
β”‚       β”œβ”€β”€ webhooks/    # Omise payment webhooks
β”‚       └── cron/        # Escrow auto-release
β”œβ”€β”€ components/
β”‚   β”œβ”€β”€ ui/              # shadcn/ui components
β”‚   └── shared/          # Header, Footer, Sidebar
β”œβ”€β”€ lib/                 # Utilities, auth, rate limiting
β”œβ”€β”€ services/            # Business logic (escrow, card identify)
└── prisma/              # Schema + seed data

API Rate Limits

Endpoint Limit
/api/cards/identify 20 req/hr/user
/api/upload/* 30 req/10min/user
/api/orders POST 20 req/hr/user
/api/listings POST 10 req/hr/user
/api/auth/login 5 req/15min/IP

Escrow System

  1. Buyer pays β†’ funds held in escrow (HOLDING)
  2. Seller ships β†’ order marked SHIPPED
  3. Buyer confirms receipt β†’ funds released (RELEASED)
  4. Auto-release after 7 days if no response
  5. Dispute freezes escrow (FROZEN)

Deployment (Vercel)

  1. Push to GitHub
  2. Connect to Vercel
  3. Set environment variables in Vercel dashboard (see .env.example)
  4. Vercel Cron runs /api/cron/escrow-release daily at 20:00 UTC (3:00 AM ICT)

Required env vars for production:

  • DATABASE_URL β€” PostgreSQL connection string
  • NEXTAUTH_SECRET β€” Random string (32+ chars)
  • NEXTAUTH_URL β€” Your domain (https://cardvault.co.th)
  • OMISE_PUBLIC_KEY / OMISE_SECRET_KEY β€” Omise payment keys
  • R2_* β€” Cloudflare R2 credentials for image storage
  • RESEND_API_KEY β€” Resend email API key

Optional:

  • LINE_CLIENT_ID / LINE_CLIENT_SECRET β€” LINE Login
  • UPSTASH_REDIS_REST_URL / UPSTASH_REDIS_REST_TOKEN β€” Redis rate limiting
  • POKEMON_TCG_API_KEY β€” Card identification API

License

MIT

New in This Update

Payment System (Omise)

  • PromptPay QR code payment
  • Credit card payment via Omise.js
  • Webhook handler for payment confirmation
  • Automatic escrow hold on payment

Seller System

  • Tier system: Bronze β†’ Silver β†’ Gold β†’ Verified Pro (auto-upgrade)
  • KYC verification: ID card + selfie upload
  • Analytics dashboard: Revenue charts, top cards, conversion rate
  • Subscriptions: FREE / PRO / BUSINESS plans

Community

  • Forum threads grouped by TCG category
  • Post feed with card tagging and listing links
  • Like, comment, and bookmark

Trust & Safety

  • Public scammer database (/check)
  • Community scammer reports with admin review
  • Auto-check against blacklist during KYC

Security

  • Edge middleware with auth + role guards
  • Security headers (HSTS, X-Frame-Options, etc.)
  • Rate limiting on all sensitive endpoints
  • R2 presigned URL validation (type + size)

About

πŸ‡ΉπŸ‡­ TCG Card Marketplace for Thailand β€” Next.js 14, Prisma, Escrow, Card Scanner

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages