A comprehensive IPFS (InterPlanetary File System) Identity-based Ring Signatures sandbox environment with private network support, featuring a secure gateway architecture and cross-platform mobile application with dual-mode operation.
This project implements a complete IPFS private network with the following components:
- Express.js Gateway: Secure API gateway with exclusive IPFS access
- Private IPFS Network: 3-node storage network with shared swarm key
- Database: Prisma ORM with SQLite for users, files, and signatures
- Cryptography: Ring signatures implementation using node-forge
- Docker Orchestration: Containerized infrastructure with health monitoring
- React Native: Cross-platform mobile app (iOS/Android)
- Dual-Mode Operation: Online (gateway integration) and Offline (mock layer)
- File Management: Document picker, image picker, and comprehensive file operations
- IPFS Integration: Complete CRUD operations with private IPFS network
- Modern UI: TypeScript-based with theme support and real-time status monitoring
- Docker Desktop installed and running
- Node.js 20+ (for development)
- Git
- React Native Environment (for mobile development)
- iOS: Xcode, CocoaPods
- Android: Android Studio, Android SDK
git clone <repository-url>
cd ipfs-sandbox
# Start entire IPFS system (backend + storage nodes)
./start-system.sh
Step 1: Get Your Machine's IP Address
# macOS/Linux
ifconfig | grep "inet " | grep -v "127.0.0.1"
# Output example: inet 192.168.1.69 netmask 0xffffff00
# Windows
ipconfig
# Look for IPv4 Address under your active network adapter
Step 2: Update Mobile App Configuration
cd mobile/src/config/api.ts
Edit line 17 and replace with your IP:
const HOST_MACHINE_IP = '192.168.1.69'; // π CHANGE THIS TO YOUR IP
Step 3: Install Dependencies
cd mobile/
npm install
# For iOS (macOS only)
cd ios && pod install && cd ..
Step 4: Run Mobile App
# Start Metro bundler (keep running)
npm start
# In another terminal - Run Android app
npm run android
# Or run iOS app (macOS only)
npm run ios
# Check backend services
docker compose ps
# Test backend health
curl http://localhost:3000/health
# Test from your IP (replace with your IP)
curl http://192.168.1.69:3000/health
# Test file upload
curl -X POST -F "file=@your-file.txt" http://localhost:3000/api/files/upload
# Test file download (replace HASH with returned hash)
curl http://localhost:3000/api/files/YOUR_HASH
GET /health
- System health check β WORKINGGET /api/users
- User management endpoint β WORKINGPOST /api/files/upload
- Upload files to IPFS β WORKINGGET /api/files/:hash
- Download files from IPFS β WORKINGGET /api/files/test-ipfs
- Test IPFS connectivity β WORKINGGET /api/signatures
- Ring signature operations β WORKING
- IPFS API:
http://localhost:5001
β WORKING (Gateway exclusive access) - IPFS Gateway:
http://localhost:8080
β WORKING (Public gateway interface) - Storage Nodes: Internal-only (no external ports) β HEALTHY
- π Online Mode: Direct gateway integration with real IPFS operations
- π± Offline Mode: Full-featured mock layer for development and testing
- π Mode Switching: Real-time switching between online and offline modes
- Gateway Exclusivity: Only the gateway container can access IPFS API
- Storage Node Isolation: Storage nodes operate without external API exposure
- Swarm Key Protection: All nodes use shared private network key (
c1df9ee7cb3c82fb83c6935ec7009ad7
) - Network Segmentation: Docker internal network for inter-node communication
- Ring signature-based identity verification
- Private network access controls
- API endpoint protection
- File encryption at rest
- Real IPFS Operations: Direct connection to gateway at
localhost:3000
- Network Configurations:
- iOS Simulator:
localhost:3000
- Android Emulator:
10.0.2.2:3000
- Physical Device: Actual IP address (e.g.,
192.168.1.100:3000
)
- iOS Simulator:
- Health Monitoring: Real-time connection status and error handling
- Progress Tracking: Live upload/download progress indicators
- Complete UI Testing: All features work without gateway connectivity
- Mock IPFS Operations: Realistic simulation with generated hashes
- Configurable Delays: Simulate network latency for testing
- Error Simulation: Test error handling scenarios
- Development Benefits: No dependency on backend services
- π€ Upload: Single and multiple files with progress tracking
- π₯ Download: Retrieve files by IPFS hash with blob handling
- π List: Display all uploaded files with metadata
- ποΈ Delete: Remove files from IPFS storage
- π Metadata: File size, type, upload time, and IPFS hash management
- Create Signatures: Generate ring signatures for files
- Verify Signatures: Validate signature authenticity
- List Signatures: Display all signatures with verification status
cd backend/
# Install dependencies
npm install
# Development mode with auto-reload
npm run dev
# Database operations
npm run prisma:generate # Generate Prisma client
npm run prisma:migrate # Run migrations
npm run prisma:studio # Database GUI
cd mobile/
# Install dependencies
npm install
cd ios && pod install && cd .. # iOS only
# Start in mock mode (default)
npm run ios
- Start Gateway:
docker compose up -d
(from root directory) - Launch App: App starts in mock mode
- Switch to Online: Tap "Switch to Online" in the connection status panel
- Configure Network: Ensure proper IP configuration for your platform
- Mock Mode: Develop UI and test functionality offline
- Online Mode: Test real gateway integration and network handling
- Error Testing: Use both modes to test various error scenarios
- Fast Iteration: Mock mode provides immediate feedback
# Rebuild containers
docker compose build --no-cache
# View container status
docker compose ps
# View logs
docker compose logs -f
# Clean system
docker compose down
docker system prune -a
# Create test file
echo "Hello IPFS Private Network!" > test.txt
# Upload to IPFS
curl -X POST -F "file=@test.txt" http://localhost:3000/api/files/upload
# Expected response:
{
"success": true,
"hash": "Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te",
"name": "test.txt",
"size": 28,
"ipfsUrl": "http://localhost:8080/ipfs/Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te",
"apiUrl": "http://localhost:5001/api/v0/cat?arg=Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te"
}
# Download file
curl http://localhost:3000/api/files/Qmek5MHc59XAf8JjCXiDwKNBx81QGnzxJ9k6jsTVEAC4te
# Output: Hello IPFS Private Network!
- Launch App: Starts automatically in mock mode
- Upload Files: Generates mock IPFS hashes instantly
- List Files: Shows uploaded files with metadata
- Delete Files: Removes from mock storage
- Test Errors: Simulate network failures
- Start Gateway:
docker compose up -d
- Switch Mode: Tap "Switch to Online" in app
- Upload Real Files: Get actual IPFS hashes
- Download Files: Retrieve from IPFS network
- Test Connection: Monitor health status and error recovery
# Check all containers
docker compose ps
# Expected: 4 containers running (gateway + 3 storage nodes)
# Test IPFS connectivity
curl http://localhost:3000/api/files/test-ipfs
# Expected: {"success":true,"ipfsVersion":{"Version":"0.24.0",...}}
# Check IPFS peers
docker exec ipfs-sandbox-gateway-1 ipfs swarm peers
# Expected: 0 (private network, no external peers)
# Verify private network
docker exec ipfs-sandbox-gateway-1 ipfs id
# Expected: Node ID and addresses listed
ipfs-sandbox/
βββ backend/ # Express.js gateway
β βββ src/
β β βββ routes/ # API endpoints
β β βββ services/ # IPFS service
β β βββ config/ # Database config
β βββ prisma/ # Database schema
β βββ start.sh # IPFS initialization
βββ mobile/ # React Native app
β βββ src/
β β βββ components/
β β β βββ common/ # Reusable UI components
β β β βββ file-manager/ # File management
β β β βββ ipfs/ # IPFS-specific components
β β βββ services/
β β β βββ GatewayApiService.ts # Real API communication
β β β βββ MockApiService.ts # Mock layer
β β β βββ IPFSService.ts # Unified wrapper
β β βββ hooks/
β β β βββ useIPFS.ts # Main IPFS hook
β β βββ types/ # TypeScript definitions
β βββ AppWithIPFS.tsx # Main IPFS demo app
β βββ ios/ # iOS configuration
β βββ android/ # Android configuration
β βββ TEST_IPFS_CONNECTIVITY.md # Testing guide
βββ docker-compose.yml # Container orchestration
βββ swarm.key # Private network key
βββ CLAUDE.md # Development instructions
βββ README.md # This file
# Backend (.env or docker-compose.yml)
NODE_ENV=development
DATABASE_URL=file:/app/data/database.db
IPFS_PATH=/data/ipfs
LIBP2P_FORCE_PNET=1
- Private Network: Enabled with swarm key fingerprint
c1df9ee7cb3c82fb83c6935ec7009ad7
- API Access: Gateway exclusive (localhost:5001)
- Storage Nodes: 3 internal nodes for redundancy
- Bootstrap: Disabled (private network only)
// Online mode configuration
const onlineConfig = {
useMockApi: false,
gatewayUrl: 'http://localhost:3000',
timeout: 30000
};
// Mock mode configuration
const mockConfig = {
useMockApi: true,
mockDelay: 1000
};
"IPFS Gateway: Disconnected" in Android App:
-
Get Your Machine's IP Address:
# macOS/Linux ifconfig | grep "inet " | grep -v "127.0.0.1" # Example output: inet 192.168.1.69 netmask 0xffffff00 # Windows ipconfig # Look for IPv4 Address under your active WiFi/Ethernet adapter
-
Update Mobile App Configuration:
# Edit this file: mobile/src/config/api.ts # Update line 17 with your IP: const HOST_MACHINE_IP = '192.168.1.69'; // π CHANGE THIS
-
Reload Mobile App:
- Android: Press
R
twice in Metro console, orCtrl+M
-> Reload - iOS:
Cmd+R
in simulator
- Android: Press
-
Verify Backend is Accessible:
# Test from your IP (replace with your actual IP) curl http://192.168.1.69:3000/health # Should return: {"status":"OK",...}
Common IP Configuration Issues:
- WiFi Changes: Your IP changes when switching networks
- VPN Active: VPN may change your network configuration
- Firewall: Ensure port 3000 is not blocked
- Network Type: Ensure both host and emulator are on same network
Get Your IP for Mobile Setup:
# macOS/Linux - Copy the IP from this command
ifconfig | grep "inet " | grep -v "127.0.0.1" | awk '{print $2}'
# Windows - Look for IPv4 Address
ipconfig | findstr "IPv4"
Development Workflow:
# 1. Start backend
./start-system.sh
# 2. Get your IP and update mobile/src/config/api.ts
ifconfig | grep "inet " | grep -v "127.0.0.1"
# 3. Start mobile app
cd mobile && npm start
cd mobile && npm run android # In another terminal
IPFS API not responding:
# Check container logs
docker logs ipfs-sandbox-gateway-1
# Restart gateway
docker compose restart gateway
File upload fails:
# Verify IPFS connectivity
curl http://localhost:3000/api/files/test-ipfs
# Should return: {"success":true,"ipfsVersion":{"Version":"0.24.0",...}}
Storage nodes disconnected:
# Check swarm peers (should be 0 for private network)
docker exec ipfs-sandbox-gateway-1 ipfs swarm peers
# Restart entire system
docker compose down && docker compose up -d
Connection failures (Online Mode):
# iOS Simulator
curl http://localhost:3000/health
# Android Emulator
curl http://10.0.2.2:3000/health
# Physical Device (replace with actual IP)
curl http://192.168.1.100:3000/health
React Native build issues:
# Reset Metro cache
npx react-native start --reset-cache
# Clean builds
cd ios && pod deintegrate && pod install && cd .. # iOS
cd android && ./gradlew clean && cd .. # Android
# Verify environment
npx react-native doctor
Mock mode not working:
- Verify app entry point uses
AppWithIPFS
- Check
useIPFS
hook configuration - Ensure mock service initialization
# All containers
docker compose logs -f
# Specific service
docker logs ipfs-sandbox-gateway-1 -f
# Mobile app debugging
# Use React Native Debugger or browser dev tools
- β 4/4 Docker containers running healthy
- β IPFS gateway operational (Kubo v0.24.0)
- β Private network established with swarm key
- β API endpoints responding correctly
- β File upload/download working
- β Database operations functional
- β Dual-mode operation (Online/Offline)
- β Complete CRUD functionality
- β Real-time connection monitoring
- β File upload with progress tracking
- β Error handling and recovery
- β Mock layer for offline development
- β TypeScript type safety
- β Modern UI with theme support
- β Mobile-to-Gateway communication
- β File operations across platforms
- β Network error handling
- β Mode switching functionality
- β Progress indicators and status updates
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature
) - Test in both online and offline modes
- Commit changes (
git commit -m 'Add amazing feature'
) - Push to branch (
git push origin feature/amazing-feature
) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CLAUDE.md - Claude Code development instructions
- Mobile README - Comprehensive mobile app documentation
- Mobile Testing Guide - Mobile connectivity testing
- IPFS Documentation - Official IPFS docs
- React Native Docs - React Native development
- Docker Compose - Container orchestration
Status: β Fully Functional - Complete system with CRUD operations, private IPFS network, and dual-mode mobile application ready for production use.
- β Complete mobile app integration with gateway
- β Dual-mode operation (Online/Offline) implemented
- β Mock layer for offline development
- β Real-time connection monitoring
- β Comprehensive error handling
- β Progress tracking and status indicators
- β Full CRUD operations tested and verified