Infrastructure
Running relayers, self-hosting, and deployment guides
Infrastructure
Priv's infrastructure consists of several interconnected services that work together to provide gasless payments and seamless user experiences. Understanding these components helps you choose the right deployment strategy for your needs.
Core Components
Relayer Service
The relayer is a Hono-based Node.js server that handles gasless transactions. It pays gas fees for claim transactions, validates claim_payment instructions, and signs as the fee payer. The relayer runs on port 3003 and provides REST endpoints for transaction relay and health monitoring.
Key responsibilities:
- Validates incoming claim_payment instructions
- Signs transactions as fee payer
- Submits transactions to Solana network
- Rate limiting to prevent abuse
- Transaction status tracking
API Server
The API server is built with Hono and uses Drizzle ORM with PostgreSQL for data persistence. It handles user authentication, payment tracking, and business logic. This service coordinates between the web interface and blockchain operations.
Features:
- User session management
- Payment history and analytics
- Database operations via Drizzle ORM
- RESTful API endpoints
- Integration with relayer service
Web Application
The main user interface is a Next.js 16 application running on port 3000. It provides the dashboard, payment creation interface, and user management features. The web app communicates with the API server for data and the relayer for gasless transactions.
Capabilities:
- Payment link creation and management
- Real-time payment status updates
- User dashboard and analytics
- Responsive design for mobile and desktop
Payment Portal
A separate Next.js application on port 3001 dedicated to payment processing. This isolated service handles the actual payment flow, reducing security risks and improving performance for payment-specific operations.
Purpose:
- Isolated payment processing environment
- Optimized for conversion and user experience
- Separate deployment and scaling
- Enhanced security for financial operations
Telegram Bot
Built with Grammy, the Telegram bot provides notifications and basic payment management through Telegram. It's an optional component that enhances user engagement through familiar messaging interfaces.
Functions:
- Payment notifications
- Basic payment status queries
- User onboarding assistance
- Integration with Telegram's payment systems
Architecture Overview
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Web App │ │ Payment App │ │ Telegram Bot│
│ (Next.js) │ │ (Next.js) │ │ (Grammy) │
│ :3000 │ │ :3001 │ │ │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└──────────────────┼──────────────────┘
│
┌──────▼──────┐
│ API Server │
│ (Hono) │
│ :3001 │
└──────┬──────┘
│
┌───────────┼───────────┐
│ │ │
┌──────▼──────┐ │ ┌──────▼──────┐
│ Relayer │ │ │ PostgreSQL │
│ (Hono) │ │ │ Database │
│ :3003 │ │ │ │
└─────────────┘ │ └─────────────┘
│
┌──────▼──────┐
│ Solana │
│ Network │
└─────────────┘Deployment Scenarios
Minimal Setup (Relayer Only)
If you only need gasless transactions, run just the relayer service. This works well for integrating Priv payments into existing applications without the full UI stack.
Required:
- Relayer service
- Funded Solana wallet
- Basic monitoring
Full Stack (All Components)
For complete functionality, deploy all services. This provides the full Priv experience with web interface, payment portal, and optional Telegram integration.
Required:
- All five services
- PostgreSQL database
- Multiple funded wallets
- Load balancer/reverse proxy
Hybrid (Core + Custom UI)
Use the API server and relayer while building your own frontend. This approach gives you the backend infrastructure while maintaining full control over user experience.
Required:
- API server
- Relayer service
- PostgreSQL database
- Custom frontend application
Network Requirements
Devnet (Current)
All services currently operate on Solana devnet for testing and development. Devnet provides free SOL through airdrops and mirrors mainnet functionality without real financial risk.
Characteristics:
- Free SOL via
solana airdrop - Reset periodically
- Identical to mainnet APIs
- Perfect for development and testing
Mainnet (Future)
Production deployments will target Solana mainnet with real SOL and USDC transactions. This requires careful security considerations and proper wallet management.
Requirements:
- Real SOL for gas fees
- USDC token support
- Enhanced security measures
- Monitoring and alerting
Security Considerations
Wallet Management
Each service that interacts with Solana needs its own wallet. The relayer wallet requires the most careful management since it pays gas fees for all transactions.
Best practices:
- Separate wallets for each service
- Regular balance monitoring
- Secure key storage (never in code)
- Backup and recovery procedures
Rate Limiting
The relayer includes built-in rate limiting to prevent abuse. Configure limits based on your expected transaction volume and available SOL balance.
Network Security
Use HTTPS for all external communications, implement proper CORS policies, and consider VPN access for administrative functions.
Monitoring and Maintenance
Health Checks
Each service provides health endpoints for monitoring. Set up automated checks to ensure all components remain operational.
Log Management
Centralized logging helps track transactions across services. Consider using structured logging for better analysis and debugging.
Backup Procedures
Regular database backups and wallet key backups are essential. Test recovery procedures before you need them.
Getting Started
Choose your deployment approach:
- Running a Relayer - Start with gasless transactions
- Self-Hosting - Deploy the complete stack
- Deployment - Production deployment strategies
Each guide provides step-by-step instructions for setting up and maintaining your Priv infrastructure.