Skip to content
yuriya-devPublic

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

116 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌊 BlobCast

Own your posts forever.

A decentralized social publishing protocol built on Sui blockchain, powered by Walrus permanent storage and Tatum enterprise-grade RPC infrastructure.

Sui Walrus Tatum Next.js TypeScript


πŸ“– Project Description

BlobCast is a decentralized social publishing protocol that enables users to publish content permanently, verifiably, and censorship-resistant on the Sui blockchain.

Unlike traditional social media platforms that store content on centralized servers, BlobCast uses a hybrid architecture:

  • Walrus for storing content (text, images, video) in a decentralized and permanent manner
  • Sui blockchain for verifying content ownership and authenticity
  • Tatum RPC as an enterprise-grade gateway to the Sui network
  • PostgreSQL + Redis for fast feed performance and indexing

Every post you create belongs to you forever β€” stored on Walrus, verified on Sui, and cannot be deleted by anyone.


πŸ€” Why Walrus?

Walrus is a decentralized blob storage built on top of Sui. BlobCast chose Walrus for the following reasons:

Reason Explanation
Permanence Content is encoded with Reed-Solomon erasure coding (120-shard distribution), ensuring data is stored permanently and fault-tolerantly
Censorship Resistance No single entity can delete or censor stored content
Cost Efficiency Blob storage costs are significantly lower compared to storing data directly on-chain in Sui
Sui Native Walrus integrates natively with the Sui ecosystem β€” blob IDs and hashes can be referenced directly in Move smart contracts
Content Integrity Every blob has a verifiable SHA-256 hash to ensure content has not been tampered with

What is stored in Walrus?

BlobCast stores all heavy content to Walrus:

  • πŸ“ Post content β€” post text serialized to a JSON blob
  • πŸ–ΌοΈ Media images β€” images attached to posts
  • 🎬 Videos β€” video content from posts
  • πŸ‘€ Avatar & Profile Banner β€” user profile photos and banners
  • πŸ’¬ Comments β€” each comment has its own Walrus blob ID
  • πŸ—‚οΈ Thread Archives β€” archives of long discussion threads

Each entity above generates a Walrus Blob ID which is then stored as a reference in the Sui smart contract and PostgreSQL database.

Example post blob structure:

{
  "author": "0x91ab3f...",
  "content": "Hello decentralized world!",
  "media": [
    { "type": "image", "blob": "walrus://8x7as..." }
  ],
  "timestamp": 1748500000
}

πŸ€” Why Tatum?

Tatum provides enterprise-grade RPC infrastructure for accessing the Sui blockchain. BlobCast chose Tatum for the following reasons:

Reason Explanation
High Availability Tatum runs dedicated Sui nodes with high uptime, avoiding rate-limiting from public endpoints
Performance Lower latency compared to public Sui RPC for production workloads
Reliability If Tatum goes down, the server automatically falls back to Sui public gateways β€” no single point of failure
Testnet & Mainnet Support for both networks with a single API key, simplifying development and deployment
API Key Auth Secure authenticated access to prevent abuse

Tatum is used as an RPC gateway for:

  • Blockchain Indexer β€” reading checkpoints and events from Sui
  • Wallet Authentication β€” verifying transaction signatures
  • On-chain Registration β€” writing blob references and ownership to Sui smart contracts

πŸ—οΈ System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚          Frontend (Next.js)      β”‚
β”‚   Feed Β· Posts Β· Profiles        β”‚
β”‚   Wallet Connect Β· Search        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚ REST API
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Backend API (Express)      β”‚
β”‚  Auth Β· Posts Β· Users Β· Feed     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚            β”‚
        β–Ό            β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Walrus   β”‚  β”‚  Tatum Sui RPC   β”‚
β”‚ Blob Store β”‚  β”‚  (Testnet/Main)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
        β”‚                β”‚
        β–Ό                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚        Sui Blockchain          β”‚
β”‚  Ownership Β· Hash Β· Events     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     BlobCast Indexer Daemon      β”‚
β”‚  Listens to Sui Events via Tatum β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
    β”Œβ”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”
    β–Ό             β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Prisma β”‚  β”‚  Redis   β”‚
β”‚  ORM   β”‚  β”‚  Cache   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
    β”‚
    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Supabase   β”‚
β”‚ (PostgreSQL)β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Technology Stack

Frontend

