A production-grade blockchain snapshot hosting service providing reliable, bandwidth-managed access to blockchain snapshots with tiered user system. Built with Next.js 15, nginx storage backend, and deployed on Kubernetes.
The Blockchain Snapshots Service provides high-speed access to blockchain node snapshots for the Cosmos ecosystem. It features:
- Tiered Access: Free tier (50 Mbps shared) and Premium tier (250 Mbps shared)
- Multiple Authentication: Email/password and Cosmos wallet (Keplr) authentication
- Compression Support: Both ZST and LZ4 compressed snapshots
- Resume Support: Interrupted downloads can be resumed
- Real-time Monitoring: Prometheus metrics and Grafana dashboards
- High Availability: Redundant deployments with automatic failover
- Security: NextAuth.js authentication, secure download links, and IP restrictions
- Key Features
- Tech Stack
- Architecture
- Getting Started
- Development
- API Reference
- Testing
- Deployment
- Integration with Snapshot Processor
- Monitoring
- Contributing
- License
- Multiple Chain Support: Host snapshots for 30+ Cosmos chains
- Dual Compression: Support for both ZST and LZ4 compressed snapshots
- Bandwidth Management: Dynamic per-connection bandwidth allocation
- Download Resume: Support for interrupted download resumption
- Real-time Updates: Automated snapshot processing via snapshot-processor
- User Management: Full account system with profile, billing, and download history
- Instant Access: No registration required for free tier
- Premium Tier: 5x faster downloads for authenticated users
- Multiple Auth Methods: Email/password or Cosmos wallet authentication
- Search & Filter: Find snapshots by chain name, type, or compression
- Download Progress: Real-time download statistics
- Mobile Responsive: Optimized for all device sizes
- Secure Downloads: Time-limited download URLs with nginx secure_link module
- Rate Limiting: Prevent abuse with configurable limits
- Health Checks: Automated monitoring and alerting
- Metrics Export: Prometheus-compatible metrics
- GitOps Ready: Kubernetes manifests managed in bare-metal repository
- Next.js 15: React framework with App Router
- TypeScript 5: Type-safe development
- Tailwind CSS 4: Utility-first styling
- React 19: Latest React features
- NextAuth.js v5: Authentication system
- Next.js API Routes: Full-stack capabilities
- Nginx: Static file storage with secure_link module
- Prisma ORM: Database management
- SQLite: User and session storage
- Redis: Session caching and rate limiting
- JWT: API authentication
- Kubernetes: Container orchestration
- TopoLVM: Dynamic volume provisioning
- Snapshot Processor: Go-based automated snapshot processing
- Prometheus: Metrics collection
- Grafana: Metrics visualization
- GitHub Actions: CI/CD pipeline
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Browser │────▶│ Next.js │────▶│ Nginx │◀────│ Snapshot │
└─────────────┘ │ Web App │ │ Storage │ │ Processor │
└─────────────┘ └─────────────┘ └─────────────┘
│ │ │
▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ SQLite │ │ TopoLVM │ │ Kubernetes │
│ Database │ │ Storage │ │ Jobs │
└─────────────┘ └─────────────┘ └─────────────┘
- User browses available snapshots via Next.js frontend
- Authentication checked via NextAuth.js for tier determination
- Snapshot data fetched from nginx autoindex API
- Download URLs generated with nginx secure_link module
- Direct download from nginx with bandwidth management
- Metrics collected for monitoring and analytics
- Snapshot creation handled by separate snapshot-processor service
The web app works in conjunction with the snapshot-processor:
- Processor creates snapshots on schedule or request
- Compresses with ZST or LZ4 based on configuration
- Uploads to nginx storage at
/snapshots/[chain-id]/
- Web app displays available snapshots from nginx
- Users download directly from nginx storage
- Node.js 20.x or higher
- npm or yarn
- Docker (for development database)
- Kubernetes cluster (for production)
-
Clone the repository
git clone https://github.com/bryanlabs/snapshots.git cd snapshots
-
Install dependencies
npm install
-
Initialize database
./scripts/init-db-proper.sh
-
Set up environment variables
cp .env.example .env.local # Edit .env.local with your configuration
-
Run development server
npm run dev
-
Open browser Navigate to http://localhost:3000
- Email: test@example.com
- Password: snapshot123
snapshots/
├── app/ # Next.js app directory
│ ├── api/ # API routes
│ │ ├── account/ # Account management
│ │ ├── admin/ # Admin endpoints
│ │ ├── auth/ # NextAuth endpoints
│ │ ├── v1/ # Public API v1
│ │ └── health # Health checks
│ ├── (auth)/ # Auth pages layout
│ ├── (public)/ # Public pages layout
│ ├── account/ # User account pages
│ └── page.tsx # Homepage
├── components/ # React components
├── lib/ # Utilities and helpers
│ ├── auth/ # Authentication logic
│ ├── nginx/ # Nginx storage client
│ └── bandwidth/ # Bandwidth management
├── prisma/ # Database schema
├── __tests__/ # Test files
├── docs/ # Documentation
└── public/ # Static assets
# Nginx Storage Configuration
NGINX_ENDPOINT=nginx
NGINX_PORT=32708
NGINX_USE_SSL=false
NGINX_EXTERNAL_URL=https://snapshots.bryanlabs.net
SECURE_LINK_SECRET=your-secure-link-secret
# Authentication
NEXTAUTH_SECRET=your-nextauth-secret
NEXTAUTH_URL=https://snapshots.bryanlabs.net
DATABASE_URL=file:/app/prisma/dev.db
# Legacy Auth (for API compatibility)
PREMIUM_USERNAME=premium_user
PREMIUM_PASSWORD_HASH=$2a$10$...
# Bandwidth Limits (Mbps)
BANDWIDTH_FREE_TOTAL=50
BANDWIDTH_PREMIUM_TOTAL=250
# Redis Configuration
REDIS_HOST=redis
REDIS_PORT=6379
# Download Limits
DAILY_DOWNLOAD_LIMIT=10
# API Configuration
NEXT_PUBLIC_API_URL=https://snapshots.bryanlabs.net
# Start development server
npm run dev
# Run tests
npm test
# Run tests in watch mode
npm run test:watch
# Run e2e tests
npm run test:e2e
# Build for production
npm run build
# Start production server
npm start
# Run linting
npm run lint
# Database commands
npx prisma migrate dev # Run migrations
npx prisma studio # Open database GUI
npx prisma generate # Generate Prisma client
See API Routes Documentation for detailed endpoint information.
GET /api/v1/chains
- List all chains with snapshotsGET /api/v1/chains/[chainId]
- Get chain detailsGET /api/v1/chains/[chainId]/snapshots
- List chain snapshotsGET /api/v1/chains/[chainId]/snapshots/latest
- Get latest snapshotPOST /api/v1/chains/[chainId]/download
- Generate download URLPOST /api/v1/auth/login
- Legacy JWT authenticationPOST /api/v1/auth/wallet
- Wallet authentication
POST /api/auth/signin
- Sign in with credentials or walletGET /api/auth/signout
- Sign outGET /api/auth/session
- Get current sessionPOST /api/auth/register
- Register new account
GET /api/account/avatar
- Get user avatarPOST /api/account/link-email
- Link email to wallet account
GET /api/admin/stats
- System statisticsGET /api/admin/downloads
- Download analytics
__tests__/
├── api/ # API route tests
├── components/ # Component tests
├── integration/ # Integration tests
└── lib/ # Library tests
# Unit tests
npm test
# Integration tests
npm run test:integration
# E2E tests (requires running app)
npm run test:e2e
# Test coverage
npm run test:coverage
# Run specific test file
npm test -- auth.test.ts
The application is deployed as part of the BryanLabs bare-metal infrastructure:
-
Repository Structure
bare-metal/ └── cluster/ └── chains/ └── cosmos/ └── fullnode/ └── snapshot-service/ └── webapp/ ├── deployment.yaml ├── configmap.yaml ├── secrets.yaml ├── pvc.yaml └── kustomization.yaml
-
Deploy with Kustomize
cd /path/to/bare-metal kubectl apply -k cluster
-
Verify deployment
kubectl get pods -n fullnodes -l app=webapp kubectl get svc -n fullnodes webapp
# Build for production (AMD64)
docker buildx build --builder cloud-bryanlabs-builder \
--platform linux/amd64 \
-t ghcr.io/bryanlabs/snapshots:v1.5.0 \
--push .
# Build for local testing
docker build -t snapshots:local .
The project uses GitHub Actions for automated deployment:
- Tests run on every push
- Docker images built and pushed to GitHub Container Registry
- Kubernetes manifests in bare-metal repo updated
- Automatic rollback on failure
/api/health
- Application health status- Kubernetes liveness/readiness probes configured
- Database connection monitoring
- Nginx storage availability checks
The service exports Prometheus metrics at /api/metrics
:
- Request counts and latencies
- Download statistics by tier and chain
- Bandwidth usage metrics
- Authentication success/failure rates
- Database query performance
Pre-built dashboards available:
- Service Overview
- User Analytics
- Download Statistics
- Error Tracking
- Performance Metrics
The web app displays snapshots created by the snapshot-processor:
- Processor Configuration defines snapshot schedules per chain
- Processor creates VolumeSnapshots on schedule
- Processor compresses snapshots (ZST or LZ4)
- Processor uploads to nginx storage at
/snapshots/[chain-id]/
- Web app reads nginx autoindex to list available snapshots
- Web app generates secure download URLs for users
- Scheduled:
[chain-id]-[YYYYMMDD]-[HHMMSS].tar.[compression]
- On-demand:
[chain-id]-[block-height].tar.[compression]
- Examples:
noble-1-20250722-174634.tar.zst
osmosis-1-12345678.tar.lz4
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
- Follow TypeScript best practices
- Use ESLint and Prettier
- Write meaningful commit messages
- Add JSDoc comments for public APIs
This project is licensed under the MIT License - see the LICENSE file for details.
- BryanLabs team for infrastructure support
- Cosmos ecosystem for blockchain technology
- Open source contributors
- Documentation: docs/
- Issues: GitHub Issues
- Discord: BryanLabs Discord
- Email: support@bryanlabs.net