Skip to content

Apillon/pixelproof

Repository files navigation

Pixelproof

Your photos, your control

A decentralized alternative to Google Photos built on Polkadot. Store memories on IPFS, control access with smart contracts, and own your data forever. No more privacy concerns or platform lock-ins.

Pixelproof React TypeScript Polkadot

✨ Features

πŸ“Έ Photo Management

  • Upload & Store: Upload photos directly to IPFS via Apillon storage
  • Albums: Organize photos into custom albums/collections
  • Favorites: Mark your favorite photos for quick access
  • Gallery Views: Multiple viewing options including masonry and grid layouts
  • Search & Sort: Find photos quickly with search and sorting capabilities
  • Album Sharing: Share albums with other users via blockchain-based access control
  • Shared Albums View: View and access albums shared with you by other users

πŸ” Wallet Integration

  • Apillon Embedded Wallet: Seamless login with passkey authentication
  • Substrate Wallets: Support for Polkadot.js, SubWallet, and Talisman extensions
  • Session Management: Persistent wallet sessions with automatic reconnection

🎨 User Experience

  • Dark Mode: Beautiful dark theme with persistent preferences
  • Responsive Design: Works seamlessly on desktop and mobile devices
  • Real-time Updates: Automatic polling for IPFS link generation
  • Optimistic UI: Instant feedback for uploads and deletions
  • User Guides: Built-in help menu with guides for key features

πŸ›‘οΈ Decentralized Storage

  • IPFS Integration: Photos stored on InterPlanetary File System
  • Blockchain Authentication: Secure access via Polkadot wallets
  • Data Ownership: You own your data, stored on decentralized infrastructure
  • Storage Quotas: 3GB free tier, upgrade to 10GB with one-time payment

πŸ”’ Smart Contract Access Control

  • Blockchain-Based Sharing: Grant and revoke album access using smart contracts on Moonbeam
  • Per-Album Permissions: Control access to individual albums with Substrate addresses
  • On-Chain Verification: All access permissions are verified on the blockchain
  • Address Conversion: Automatic conversion between Substrate (SS58) and EVM (H160) formats
  • Shared Albums Discovery: Automatically discover albums shared with you via blockchain events

πŸ’Ž Premium Features

  • Storage Upgrade: One-time payment of $9.99 to upgrade from 3GB to 10GB
  • NFT Proof of Ownership: Premium membership verified via NFT on blockchain
  • Stripe Integration: Secure payment processing with automatic NFT minting
  • Lifetime Access: Pay once, keep your premium storage forever

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • A Polkadot wallet extension (optional, for Substrate wallet login)
  • Apillon account and API credentials (for storage)

Installation

  1. Clone the repository

    git clone https://github.com/Apillon/pixelproof.git
    cd pixelproof
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # Apillon API Credentials
    APILLON_API_KEY=your_api_key_here
    APILLON_API_SECRET=your_api_secret_here
    APILLON_NFT_COLLECTION_UUID=your_nft_collection_uuid
    
    # Apillon Client ID (for embedded wallet)
    NEXT_PUBLIC_APILLON_CLIENT_ID=your_client_id_here
    
    # Stripe Configuration (optional - for storage upgrades)
    STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key
    STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key
    
    # Application URL
    NEXT_PUBLIC_BASE_URL=http://localhost:3000
    
    # JWT Secret (for authentication tokens)
    # Generate a secure random string for production (e.g., using openssl rand -hex 32)
    JWT_SECRET=your-secret-key-change-in-production
    
    # Smart Contract Configuration (for album access control)
    CONTRACT_ADDRESS=0x...  # AlbumAccessControl contract address on Moonbeam
    PRIVATE_KEY=your_private_key_here  # Server-side wallet private key for contract transactions
    
    # Optional: Moonbeam API key for contract verification
    MOONBEAM_API_KEY=your_moonscan_api_key

    You can get Apillon credentials from the Apillon Dashboard.

    For Stripe payment setup, see STRIPE_SETUP.md for detailed instructions.

  4. Run the development server

    npm run dev
  5. Open your browser

    Navigate to http://localhost:3000 (or the port shown in your terminal)

Building for Production

npm run build
npm start

πŸ“ Project Structure

