Skip to content

sepehr-safari/mkauction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Nostr Art Auctions

A decentralized art auction platform built on the Nostr protocol with Lightning Network payments. Discover, bid on, and sell unique digital artworks in a censorship-resistant environment.

Nostr Art Auctions React TypeScript Tailwind CSS Lightning

✨ Features

  • 🎨 Art Auctions: Create and participate in time-based art auctions
  • ⚑ Lightning Payments: Instant Bitcoin payments via Lightning Network
  • πŸ”„ Smart Extensions: Auto-extending auctions for fair bidding
  • 🌍 Global Shipping: Support for local and international shipping
  • πŸ” Decentralized: Built on Nostr protocol - no central authority
  • πŸ“± Responsive: Works seamlessly on desktop and mobile
  • πŸŒ™ Dark Mode: Complete light/dark theme support
  • πŸ”’ Secure: WebLN integration for secure Lightning payments

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn
  • A Nostr client extension (like Alby, nos2x, or Flamingo)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd nostr-art-auctions
  2. Install dependencies

    npm install
  3. Start development server

    npm run dev
  4. Open your browser Navigate to http://localhost:8080

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run test - Run tests and linting
  • npm run deploy - Deploy to Surge.sh

πŸ—οΈ Technology Stack

Core Technologies

  • React 18.x - Modern React with hooks and concurrent rendering
  • TypeScript 5.x - Type-safe JavaScript development
  • Vite - Fast build tool and development server
  • TailwindCSS 3.x - Utility-first CSS framework

Nostr Integration

  • Nostrify - Nostr protocol framework for web
  • nostr-tools - Nostr utilities and cryptography
  • @nostrify/react - React hooks for Nostr integration

UI Components

  • shadcn/ui - 48+ accessible UI components built with Radix UI
  • Radix UI - Unstyled, accessible component primitives
  • Lucide React - Beautiful icon library
  • next-themes - Theme management system

State Management & Data

  • TanStack Query - Data fetching, caching, and synchronization
  • React Hook Form - Performant forms with easy validation
  • Zod - TypeScript-first schema validation

Routing & Navigation

  • React Router 6 - Client-side routing with BrowserRouter
  • ScrollToTop - Automatic scroll restoration

πŸ“ Project Structure

src/
β”œβ”€β”€ components/           # Reusable UI components
β”‚   β”œβ”€β”€ ui/              # shadcn/ui components (48+ components)
β”‚   β”œβ”€β”€ auth/            # Authentication components
β”‚   β”œβ”€β”€ NostrProvider.tsx # Nostr protocol integration
β”‚   └── Layout.tsx       # Main layout component
β”œβ”€β”€ hooks/               # Custom React hooks
β”‚   β”œβ”€β”€ useNostr.ts      # Core Nostr integration
β”‚   β”œβ”€β”€ useAuthor.ts     # Fetch user profiles
β”‚   β”œβ”€β”€ useCurrentUser.ts # Current user state
β”‚   └── useNostrPublish.ts # Publish events
β”œβ”€β”€ pages/               # Page components
β”‚   β”œβ”€β”€ Index.tsx        # Landing page
β”‚   β”œβ”€β”€ AuctionsPage.tsx # Browse auctions
β”‚   β”œβ”€β”€ AuctionDetailsPage.tsx # Individual auction
β”‚   β”œβ”€β”€ DashboardPage.tsx # User dashboard
β”‚   └── NotFound.tsx     # 404 page
β”œβ”€β”€ contexts/            # React context providers
β”‚   └── AppContext.tsx   # Global app configuration
β”œβ”€β”€ lib/                 # Utility functions
β”œβ”€β”€ test/                # Testing utilities
β”œβ”€β”€ App.tsx              # Main app component
└── AppRouter.tsx        # Route configuration

🎯 Core Features

Auction System

