A Decentralized Chat App with Gaia and Storacha
Harish Kotra (he/him)

Harish Kotra (he/him) @harishkotra

About: I do/build: Chatbots | Hackathons | WordPress | Developer Events | Web & Mobile Apps

Location:
Hyderabad, India
Joined:
Sep 14, 2018

A Decentralized Chat App with Gaia and Storacha

Publish Date: Aug 25
0 0

I've created a full-stack web application that demonstrates how AI conversations can be both intelligent and permanently preserved on decentralized infrastructure. The app allows users to:

  • Chat with AI models running on Gaia nodes
  • Customize system prompts in real-time
  • Store complete conversations with rich metadata on Storacha
  • Access stored conversations via IPFS with full transparency
  • Track token usage and conversation analytics

Why This Matters

Traditional AI chat applications store your conversations on centralized servers, often with limited transparency about data usage, retention, or accessibility. This approach has several limitations:

  • Data ownership: Your conversations belong to the platform, not you
  • Transparency: You can't see exactly what data is stored or how it's processed
  • Permanence: Conversations can be deleted or lost when services shut down
  • Portability: Moving your data between platforms is difficult or impossible

Our decentralized approach solves these problems by putting users in complete control of their AI interactions.

The Technology Stack

Gaia: Decentralized AI Inference

Gaia provides OpenAI-compatible API endpoints powered by decentralized nodes. This means:

  • No single point of failure: AI inference is distributed across multiple nodes
  • Transparency: You know exactly which model and node is processing your requests
  • Customization: Full control over system prompts and model parameters
  • Privacy: Your conversations aren't stored on centralized AI company servers

Storacha: Permanent Decentralized Storage

Storacha leverages IPFS and Filecoin to provide permanent, decentralized storage with:

  • Content addressing: Each conversation gets a unique, immutable CID
  • Permanent availability: Data is stored across multiple nodes with Filecoin backing
  • Direct access: Anyone can access stored conversations via IPFS gateways
  • Cryptographic verification: Content integrity is guaranteed by cryptographic hashes

Key Features Deep Dive

1. Real-Time System Prompt Editing

One of the most powerful features is the ability to customize system prompts on the fly. Users can:

  • View the current system prompt from the Gaia node
  • Edit and customize prompts for specific use cases
  • See prompts applied immediately to new conversations
  • Store conversations with the exact prompt used

This level of control is rarely available in traditional AI chat applications.

2. Rich Metadata Storage

Every conversation stored on Storacha includes comprehensive metadata:

{
  "id": "conversation-1234567890",
  "timestamp": "2025-01-08T12:00:00.000Z",
  "messages": [...],
  "metadata": {
    "stored_at": "2025-01-08T12:05:00.000Z",
    "model": "Llama-3-Groq-8B-Tool",
    "gaia_node_url": "https://node.gaia.domains",
    "system_prompt": "You're a helpful assistant...",
    "space_did": "did:key:z6Mk...",
    "space_name": "gaia-storacha-example",
    "total_tokens": 150,
    "file_size_bytes": 2048
  }
}
Enter fullscreen mode Exit fullscreen mode

This metadata provides complete transparency about:

  • Which AI model generated the responses
  • What system prompt was used
  • Token consumption for cost tracking
  • Storage details for verification

3. Markdown and Code Formatting

The application automatically detects and formats various content types:

  • Code blocks with syntax highlighting
  • Markdown rendering for structured content
  • Tables, lists, and headers for complex responses
  • Mathematical expressions and technical content

This makes it perfect for technical discussions, code reviews, and educational content.

4. Dual Access Methods

For each stored conversation, users get:

  • Load Chat: Continues the conversation in the current session
  • View on Storacha: Opens the raw JSON data via IPFS for full transparency

This dual approach balances usability with transparency.

Technical Implementation

Backend Architecture

The Node.js backend uses:

  • Express.js for the web server
  • OpenAI SDK for Gaia node communication
  • Storacha Client for decentralized storage
  • Axios for metadata fetching

Frontend Design

The frontend is built with vanilla JavaScript and features:

  • Modern, clean UI with professional color scheme
  • Responsive design that works on desktop and mobile
  • Real-time formatting with Prism.js for syntax highlighting
  • Markdown parsing with marked.js and DOMPurify for security

Storage Strategy

The app uses a "Bring Your Own Delegations" approach with Storacha:

  1. Space Creation: Users create a dedicated Storacha space
  2. Agent Delegation: Generate agent keys and delegation proofs
  3. Secure Storage: All conversations are stored with cryptographic verification
  4. IPFS Access: Direct access via content-addressed URLs

Getting Started

Setting up the application requires credentials from both services:

Gaia Setup

# Get a Gaia node endpoint and API key
GAIA_API_URL=https://your-gaia-node.com/v1
GAIA_API_KEY=your-api-key
Enter fullscreen mode Exit fullscreen mode

Storacha Setup

# Install CLI and create space
npm install -g @storacha/cli
storacha login your-email@example.com
storacha space create gaia-storacha-demo

# Generate delegation
storacha key create
storacha delegation create <did> --base64
Enter fullscreen mode Exit fullscreen mode

The complete setup process is documented in the project README.

Real-World Applications

This architecture opens up numerous possibilities:

Educational Platforms

  • Permanent lesson storage: AI tutoring sessions stored permanently
  • Progress tracking: Complete learning history with metadata
  • Shareable content: Students can share AI explanations via IPFS links

Research and Development

  • Experiment documentation: AI-assisted research with permanent records
  • Collaboration: Researchers can share AI conversations with full context
  • Reproducibility: Exact prompts and models used are preserved

Content Creation

  • Writing assistance: AI brainstorming sessions stored for reference
  • Version control: Track how ideas evolved through AI conversations
  • Portfolio building: Demonstrate AI collaboration skills

Business Applications

  • Customer support: AI interactions with permanent audit trails
  • Training data: Build datasets from real conversations
  • Compliance: Immutable records for regulatory requirements

The combination of Gaia and Storacha creates a powerful foundation for the next generation of AI applications. By prioritizing user control, transparency, and permanence, we can build AI tools that truly serve users rather than extracting value from them.

This project is just the beginning. The decentralized AI ecosystem is rapidly evolving, and I'm excited to see what the community builds next. Whether you're a developer interested in decentralized technologies, a researcher looking for transparent AI tools, or simply someone who values data ownership, this application demonstrates what's possible when we put users first.

The future of AI is decentralized, transparent, and user-controlled. And that future is available today.


Try It Yourself

Ready to explore decentralized AI conversations? Check out the project on GitHub and follow the setup guide to start building your own AI applications with Gaia and Storacha.

Links:

Examples of Data Stored on Storacha

Comments 0 total

    Add comment