pixelproof/
β”œβ”€β”€ app/                          # Next.js app directory
β”‚   β”œβ”€β”€ api/                      # API routes
β”‚   β”‚   β”œβ”€β”€ albums/               # Album access control
β”‚   β”‚   β”‚   β”œβ”€β”€ access/           # Grant/revoke/check album access
β”‚   β”‚   β”‚   └── shared/           # Shared albums discovery and metadata
β”‚   β”‚   β”œβ”€β”€ nft/                  # NFT operations
β”‚   β”‚   β”‚   β”œβ”€β”€ mint/             # Mint NFT for premium users
β”‚   β”‚   β”‚   └── check/            # Check NFT ownership
β”‚   β”‚   β”œβ”€β”€ storage/              # Storage API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ bucket/           # Bucket management
β”‚   β”‚   β”‚   β”œβ”€β”€ file/             # File operations
β”‚   β”‚   β”‚   β”œβ”€β”€ files/            # File listing & upload
β”‚   β”‚   β”‚   β”œβ”€β”€ folders/          # Folder/album operations
β”‚   β”‚   β”‚   └── ipfs/             # IPFS link generation
β”‚   β”‚   └── stripe/               # Stripe payment integration
β”‚   β”‚       β”œβ”€β”€ checkout/         # Create checkout session
β”‚   β”‚       └── webhook/          # Handle payment events
β”‚   β”œβ”€β”€ components/               # React components
β”‚   β”‚   β”œβ”€β”€ LoginModal.tsx        # Wallet login modal
β”‚   β”‚   └── WalletProvider.tsx    # Wallet context provider
β”‚   β”œβ”€β”€ home/                     # Main application pages
β”‚   β”‚   β”œβ”€β”€ components/          # Home page components
β”‚   β”‚   β”‚   β”œβ”€β”€ AlbumCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ AlbumView.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CreateAlbumModal.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Gallery.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ImageCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ImageCinemaView.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ MasonryGallery.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ StorageQuotaIndicator.tsx  # Storage quota display
β”‚   β”‚   β”‚   β”œβ”€β”€ UpgradeModal.tsx           # Storage upgrade modal
β”‚   β”‚   β”‚   β”œβ”€β”€ ManageAccessModal.tsx      # Album access control modal
β”‚   β”‚   β”‚   └── UploadModal.tsx
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ useStorage.ts              # Storage operations hook
β”‚   β”‚   β”‚   └── useStorageQuota.ts         # Storage quota check hook
β”‚   β”‚   └── page.tsx              # Main home page
β”‚   β”œβ”€β”€ layout.tsx                # Root layout
β”‚   └── page.tsx                   # Landing page
β”œβ”€β”€ lib/                          # Utility libraries
β”‚   β”œβ”€β”€ DotSamaWallet.ts          # Polkadot wallet integration
β”‚   β”œβ”€β”€ SubstrateWallet.ts        # Substrate wallet utilities
β”‚   β”œβ”€β”€ walletSession.ts          # Session management
β”‚   β”œβ”€β”€ albumAccessControl.ts     # Smart contract client for access control
β”‚   β”œβ”€β”€ addressConversion.ts      # Substrate/EVM address conversion utilities
β”‚   └── types/
β”‚       └── wallet.ts             # TypeScript types
β”œβ”€β”€ contracts/                    # Smart contracts
β”‚   └── AlbumAccessControl.sol    # Album access control contract
β”œβ”€β”€ scripts/                      # Deployment scripts
β”‚   β”œβ”€β”€ deploy.ts                 # Contract deployment script
β”‚   └── interact.ts               # Contract interaction examples
β”œβ”€β”€ test/                         # Contract tests
β”‚   └── AlbumAccessControl.test.ts
β”œβ”€β”€ data/                         # Application data
β”‚   └── shared-albums.json        # Shared album metadata
β”œβ”€β”€ public/                       # Static assets
└── tests/                        # Test documentation

πŸ§ͺ Testing

This project includes a comprehensive test suite using Jest and React Testing Library.

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Generate coverage report
npm run test:coverage

Test Coverage

  • βœ… API routes (bucket, file, files, folders, ipfs, albums/access, albums/shared)
  • βœ… Wallet utilities (DotSamaWallet, SubstrateWallet, walletSession)
  • βœ… React hooks (useStorage, useStorageQuota)
  • βœ… React components (LoginModal, WalletProvider)
  • βœ… Smart contracts (AlbumAccessControl)

See tests/README.md for detailed testing documentation.

πŸ”§ Technology Stack

