Skip to main content
Stork SMS Architecture Overview Stork SMS is built on a modern, decentralized architecture that combines Web3 technologies with traditional web application patterns to create a secure, scalable messaging platform.

High-Level Architecture

Core Components

1. Frontend Application (Next.js 15)

Purpose: User interface and client-side logic for the messaging application. Key Technologies:
  • Next.js 15 with App Router for server-side rendering
  • React 18 for component-based UI
  • TypeScript for type safety
  • Tailwind CSS with shadcn/ui for styling
  • Solana Wallet Adapters for Web3 integration
Architecture Patterns:
  • Component-based architecture with reusable UI components
  • Context providers for global state management (Auth, Wallet)
  • Custom hooks for business logic abstraction
  • Real-time subscriptions for live messaging

2. API Layer (Next.js Server)

Purpose: Backend services handling authentication, data processing, and blockchain interactions. Key Endpoints:
Security Features:
  • Rate limiting with rate-limiter-flexible
  • Wallet signature verification
  • Input validation and sanitization
  • CORS configuration

3. Database Layer (Supabase)

Purpose: Encrypted data storage with real-time synchronization capabilities. Core Tables:

Chats Table

Messages Table

Chat Participants Table

Features:
  • Row Level Security (RLS) for data isolation
  • Real-time subscriptions for live updates
  • Automated timestamp management
  • Optimized indexing for performance

4. Blockchain Layer (Solana)

Purpose: Decentralized ownership verification and payment processing. Components:

NFT System

  • Compressed NFTs using Metaplex Bubblegum for cost efficiency
  • Dual NFT Creation: Sender and recipient NFTs for each chat
  • Dynamic Metadata: NFT attributes reflect chat participation
  • Ownership Verification: On-chain verification of NFT possession

Smart Contract Integration

  • Merkle Tree Management: Efficient compressed NFT storage
  • Collection Management: Organized NFT collections
  • Fee Processing: Automated payment collection
  • Access Control: NFT-based chat permissions

5. File Storage Layer (Cloudflare R2)

Purpose: Scalable, cost-effective storage for media files. Stored Content:
  • Images: Optimized and compressed image files
  • Voice Messages: Compressed audio files
  • NFT Assets: Generated NFT images and metadata
  • Media Previews: Thumbnails and previews
Features:
  • Global CDN distribution
  • Automatic compression and optimization
  • Secure upload URLs with time-based expiration
  • Integration with Next.js API for seamless file handling

Security Architecture

1. Zero-Knowledge Authentication

  • No passwords or personal information required
  • Each request authenticated via wallet signature
  • JWT tokens for stateless session management
  • Hardware wallet support for enhanced security

2. End-to-End Encryption

Key Management:
  • Encryption keys derived from wallet addresses
  • Client-side encryption/decryption only
  • Keys never stored or transmitted
  • Perfect forward secrecy (planned enhancement)

3. NFT-Based Access Control

  • Immutable access permissions via blockchain
  • No central authority can override access
  • Transferable chat access through NFT trading
  • Transparent verification process

Data Flow Architecture

1. Message Creation Flow

2. Chat Creation Flow

3. Real-time Communication

Real-time Features:
  • Message delivery notifications
  • Typing indicators
  • Online status updates
  • Read receipt confirmation

Scalability Considerations

1. Database Optimization

  • Indexing Strategy: Optimized indexes for common query patterns
  • Partitioning: Chat-based data partitioning for large scale
  • Connection Pooling: Efficient database connection management
  • Query Optimization: Minimized database calls through batching

2. Blockchain Efficiency

  • Compressed NFTs: 99% cost reduction vs traditional NFTs
  • Batch Operations: Multiple NFT operations in single transaction
  • Fee Optimization: Intelligent fee calculation and timing
  • RPC Optimization: Smart RPC endpoint selection and fallbacks

3. Media Handling

  • Lazy Loading: On-demand image and media loading
  • Compression: Automatic file size optimization
  • CDN Distribution: Global content delivery
  • Caching Strategy: Multi-layer caching for performance

Development & Deployment

Local Development Environment

Production Deployment

  • Frontend: Netlify with Next.js optimization
  • Database: Supabase managed PostgreSQL
  • Storage: Cloudflare R2 with global distribution
  • Monitoring: Real-time performance and error tracking

Technology Stack Summary

This architecture ensures Stork SMS remains secure, scalable, and truly decentralized while providing an excellent user experience comparable to traditional messaging applications.