Technology Version Purpose
Next.js 16 Frontend framework (App Router)
React 19 UI rendering
Tailwind CSS 4 Styling
Framer Motion 12 Animations & transitions
@mysten/dapp-kit 1.0 Sui wallet integration
@mysten/sui 2.17 Sui SDK (transactions, objects)
TanStack Query 5 Server state & data fetching
Zustand β€” Client state management
Recharts 3 Analytics charts
Radix UI β€” Accessible UI components
Lucide React β€” Icon library

Backend

Technology Version Purpose
Node.js 20 Runtime
Express 4 REST API framework
Prisma 7 ORM & database migrations
PostgreSQL β€” Primary database (via Supabase)
Redis (ioredis) 5 Feed caching & trending engine
TypeScript 5 Type safety

Blockchain & Storage

Technology Purpose
Sui Ownership verification, smart contracts
Walrus Decentralized blob storage
Tatum Enterprise Sui RPC gateway
Move Smart contract language

Deployment

Layer Platform
Frontend Vercel
Backend API Fly.io
Database Supabase (PostgreSQL)
Cache Upstash (Redis)
Storage Walrus (Decentralized)
RPC Tatum Infrastructure

πŸ“ Repository Structure

BlobCast/
β”œβ”€β”€ πŸ“ client/                    # Frontend Next.js App
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/                  # Next.js App Router pages
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx          # Landing / Home page
β”‚   β”‚   β”‚   β”œβ”€β”€ layout.tsx        # Root layout
β”‚   β”‚   β”‚   β”œβ”€β”€ feed/             # Social feed
β”‚   β”‚   β”‚   β”œβ”€β”€ posts/[id]/       # Post detail page
β”‚   β”‚   β”‚   β”œβ”€β”€ profile/          # User profiles
β”‚   β”‚   β”‚   β”œβ”€β”€ explore/          # Explore & trending
β”‚   β”‚   β”‚   β”œβ”€β”€ search/           # Semantic search
β”‚   β”‚   β”‚   β”œβ”€β”€ bookmarks/        # Saved posts
β”‚   β”‚   β”‚   β”œβ”€β”€ messages/         # Direct messages
β”‚   β”‚   β”‚   β”œβ”€β”€ wallet/           # Wallet dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ login/            # Login page
β”‚   β”‚   β”‚   └── register/         # Registration
β”‚   β”‚   β”œβ”€β”€ components/           # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ hooks/                # Custom React hooks
β”‚   β”‚   └── lib/                  # Client-side utilities
β”‚   β”œβ”€β”€ prisma/                   # Client-side Prisma schema
β”‚   β”œβ”€β”€ .env                      # Client environment variables
β”‚   └── package.json
β”‚
β”œβ”€β”€ πŸ“ server/                    # Backend Express API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ server.ts             # Entry point
β”‚   β”‚   β”œβ”€β”€ app.ts                # Express app setup
β”‚   β”‚   β”œβ”€β”€ indexer.ts            # πŸ”΄ Sui blockchain indexer daemon
β”‚   β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”‚   β”œβ”€β”€ authController.ts     # Wallet authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ postController.ts     # Posts CRUD & interactions
β”‚   β”‚   β”‚   └── userController.ts     # User profiles
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”‚   β”œβ”€β”€ authRoutes.ts         # POST /auth/*
β”‚   β”‚   β”‚   β”œβ”€β”€ postRoutes.ts         # GET/POST /posts/*
β”‚   β”‚   β”‚   └── userRoutes.ts         # GET/PUT /users/*
β”‚   β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”‚   β”œβ”€β”€ tatum.ts              # πŸ”΅ Tatum RPC client
β”‚   β”‚   β”‚   β”œβ”€β”€ redis.ts              # Redis / in-memory cache
β”‚   β”‚   β”‚   β”œβ”€β”€ db.ts                 # Prisma client singleton
β”‚   β”‚   β”‚   └── auth.ts               # JWT utilities
β”‚   β”‚   β”œβ”€β”€ middleware/           # Express middlewares
β”‚   β”‚   β”œβ”€β”€ utils/                # Helper utilities
β”‚   β”‚   └── types/                # TypeScript type definitions
β”‚   β”œβ”€β”€ prisma/                   # Prisma schema & migrations
β”‚   β”œβ”€β”€ .env.example              # πŸ“‹ Environment template
β”‚   └── package.json
β”‚
β”œβ”€β”€ πŸ“ move/                      # Sui Move Smart Contracts
β”‚   β”œβ”€β”€ Move.toml                 # Package configuration
β”‚   └── sources/
β”‚       β”œβ”€β”€ profile.move          # User identity & avatars
β”‚       β”œβ”€β”€ post.move             # Post ownership & Walrus refs
β”‚       β”œβ”€β”€ interaction.move      # Likes, reposts, follows
β”‚       β”œβ”€β”€ tipping.move          # SUI creator tipping
β”‚       └── events.move           # On-chain event definitions
β”‚
└── πŸ“ docs/                      # Technical documentation
    β”œβ”€β”€ architecture_diagram.md   # System architecture & mermaid diagrams
    β”œβ”€β”€ database_schema.md        # PostgreSQL schema & Redis cache design
    β”œβ”€β”€ smart_contracts.md        # Sui Move contract modules API reference
    β”œβ”€β”€ api_documentation.md      # Express gateway endpoints & payloads
    β”œβ”€β”€ deployment_guide.md       # End-to-end production deployment guide
    └── docs_old/                 # Deprecated legacy documentation