Frontend

  • Next.js 15 - React framework with App Router
  • React 19 - UI library
  • TypeScript - Type safety
  • Tailwind CSS - Utility-first CSS framework
  • Lucide React - Icon library

Blockchain & Storage

  • Apillon SDK - Decentralized storage, NFT minting, and wallet integration
  • Polkadot - Blockchain network
  • IPFS - Decentralized file storage
  • @polkadot/extension-inject - Polkadot wallet extension integration
  • Stripe - Secure payment processing for storage upgrades
  • Moonbeam - EVM-compatible Polkadot parachain for smart contracts
  • Ethers.js - Ethereum/Moonbeam blockchain interaction
  • Hardhat - Smart contract development and deployment

Development Tools

  • Jest - Testing framework
  • React Testing Library - Component testing
  • ESLint - Code linting
  • TypeScript - Static type checking
  • Hardhat - Smart contract development framework
  • TypeChain - TypeScript bindings for smart contracts

πŸ“– Usage Guide

First Time Setup

  1. Launch the app and click "Enter App"
  2. Choose your wallet:
    • Apillon Wallet: Click the Apillon button and authenticate with passkey
    • Substrate Wallet: Select your wallet extension (Polkadot.js, SubWallet, or Talisman) and choose an account
  3. Start uploading: Your first bucket will be created automatically

Uploading Photos

  1. Click the Upload button in the header
  2. Select one or more image files (PNG, JPEG, WebP supported)
  3. Optionally select or create an album
  4. Click Upload - photos will be uploaded to IPFS

Managing Albums

  • Create Album: Click "Create Album" in the sidebar
  • View Album: Click on an album name in the sidebar
  • Delete Album: Right-click on an album and select delete

Organizing Photos

  • Favorites: Click the heart icon on any photo to add to favorites
  • Search: Use the search bar in the header to find photos by name
  • Sort: Use the sort dropdown to organize by name or date

Sharing Albums

  1. Open an album: Click on an album name in the sidebar
  2. Manage Access: Click the "Manage Access" button in the album view
  3. Grant Access: Enter a Substrate address (SS58 format) and click "Add"
  4. View Shared Albums: Albums shared with you will appear in your sidebar with a "Shared" indicator
  5. Revoke Access: Click the trash icon next to an address in the Manage Access modal

Note: Album sharing uses smart contracts on Moonbeam. Access permissions are stored on-chain and verified automatically.

Upgrading Storage

  1. Check your quota: Look for the storage indicator in the header (shows 3GB by default)
  2. Click Upgrade: Click the "Upgrade" button next to your storage quota
  3. Review plans: Compare Free (3GB) vs Premium (10GB) plans
  4. Complete payment: Click "Upgrade Now" and complete the $9.99 one-time payment via Stripe
  5. NFT minting: After successful payment, an NFT will be automatically minted to your wallet
  6. Enjoy 10GB: Your storage quota will be upgraded to 10GB permanently!

For detailed Stripe setup instructions, see STRIPE_SETUP.md.

Smart Contract Setup

If you want to deploy and use the album access control smart contract:

  1. Deploy the contract: See SMART_CONTRACTS.md for detailed instructions
  2. Set environment variables: Add CONTRACT_ADDRESS and PRIVATE_KEY to your .env.local
  3. Test the integration: Use the "Manage Access" feature in any album to grant/revoke access

The contract enables decentralized, on-chain access control for album sharing. All access permissions are stored on the Moonbeam blockchain and verified automatically.

πŸ” Security & Privacy

  • Decentralized Storage: All photos are stored on IPFS, not on centralized servers
  • Wallet Authentication: Access is controlled via blockchain wallets
  • No Data Collection: We don't track or collect your personal data
  • Client-Side Encryption: Wallet sessions are stored locally in your browser
  • Blockchain-Based Access Control: Album sharing permissions are stored on-chain and cannot be tampered with
  • Smart Contract Security: Access control is enforced by smart contracts on Moonbeam
  • Address Validation: All Substrate addresses are validated before granting access

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

Development Guidelines

  • Follow TypeScript best practices
  • Write tests for new features
  • Follow the existing code style
  • Update documentation as needed

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Apillon - Decentralized infrastructure platform
  • Polkadot - Blockchain network
  • IPFS - InterPlanetary File System

πŸ“ž Support

Built with ❀️ by the Apillon team

Empowering users to own their data in a decentralized world.

Releases

No releases published

Packages

No packages published