Skip to content

Backend Storage

Multi-tier storage system for scalability and redundancy.

Storage Tiers

Hot Storage: S3 with CDN

  • Recently accessed images
  • Fast retrieval (< 100ms)
  • TTL: 30 days
  • CloudFront CDN for acceleration

Warm Storage: IPFS

  • All processed assets
  • Content-addressed
  • Global availability
  • P2P distribution

Cold Storage: Filecoin

  • Long-term archival
  • Verifiable storage proofs
  • Economic incentives
  • Decentralized backup

Storage Operations

Upload

async def upload_asset(
    file_path: str,
    asset_id: UUID
) -> StorageInfo:
    """
    1. Upload to IPFS
    2. Upload to S3
    3. Upload to Filecoin (async)
    4. Store metadata
    """

Retrieval

async def retrieve_asset(cid: str) -> bytes:
    """
    1. Try IPFS primary node
    2. Fallback to public gateway
    3. Fallback to S3
    """

Configuration

# IPFS
IPFS_API_URL=/ip4/127.0.0.1/tcp/5001

# S3
AWS_ACCESS_KEY_ID=...
S3_BUCKET_NAME=certana-prod
CDN_BASE_URL=https://cdn.example.com

# Filecoin
LIGHTHOUSE_API_KEY=...
FILECOIN_GATEWAY_URL=https://gateway.lighthouse.storage/ipfs
FILECOIN_STORAGE_ENABLED=true

Cost Optimization

  • Lifecycle policies for S3
  • Compression before upload
  • Batch operations
  • Spot instances for processing

See Services Documentation for implementation.