Skip to content

Latest commit

 

History

History
218 lines (165 loc) · 6.09 KB

DECOUPLING_VERIFICATION.md

File metadata and controls

218 lines (165 loc) · 6.09 KB

SDK Decoupling Verification

Status: ✅ VERIFIED - SDK is platform-agnostic

Overview

The Dorisio SDK is designed to be embeddable in any platform. This document verifies that the client implementation does not hardcode Dorisio-specific schemas or assumptions.

Platform-Agnostic Design

1. Generic Domain Models

All domain models are defined as generic interfaces in src/types/models.ts:

  • User: Generic user model with id, email, name, role, verified

    • No Dorisio-specific fields
    • Extensible via TypeScript interface merging
    • Can represent any user system (fans, creators, admins)
  • Creator: Generic creator model with id, userId, username, displayName, bio, avatar, verified, isPublic

    • No Dorisio-specific assumptions
    • Can represent any content creator on any platform
    • Earnings fields (totalEarnings, pendingBalance) are generic
  • Wallet: Generic wallet model with id, userId, publicKey, name, verified

    • Platform-agnostic Stellar wallet structure
    • No Dorisio-specific linking logic
  • Transaction: Generic transaction model with id, fromUserId, creatorId, amount, message, status, stellarTxHash

    • Represents any payment transaction
    • No Dorisio-specific fields

2. Client Method Patterns

All client methods follow a generic pattern:

// Generic GET endpoint
export async function getCreator(
  this: DorisioClient,
  creatorId: string
): Promise<Creator>

// Generic POST endpoint with configurable request data
export async function createTip(
  this: DorisioClient,
  data: CreateTipRequest
): Promise<Transaction>

// Generic transaction building (any Stellar payment)
export async function buildPaymentTransaction(
  this: DorisioClient,
  tipId: string,
  data: BuildTransactionRequest
): Promise<BuildTransactionResponse>

Key characteristics:

  • Methods accept generic IDs (strings) without format assumptions
  • Request/response DTOs are decoupled from backend implementation
  • HTTP routes are configurable via baseUrl in client config
  • No implicit Dorisio database schema assumptions

3. HTTP Client Abstraction

The HttpClient class in src/http/http-client.ts is completely generic:

  • Accepts any base URL
  • Makes standard HTTP requests (GET, POST, PATCH, DELETE)
  • Handles authentication via Bearer tokens
  • No hardcoded endpoints or business logic

4. Authentication Layer

Authentication is platform-agnostic:

interface AuthState {
  isAuthenticated: boolean;
  token?: string;
  userId?: string;
  createdAt: number;
}
  • Token-based (JWT or any standard bearer token)
  • No Dorisio-specific auth provider assumptions
  • Works with any backend auth system

5. React Hooks Layer

All React hooks are generic and don't assume Dorisio schemas:

  • useCreateTip: Generic tip creation with configurable creator references
  • useWallet: Generic wallet management
  • useCreatorBalance: Generic earnings queries
  • useTransactionHistory: Generic transaction pagination
  • TipForgeProvider: Generic context that wraps any DorisioClient

6. Configuration

Client configuration is minimal and generic:

interface ClientConfig {
  baseUrl: string;           // Any API URL
  token?: string;            // Any bearer token
  timeout?: number;          // Standard HTTP timeout
}

Embeddability Confirmation

✅ Can be embedded in:

  • Any platform with a REST API matching the documented endpoints
  • Any project using React (via hooks) or vanilla JavaScript
  • Any authentication system using bearer tokens
  • Any Stellar network (testnet, mainnet, standalone)

✅ Requires (from consuming platform):

  • REST API endpoints matching the transaction/wallet routes (documented in backend)
  • Bearer token authentication support
  • Standard HTTP request/response format (JSON)
  • Optional: User/Creator/Wallet models matching the generic interfaces

❌ Does NOT require:

  • Dorisio database schema
  • Dorisio-specific User/Creator models
  • Dorisio authentication system
  • Any Dorisio-specific integrations

Configuration for Different Platforms

Example 1: Generic Payment Platform

const client = new DorisioClient({
  baseUrl: 'https://api.payment-platform.com',
  token: userToken,
});

// Works with any creator and user IDs
const tip = await client.createTip({
  creatorId: 'external-creator-id',
  amount: 50,
  message: 'Support message',
});

Example 2: Streaming Platform Integration

const client = new DorisioClient({
  baseUrl: 'https://streaming-platform.com/api',
  token: streamerToken,
});

// Tip creators on the streaming platform
const wallet = await client.listWallets(streamerId);
const earnings = await client.request('GET', '/creators/earnings');

Example 3: Gaming Platform

const client = new DorisioClient({
  baseUrl: 'https://game-api.example.com',
  token: playerToken,
});

// Support game creators with tips
const tip = await client.createTip({
  creatorId: gameCreatorId,
  amount: 100,
});

Verification Checklist

  • ✅ No hardcoded /dorisio/ path prefixes
  • ✅ No Dorisio-specific field mappings
  • ✅ No Dorisio organization assumptions
  • ✅ Generic HTTP client
  • ✅ Generic domain models
  • ✅ Configurable base URL
  • ✅ Standard Bearer token auth
  • ✅ React-agnostic core client
  • ✅ Generic React hooks
  • ✅ No external dependencies on Dorisio infrastructure

Types are Extensible

Platforms can extend the generic types:

// In consuming platform
interface CustomUser extends User {
  platformId: string;
  customField: string;
}

interface CustomCreator extends Creator {
  platformSpecificData: any;
}

Conclusion

The SDK achieves the design goal of being "embeddable in any platform" by:

  1. Using generic interfaces for all domain models
  2. Making HTTP requests to configurable endpoints
  3. Supporting any bearer token authentication
  4. Providing a framework-agnostic core client
  5. Offering optional React hooks for convenience
  6. Not assuming any Dorisio-specific implementation details

The SDK can be integrated into any platform with minimal customization.