Skip to content

Maldivian pet marketplace for all the furry, feathery, and scaly friends! Shop supplies, manage stores, track orders across islands. Built with Next.js while Totoro, Jojo, and Roro supervised (Pudding approves when she visits). Learning full-stack dev one screm at a time! 🏝️

Notifications You must be signed in to change notification settings

MystSugar/pet-realm

Repository files navigation

🐾 Pet Realm

A comprehensive e-commerce platform for pet supplies and services across the Maldives

Pet Realm connects pet owners with local shops, veterinary clinics, and pet service providers throughout the Maldivian atolls and islands. Built with modern web technologies and designed specifically for the unique geographic and business needs of the Maldives.

Version Next.js TypeScript License


✨ Features

For Customers

  • Browse & Search - Discover pet supplies and services across the Maldives
  • Shopping Cart - Easy cart management with single-shop validation
  • Order Tracking - Real-time order status with detailed timeline
  • Flexible Delivery - Choose pickup or delivery based on shop availability
  • Email Notifications - Stay updated on order status changes
  • Profile Management - Manage your account and order history

For Shop Owners

  • Shop Setup - Multi-step wizard to get your shop online quickly
  • Product Management - Create, edit, and manage products with multiple images
  • Dashboard - Track revenue, orders, and key metrics
  • Delivery Zones - Configure custom delivery areas and fees
  • Payment Verification - Review and verify receipt uploads
  • Order Management - Process orders with status tracking

Platform Features

  • Secure Authentication - Email verification and password reset
  • Maldivian Location System - Atoll and island-based addressing
  • Responsive Design - Optimized for mobile, tablet, and desktop
  • Image Management - Up to 5 images per product with R2 cloud storage
  • Receipt-Based Payments - Manual payment verification via receipt upload
  • Multi-Region Support - Delivery across different atolls and islands

Quick Start

Prerequisites

  • Node.js 18+ and pnpm
  • PostgreSQL database
  • Resend API key (for emails)
  • Cloudflare R2 bucket (for image storage)

Installation

  1. Clone the repository

    git clone https://github.com/MystSugar/pet-realm.git
    cd pet-realm
  2. Install dependencies

    pnpm install
  3. Set up environment variables

    Create a .env file in the root directory:

    # Database
    DATABASE_URL="postgresql://user:password@localhost:5432/pet_realm"
    
    # NextAuth
    NEXTAUTH_SECRET="your-secret-key-here"
    NEXTAUTH_URL="http://localhost:3000"
    
    # Email (Resend)
    RESEND_API_KEY="re_xxxxxxxxxxxxx"
    EMAIL_FROM="Pet Realm <noreply@yourdomain.com>"
    
    # Cloudflare R2 Storage
    R2_ACCOUNT_ID="your-r2-account-id"
    R2_ACCESS_KEY_ID="your-r2-access-key"
    R2_SECRET_ACCESS_KEY="your-r2-secret-key"
    R2_BUCKET_NAME="pet-realm-receipts"
    R2_PUBLIC_URL="https://your-r2-public-url.com"
    
    # R2 Shop Images
    R2_SHOP_IMAGES_BUCKET_NAME="pet-realm-shop-images"
    R2_SHOP_IMAGES_PUBLIC_URL="https://your-shop-images-url.com"
    
    # App
    NEXT_PUBLIC_APP_URL="http://localhost:3000"
  4. Set up the database

    # Push schema to database
    pnpm prisma db push
    
    # Or run migrations
    pnpm prisma migrate deploy
    
    # Generate Prisma client
    pnpm prisma generate
  5. Seed the database (optional)

    pnpm db:seed
  6. Run the development server

    pnpm dev
  7. Open your browser

    Navigate to http://localhost:3000


πŸ—οΈ Project Structure