The platform implements a sophisticated auction system with the following features:

  • Time-based Auctions: Set start times and durations
  • Auto-extending: Bids in the last 5 minutes extend the auction
  • Reserve Prices: Optional minimum selling prices
  • Shipping Integration: Local and international shipping options
  • Real-time Updates: Live auction status via Nostr events

Nostr Protocol Integration

Built on custom NIP (Nostr Implementation Possibility) defining:

  • Kind 30020: Auction Listings (replaceable events)
  • Kind 1021: Bids
  • Kind 1022: Bid Confirmations
  • Kind 1023: Auction Status Updates

Lightning Network Payments

  • WebLN Integration: Seamless Lightning wallet connectivity
  • Instant Payments: Pay in satoshis with immediate settlement
  • NIP-57 Zaps: Lightning payments integrated with Nostr
  • Payment Requests: Encrypted payment coordination

πŸ”§ Development

Custom Hooks

The application provides several custom hooks for Nostr integration:

// Query Nostr data
const { nostr } = useNostr();
const auctions = useQuery({
  queryKey: ['auctions'],
  queryFn: () => nostr.query([{ kinds: [30020] }])
});

// Get user profile
const author = useAuthor(pubkey);
const displayName = author.data?.metadata?.name;

// Publish events
const { mutate: publish } = useNostrPublish();
publish({ kind: 1021, content: JSON.stringify(bidData) });

// Current user state
const { user } = useCurrentUser();

Component Architecture

Built with shadcn/ui components for consistency and accessibility:

import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader } from '@/components/ui/card';
import { LoginArea } from '@/components/auth/LoginArea';

Theme System

Complete light/dark mode support:

import { useTheme } from '@/hooks/useTheme';

const { theme, setTheme } = useTheme();
setTheme('dark'); // or 'light'

πŸ§ͺ Testing

The project includes comprehensive testing setup:

  • Vitest - Fast unit testing framework
  • React Testing Library - Component testing utilities
  • jsdom - Browser environment simulation
  • TypeScript - Type checking in tests
npm run test  # Run all tests

Test Structure

import { render, screen } from '@testing-library/react';
import { TestApp } from '@/test/TestApp';
import { MyComponent } from './MyComponent';

test('renders correctly', () => {
  render(
    <TestApp>
      <MyComponent />
    </TestApp>
  );
  expect(screen.getByText('Expected text')).toBeInTheDocument();
});

🌐 Deployment

Production Build

npm run build

Creates optimized production build in dist/ directory.

Deploy to Surge.sh

npm run deploy

Automatically builds and deploys to Surge.sh hosting.

Environment Configuration

The app connects to Nostr relays with these defaults:

  • Primary: wss://relay.nostr.band
  • Alternatives: Ditto, Damus, Primal relays

Configure via the relay selector in the UI.

πŸ” Security

Nostr Security

  • Private Key Protection: Never requests private keys directly
  • NIP-07 Signers: Uses browser extension signers
  • Event Validation: Validates all incoming Nostr events
  • Encrypted Messages: NIP-04 encryption for sensitive data

Lightning Security

  • WebLN Integration: Secure Lightning wallet connectivity
  • Payment Verification: Cryptographic payment proofs
  • Amount Validation: Client and server-side amount checks

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow TypeScript best practices
  • Use provided custom hooks for Nostr integration
  • Implement proper loading states with skeletons
  • Add tests for new components
  • Follow shadcn/ui patterns for new UI components

πŸ“š Documentation

Nostr Protocol

  • NIP-01 - Basic protocol flow
  • NIP-07 - Browser extension interface
  • NIP-57 - Lightning Zaps

Lightning Network

UI Components

πŸ“„ License

This project is open source and available under the MIT License.

πŸ™ Acknowledgments

  • Nostr Protocol - Decentralized social networking protocol
  • Lightning Network - Bitcoin's layer 2 payment solution
  • shadcn/ui - Beautiful and accessible UI components
  • Nostrify - Excellent Nostr development framework

Built with ❀️ for the decentralized web

Connect your Nostr identity and start exploring the future of digital art auctions!