πŸ“š Technical Documentation

BlobCast is accompanied by standard-setting production documentation compiled by Web3 Solutions Architects. Read the specialized manuals to understand specific layers in detail:

  • πŸ—ΊοΈ System Architecture Diagram β€” Architectural diagrams, lifecycle sequence workflows (Post Creation, E2E Encrypted DMs), and failover fail-soft high-availability guides.
  • πŸ—„οΈ Database Schema Design β€” Complete Entity-Relationship (ER) model diagram, Prisma PostgreSQL database tables, and key-value Redis caching schemas.
  • πŸ“œ Sui Move Smart Contracts β€” Full specification of the smart contracts residing in /move, including module breakdowns, structs, core entry function APIs, and event telemetries.
  • πŸ”Œ Backend Gateway API β€” Comprehensive REST API documentation, passwordless cryptographic challenge-response authentication login guides, request-response payload specs, and simulator gateways.
  • πŸš€ End-to-End Deployment Guide β€” Step-by-step production runbooks to publish Move contracts to Sui Testnet/Mainnet, deploy the Express indexer service to Railway/Fly.io, and launch the Next.js client on Vercel.

πŸ”„ Post Workflow (Post Lifecycle)

1. User submits a post (text + media)
        β”‚
        β–Ό
2. Frontend uploads media β†’ Walrus
   β†’ Receives walrus_blob_id + blob_hash
        β”‚
        β–Ό
3. Backend POST /posts
   β†’ Saves walrus_blob_id, blob_hash to Supabase
        β”‚
        β–Ό
4. Smart Contract (Move) called via Sui SDK
   β†’ Registers post ownership on-chain
   β†’ Emits PostCreated event
        β”‚
        β–Ό
5. BlobCast Indexer (via Tatum RPC) detects event
   β†’ Syncs to PostgreSQL
   β†’ Updates Redis trending cache
   β†’ Emits real-time feed update

πŸ“œ Smart Contracts (Move)

BlobCast's contracts on Sui are designed to be lightweight β€” storing only minimal references:

Module Function
profile.move User identity, username, avatar blob ID
post.move Post ownership, Walrus blob reference, timestamps
interaction.move Like, repost, follow
tipping.move Direct SUI transfer to creator
events.move Event definitions for the indexer

Heavy content (text, images, video) is never stored on-chain β€” everything lives on Walrus.


πŸš€ Getting Started

Prerequisites

  • Node.js 20+
  • pnpm / npm
  • Sui CLI (for deploying smart contracts)
  • Tatum account for API key
  • Supabase project (PostgreSQL)
  • Redis (local or Upstash)

1. Clone the Repository

git clone https://github.com/yuriya-dev/BlobCast.git
cd BlobCast

2. Setup Backend

cd server

# Copy and fill in environment variables
cp .env.example .env

# Install dependencies
npm install

# Run database migrations
npx prisma migrate dev

# (Optional) Seed initial data
npm run seed

# Start development server
npm run dev

Backend will run at http://localhost:8080

3. Setup Frontend

cd client

# Install dependencies
npm install

# Start development server
npm run dev

Frontend will run at http://localhost:3000

4. Deploy Smart Contracts (Optional)

cd move

# Deploy to Sui Testnet
sui client publish --gas-budget 100000000

βš™οΈ Environment Variables

Server (server/.env)

# =========================================================================
# BlobCast β€” Server Environment Configurations Example
# =========================================================================