pet-realm/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma          # Database schema
β”‚   β”œβ”€β”€ seed.ts                # Database seeding
β”‚   └── migrations/            # Database migrations
β”œβ”€β”€ public/
β”‚   └── uploads/               # Local file uploads (dev only)
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                   # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ api/              # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/         # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ cart/         # Shopping cart endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ checkout/     # Order creation
β”‚   β”‚   β”‚   β”œβ”€β”€ orders/       # Order management
β”‚   β”‚   β”‚   β”œβ”€β”€ products/     # Product endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ shop/         # Shop management (seller)
β”‚   β”‚   β”‚   β”œβ”€β”€ shops/        # Shop listing (public)
β”‚   β”‚   β”‚   └── user/         # User profile endpoints
β”‚   β”‚   β”œβ”€β”€ auth/             # Auth pages (signin, register, etc.)
β”‚   β”‚   β”œβ”€β”€ shop/             # Seller dashboard pages
β”‚   β”‚   β”œβ”€β”€ marketplace/      # Product browsing
β”‚   β”‚   β”œβ”€β”€ cart/             # Shopping cart page
β”‚   β”‚   β”œβ”€β”€ checkout/         # Checkout page
β”‚   β”‚   β”œβ”€β”€ orders/           # Order history
β”‚   β”‚   └── ...               # Other pages
β”‚   β”œβ”€β”€ components/           # React components
β”‚   β”‚   β”œβ”€β”€ auth/            # Auth forms
β”‚   β”‚   β”œβ”€β”€ cart/            # Cart components
β”‚   β”‚   β”œβ”€β”€ checkout/        # Checkout flow
β”‚   β”‚   β”œβ”€β”€ layouts/         # Layout components
β”‚   β”‚   β”œβ”€β”€ marketplace/     # Product listing
β”‚   β”‚   β”œβ”€β”€ orders/          # Order displays
β”‚   β”‚   β”œβ”€β”€ products/        # Product cards
β”‚   β”‚   β”œβ”€β”€ shop/            # Seller components
β”‚   β”‚   β”œβ”€β”€ ui/              # Reusable UI components
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ useAuth.ts      # Authentication hook
β”‚   β”‚   β”œβ”€β”€ useCart.ts      # Shopping cart hook
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ lib/                 # Utility libraries
β”‚   β”‚   β”œβ”€β”€ auth.ts         # NextAuth configuration
β”‚   β”‚   β”œβ”€β”€ prisma.ts       # Prisma client
β”‚   β”‚   β”œβ”€β”€ email.ts        # Email utilities
β”‚   β”‚   β”œβ”€β”€ validations/    # Zod schemas
β”‚   β”‚   └── utils/          # Helper functions
β”‚   β”œβ”€β”€ types/              # TypeScript types
β”‚   └── middleware.ts       # Next.js middleware
β”œβ”€β”€ CHANGELOG.md            # Version history
β”œβ”€β”€ package.json            # Dependencies
└── README.md              # This file

πŸ› οΈ Tech Stack

Category Technology
Framework Next.js 15.1 with App Router
Language TypeScript 5
Database PostgreSQL with Prisma ORM 6.19
Authentication NextAuth.js (JWT sessions)
Styling Tailwind CSS 4
Email Resend API
Storage Cloudflare R2 (S3-compatible)
Validation Zod
UI Components Radix UI
Package Manager pnpm

πŸ“Š Database Schema

Core Models

  • User - Customer, Seller, or Admin accounts
  • Shop - Shop profiles and settings
  • Product - Product listings with images and details
  • Order - Customer orders with status tracking
  • OrderItem - Individual items in orders
  • CartItem - Shopping cart items
  • ContactSubmission - Contact form submissions

Authentication Models (NextAuth)

  • Account - OAuth accounts
  • Session - Database sessions (currently using JWT)
  • VerificationToken - Email verification tokens

πŸ” Authentication Flow

  1. Registration

    • User signs up with email, phone, and ID verification
    • Email verification token sent
    • Account remains unverified until email confirmed
  2. Email Verification

    • Click link in verification email
    • Token validated and marked as verified
    • Account activated
  3. Sign In

    • Email/password authentication
    • JWT token created (30-day expiry)
    • Stored in HTTP-only cookie
  4. Password Reset

    • Request reset via email
    • Reset token sent to email
    • New password set via token link

πŸ›’ E-commerce Flow

Customer Journey

Browse Marketplace β†’ View Product β†’ Add to Cart β†’ Checkout β†’ 
Upload Receipt β†’ Seller Verifies β†’ Order Status Updates β†’ Delivered/Picked Up

Seller Journey

Setup Shop β†’ Add Products β†’ Receive Order β†’ Verify Payment β†’ 
Update Status β†’ Fulfill Order

Order States

  1. PENDING - Order placed, awaiting receipt upload
  2. CONFIRMED - Receipt verified, order confirmed
  3. PREPARING - Shop preparing the order
  4. READY - Ready for pickup
  5. OUT_FOR_DELIVERY - Out for delivery
  6. DELIVERED - Successfully delivered
  7. PICKED_UP - Customer picked up order
  8. CANCELLED - Order cancelled

🚒 Deployment

Environment Setup

  1. Set up PostgreSQL database (e.g., Supabase, Railway, Neon)
  2. Configure R2 buckets in Cloudflare
  3. Get Resend API key for email
  4. Set all environment variables

Build & Deploy

# Build for production
pnpm build

# Start production server
pnpm start

Recommended Platforms

  • Vercel - Optimized for Next.js
  • Railway - Easy database + app hosting
  • Fly.io - Global edge deployment

πŸ§ͺ Development

Available Scripts

pnpm dev          # Start development server
pnpm build        # Build for production
pnpm start        # Start production server
pnpm lint         # Run ESLint
pnpm db:seed      # Seed database with sample data

Database Commands

# Generate Prisma client
pnpm prisma generate

# Create migration
pnpm prisma migrate dev --name your_migration_name

# Apply migrations
pnpm prisma migrate deploy

# Open Prisma Studio
pnpm prisma studio

# Reset database (dev only)
pnpm prisma migrate reset

See CHANGELOG.md for version history and GitHub Issues for planned features.


πŸ“– Learning Goals

This project serves as a comprehensive learning experience for:

  • Modern Next.js 15 development with App Router
  • TypeScript and type-safe development
  • Database design and Prisma ORM
  • Authentication and authorization patterns
  • E-commerce platform architecture
  • Cloud storage and email services
  • GitHub workflows and versioning
  • Project management and documentation

🀝 Contributing

This is currently a personal learning project. Contributions are not being accepted at this time, but feel free to fork and adapt for your own learning!


πŸ“„ License

Proprietary - All rights reserved. This is a personal learning project.


πŸ‘¨β€πŸ’» Author

MystSugar


🦜 Special Thanks to the QA Team

This project wouldn't exist without the constant supervision and "helpful" feedback from:

  • Totoro 🀍 - Head of Quality Assurance (Cockatiel Division). Expert at finding bugs by screaming at 4PM.
  • Jojo πŸ’š - Senior Code Reviewer. Named after a certain bizarre adventure. Provides feedback exclusively in chirps and aggressive keyboard inspections.
  • Roro (Rose) 🩷 - Chief Motivational Officer. Specializes in moral support and head bobs.
  • Pudding (Pood) πŸ’› - Visiting Consultant (Kakariki Advisory Board). Offers expert judgment on all architectural decisions, mostly while giving speeches.

All commits are birb-approved. Most compile errors are definitely their fault. 🐦✨


About

Maldivian pet marketplace for all the furry, feathery, and scaly friends! Shop supplies, manage stores, track orders across islands. Built with Next.js while Totoro, Jojo, and Roro supervised (Pudding approves when she visits). Learning full-stack dev one screm at a time! 🏝️

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages