2025-12-12 15:08:52 -05:00

9.2 KiB

OpChan Core Documentation Index

Complete documentation for @opchan/core - the foundational SDK for building decentralized forums.



Documentation Overview

For Beginners

Start here if you're new to OpChan:

  1. Quick Start (5 min)

    • Minimal working example
    • Essential operations
    • Complete starter template
  2. README (15 min)

    • Package overview
    • Core concepts
    • Quick start guide
    • Usage patterns
  3. Getting Started Guide (30 min)

    • Step-by-step tutorial
    • All features explained
    • Best practices
    • Complete application skeleton

For Developers

Deep dive into building applications:

  1. API Reference (Reference)

    • Complete API documentation
    • All classes and methods
    • Type definitions
    • Usage examples
  2. Sample Applications (Templates)

    • Minimal forum
    • Anonymous-first forum
    • Moderation dashboard
    • Identity explorer
    • Bookmark manager
    • Real-time feed
    • CLI tool

For Advanced Users

Understanding the system:

  1. Architecture Guide (Deep Dive)
    • System overview
    • Core architecture
    • Data flow
    • Key subsystems
    • Cryptographic design
    • Storage strategy
    • Network layer
    • Design patterns
    • Performance considerations
    • Security model

By Topic

Getting Started

Client Setup

Authentication & Identity

Content Management

Moderation

Advanced Features

Architecture & Internals


API Documentation

Core Classes

Type Definitions


Sample Application

Complete Production-Ready Template

Complete Forum Application

A comprehensive, production-ready forum demonstrating all features:

  • Client initialization and configuration
  • Anonymous & wallet authentication
  • Session persistence across reloads
  • Content creation (cells, posts, comments)
  • Voting system (upvote/downvote)
  • Identity resolution (ENS, call signs)
  • Real-time message synchronization
  • Relevance scoring with breakdown
  • Moderation tools (cell owners)
  • Bookmark management
  • Network health monitoring
  • Optimistic UI with pending states
  • Proper error handling
  • Clean architecture

Use this as a foundation for building your decentralized forum application.


Usage Patterns

Common Workflows

Best Practices


Additional Resources


Quick Reference

Essential Imports

// Core client
import { OpChanClient } from '@opchan/core';

// Types
import {
  EVerificationStatus,
  EDisplayPreference,
  type User,
  type Cell,
  type Post,
  type Comment,
  type Bookmark
} from '@opchan/core';

// Utilities
import {
  transformPost,
  transformComment,
  transformCell,
  BookmarkService,
  MessageValidator
} from '@opchan/core';

// Services
import {
  DelegationManager,
  LocalDatabase,
  ForumActions,
  UserIdentityService,
  RelevanceCalculator
} from '@opchan/core';

Most Common Operations

// Initialize
const client = new OpChanClient({ wakuConfig });
await client.database.open();

// Anonymous session
const sessionId = await client.delegation.delegateAnonymous('7days');

// Create post
await client.forumActions.createPost(params, callback);

// Read posts
const posts = Object.values(client.database.cache.posts);

// Get identity
const identity = await client.userIdentityService.getIdentity(address);

Troubleshooting

Common Issues

Debug Tips

  1. Check delegation status: await client.delegation.getStatus()
  2. Monitor network health: client.messageManager.onHealthChange()
  3. Validate messages: await validator.isValidMessage()
  4. Check database: await client.database.open()
  5. Review logs: Enable verbose logging in browser console

Contributing

Documentation improvements are welcome! Please see the main project README for contribution guidelines.


License

MIT License - See LICENSE for details.


Last Updated: December 2024

Version: 1.0.3