# --- 1. Server Settings ---
# Port that the Express API server will listen on
PORT=8080
# Node runtime mode: 'development' or 'production' (development shows stack traces)
NODE_ENV=development

# --- 2. Supabase Database Connection (PostgreSQL) ---
# Format: postgresql://[user]:[password]@[host]:[port]/[database]?schema=public
DATABASE_URL="postgresql://postgres:[password]@[host].supabase.co:5432/postgres?schema=public"

# --- 3. Redis Cache Configuration ---
# Connection string for Upstash or local Redis instance
REDIS_URL="redis://localhost:6379"

# --- 4. Tatum Sui RPC Infrastructure gateways ---
# Custom Tatum gateway endpoints for Sui Testnet and Mainnet
# If left blank, the Tatum client automatically falls back to Sui public gateways
TATUM_SUI_TESTNET_RPC="https://sui-testnet.node.tatum.io"
TATUM_SUI_MAINNET_RPC="https://sui-mainnet.node.tatum.io"
TATUM_API_KEY="ISI_DENGAN_TATUM_API_KEY_ANDA"

SPONSOR_PRIVATE_KEY="suikey1..."

# --- 5. Gemini AI Moderation ---
# Get a key from https://aistudio.google.com/apikey
GEMINI_API_KEY=""
# Optional model override (default: gemini-2.0-flash)
# GEMINI_MODEL="gemini-2.0-flash"

πŸ’‘ Tip: If REDIS_URL is left empty, the server uses a built-in in-memory cache simulator β€” ideal for development without Redis. If TATUM_API_KEY is left empty, the indexer automatically falls back to public Sui RPC endpoints.

Client (client/.env)

# =========================================================================
# BlobCast β€” Frontend Client Environment Configurations Example
# =========================================================================

# --- 1. API Backend Url ---
# URL of the Express API backend server
NEXT_PUBLIC_API_URL="http://localhost:8080/api"

# --- 2. Sui Blockchain Configuration ---
# Deployed Move contract package ID on Sui Testnet/Mainnet
NEXT_PUBLIC_BLOBCAST_PACKAGE_ID=""

# --- 3. Active Sui network: 'testnet' or 'mainnet' ---
NEXT_PUBLIC_SUI_NETWORK="testnet"

# --- 4. Walrus Gateway Configuration ---
# Public Walrus publisher and aggregator endpoints
NEXT_PUBLIC_WALRUS_PUBLISHER_URL="https://publisher.walrus-testnet.walrus.space"
NEXT_PUBLIC_WALRUS_AGGREGATOR_URL="https://aggregator.walrus-testnet.walrus.space"

πŸ”Œ API Endpoints

Authentication

Method Endpoint Description
POST /auth/login Login with wallet signature
POST /auth/logout Logout & invalidate session

Posts

Method Endpoint Description
GET /posts Fetch all posts (paginated)
GET /posts/:id Fetch single post by ID
POST /posts Create new post (auth required)
POST /posts/:id/like Toggle like on post
POST /posts/:id/repost Toggle repost
POST /posts/:id/comments Add comment (Walrus blob)
GET /posts/notifications Fetch latest indexer notifications

Users

Method Endpoint Description
GET /users/:id Fetch user profile
PUT /users/:id Update profile
GET /users/:id/posts Fetch user's posts
POST /users/:id/follow Follow/unfollow user
GET /users/:id/followers Fetch followers list

🌟 Key Features

  • πŸ” Wallet-native Authentication β€” Login with only a Sui wallet, no password required
  • πŸ“ Permanent Posts β€” Every post is stored permanently on Walrus
  • βœ… On-chain Authorship β€” Content ownership verified on the Sui blockchain
  • πŸ“‘ Real-time Indexer β€” Daemon that listens to Sui events via Tatum RPC
  • πŸ”₯ Trending Engine β€” Redis-powered trending hashtags and post scoring
  • πŸ” Social Interactions β€” Like, repost, comment, follow
  • πŸ’° SUI Tipping β€” Tip creators directly with SUI coin
  • πŸ”– Bookmarks β€” Save favorite posts
  • πŸ” Search β€” Search posts, hashtags, and users
  • πŸ›‘οΈ AI Moderation β€” Flagged content is hidden in the UI; blobs remain immutable

πŸ“„ License

MIT License β€” see the LICENSE file for details.


BlobCast β€” Own your posts forever.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages