# Aphrodite Domain

> Sensual Performance Streaming Platform Libraries — capped at music-video grade

Aphrodite is the sensual-performance streaming domain within the Oshun monorepo.
It provides all the building blocks needed to build a full-featured dance,
performance, and creator-economy platform: device integration, payment
processing, real-time chat, VR experiences, AI-generated and stylised performer
support, real strip-club / dance-studio venue partnerships, and the compliance
tooling that comes with running an adult-adjacent platform.

## The Music-Video Cap

Aphrodite caps the level of eroticism platform-wide at what is acceptable in a
commercially-broadcast Nicki Minaj / Cardi B / Megan Thee Stallion / Drake /
Future music video. The cap covers every surface of the platform — public
streams, private shows, VR rooms, VOD purchases, virtual gifts, AI-generated
content, partnered strip-club broadcasts.

**On-policy.** Twerking in a thong, lingerie / swimwear / dancewear posing,
sensual choreography, body-rolls, pole and burlesque routines, sensual
storytelling, stylised android and humanoid-alien sensual performance, fully
AI-generated personas (with synthetic-content disclosure), and live in-venue
strip-club broadcasts (stage-only camera zones, no full nudity on-camera).

**Off-policy.** Full nudity, exposed genitals, exposed anus, exposed nipples
(pasties acceptable), explicit sexual acts, on-camera penetration, on-camera
oral, on-camera masturbation focused on genital contact, ejaculation, or
hardcore BDSM with sustained pain emphasis. These are rejected by moderation
regardless of viewer age, paywall, or private-show carve-out.

The canonical cap matrix lives in
`libs/aphrodite/core/src/domain/content-policy.ts`. Moderation thresholds,
consent activity catalogues, venue-partnership contracts, AI prompt guardrails,
and the recommendation re-ranker all read from that module.

## Table of Contents

1. [Architecture Overview](#architecture-overview)
2. [Library Categories](#library-categories)
3. [Getting Started](#getting-started)
4. [Core Libraries](#core-libraries)
5. [Device Integration](#device-integration)
6. [Streaming Features](#streaming-features)
7. [Payment Systems](#payment-systems)
8. [VR/AR Features](#vrar-features)
9. [AI & Analytics](#ai--analytics)
10. [Security & Compliance](#security--compliance)
11. [Configuration](#configuration)
12. [Testing](#testing)

---

## Architecture Overview

The Aphrodite domain follows a modular architecture where each library handles a
specific concern. Libraries are designed to be composable and can be used
independently or together.

```
┌──────────────────────────────────────────────────────────────────────────┐
│                           APPLICATION LAYER                               │
│  (Your application using Aphrodite libraries)                            │
└─────────────────────────────────┬────────────────────────────────────────┘
                                  │
┌─────────────────────────────────▼────────────────────────────────────────┐
│                           APHRODITE SDK                                   │
│  @aphrodite/sdk - Unified entry point for all features                   │
└─────────────────────────────────┬────────────────────────────────────────┘
                                  │
        ┌─────────────────────────┼─────────────────────────┐
        │                         │                         │
        ▼                         ▼                         ▼
┌───────────────┐    ┌────────────────────┐    ┌────────────────────┐
│   STREAMING   │    │      DEVICES       │    │     PAYMENTS       │
├───────────────┤    ├────────────────────┤    ├────────────────────┤
│ streaming-core│    │ device-protocols   │    │ payments           │
│ vr-core       │    │ buttplug           │    │ crypto-payments    │
│ cloud-recording│   │ haptics            │    │ privacy-coins      │
│ multi-source  │    │ wearables          │    │ ppv                │
│ video-effects │    │ smart-home         │    │ revenue-sharing    │
└───────────────┘    └────────────────────┘    └────────────────────┘
        │                         │                         │
        └─────────────────────────┼─────────────────────────┘
                                  │
        ┌─────────────────────────┼─────────────────────────┐
        │                         │                         │
        ▼                         ▼                         ▼
┌───────────────┐    ┌────────────────────┐    ┌────────────────────┐
│   ANALYTICS   │    │      CHAT          │    │    COMPLIANCE      │
├───────────────┤    ├────────────────────┤    ├────────────────────┤
│ analytics     │    │ chat-core          │    │ age-verification   │
│ recommendations│   │ chat-moderation    │    │ compliance-2257    │
│ gamification  │    │ chat-entertainment │    │ gdpr-compliance    │
│ ai-assistant  │    │ virtual-rooms      │    │ drm                │
└───────────────┘    └────────────────────┘    └────────────────────┘
                                  │
                                  ▼
        ┌────────────────────────────────────────────────────┐
        │                   CORE LAYER                        │
        ├────────────────────────────────────────────────────┤
        │ @aphrodite/core - Types, validation, utilities     │
        │ @aphrodite/database - Database abstractions        │
        │ @aphrodite/cache - Caching layer                   │
        │ @aphrodite/storage - File/media storage            │
        │ @aphrodite/event-publisher - Event system          │
        └────────────────────────────────────────────────────┘
                                  │
                                  ▼
        ┌────────────────────────────────────────────────────┐
        │              OSHUN SHARED LIBRARIES                 │
        │ @oshun/logging, @oshun/config, @oshun/database...  │
        └────────────────────────────────────────────────────┘
```

---

## Library Categories

### Core Infrastructure (9 libraries)

| Library           | Description                               |
| ----------------- | ----------------------------------------- |
| `core`            | Platform types, validation, utilities     |
| `database`        | Database abstractions for Aphrodite data  |
| `cache`           | Redis-based caching layer                 |
| `storage`         | S3-compatible file storage                |
| `event-publisher` | Event publishing and subscription system  |
| `oauth-providers` | OAuth integration (Google, Twitter, etc.) |
| `safety`          | Safety features and emergency controls    |
| `sdk`             | Unified SDK for easy integration          |
| `payment`         | Payment processing utilities              |

### Device Integration (12 libraries)

| Library                 | Description                      |
| ----------------------- | -------------------------------- |
| `device-protocols`      | Device protocol definitions      |
| `buttplug`              | Buttplug.io integration          |
| `haptics`               | Haptic feedback system           |
| `bidirectional-haptics` | Two-way haptic communication     |
| `motion-haptics`        | Motion-based haptics             |
| `audio-haptics`         | Audio-reactive haptics           |
| `wearables`             | Wearable device integration      |
| `smart-home`            | Smart home device control        |
| `eye-tracking`          | Eye tracking for VR              |
| `vr-quest`              | Meta Quest VR integration        |
| `vr-haptics`            | VR-specific haptic feedback      |
| `interactables`         | Interactive elements for streams |

### Streaming & Media (10 libraries)

| Library                   | Description                    |
| ------------------------- | ------------------------------ |
| `streaming-core`          | Core streaming functionality   |
| `cloud-recording`         | Cloud-based stream recording   |
| `multi-source`            | Multi-camera/source streaming  |
| `video-effects`           | Real-time video effects        |
| `stream-upscaling`        | AI-powered stream upscaling    |
| `highlight-clipping`      | Stream highlight creation      |
| `vod-chaptering`          | VOD chapter management         |
| `thumbnail-generation`    | Automatic thumbnail generation |
| `content-tagging`         | AI content tagging             |
| `stream-content-analysis` | Stream content analysis        |

### VR/AR Features (7 libraries)

| Library          | Description             |
| ---------------- | ----------------------- |
| `vr-core`        | Core VR functionality   |
| `vr-quest`       | Meta Quest integration  |
| `vr-haptics`     | VR haptic feedback      |
| `spatial-audio`  | 3D spatial audio        |
| `virtual-rooms`  | Virtual room management |
| `ar-overlays`    | AR overlay system       |
| `viewer-avatars` | Viewer avatar system    |

### Avatar & Animation (6 libraries)

| Library                   | Description                    |
| ------------------------- | ------------------------------ |
| `avatar-motion`           | Avatar motion capture          |
| `avatar-renderer`         | Avatar rendering system        |
| `avatar-physics`          | Avatar physics simulation      |
| `avatar-customization-ui` | Avatar customization interface |
| `animations`              | Animation system               |
| `animation-blending`      | Animation blend trees          |
| `animation-triggers`      | Animation trigger system       |

### Chat & Social (8 libraries)

| Library               | Description                          |
| --------------------- | ------------------------------------ |
| `chat-core`           | Core chat functionality              |
| `chat-moderation`     | Chat moderation tools                |
| `chat-entertainment`  | Entertainment features (games, etc.) |
| `chat`                | High-level chat integration          |
| `virtual-rooms`       | Virtual chat rooms                   |
| `viewer-interactions` | Viewer interaction system            |
| `tip-acknowledgment`  | Tip acknowledgment system            |
| `vip-areas`           | VIP-only areas and features          |

### Payment & Monetization (10 libraries)

| Library           | Description                           |
| ----------------- | ------------------------------------- |
| `payments`        | Payment processing system             |
| `crypto-payments` | Cryptocurrency payments               |
| `privacy-coins`   | Privacy-focused crypto (Monero, etc.) |
| `ppv`             | Pay-per-view system                   |
| `revenue-sharing` | Revenue sharing between creators      |
| `tip-effects`     | Visual effects for tips               |
| `tip-goals`       | Tip goal system                       |
| `virtual-gifts`   | Virtual gift marketplace              |
| `gamification`    | Gamification features                 |
| `nft-integration` | NFT marketplace integration           |

### AI & Analytics (6 libraries)

| Library                     | Description                      |
| --------------------------- | -------------------------------- |
| `analytics`                 | Comprehensive analytics platform |
| `recommendations`           | Content recommendation engine    |
| `ai-assistant`              | AI assistant for creators        |
| `notification-intelligence` | Smart notification system        |
| `stream-content-analysis`   | AI content analysis              |
| `content-tagging`           | Automatic content tagging        |

### Security & Compliance (8 libraries)

| Library                | Description                 |
| ---------------------- | --------------------------- |
| `age-verification`     | Age verification system     |
| `compliance-2257`      | 18 U.S.C. 2257 compliance   |
| `gdpr-compliance`      | GDPR compliance tools       |
| `drm`                  | Digital rights management   |
| `e2e-encryption`       | End-to-end encryption       |
| `stream-watermarking`  | Stream watermarking         |
| `recording-prevention` | Screen recording prevention |
| `content-takedown`     | DMCA takedown handling      |

---

## Getting Started

### Installation

Install the packages you need using pnpm:

```bash
# Install the SDK for full access
pnpm add @aphrodite/sdk

# Or install specific packages
pnpm add @aphrodite/core @aphrodite/streaming-core @aphrodite/payments
```

### Basic Usage

```typescript
// Using the SDK
import { createAphroditeClient } from '@aphrodite/sdk';

const client = createAphroditeClient({
  apiKey: process.env.APHRODITE_API_KEY,
  environment: 'production',
});

// Start a stream
const stream = await client.streaming.createStream({
  title: 'My Stream',
  category: 'gaming',
  isPrivate: false,
});

// Connect a device
await client.devices.connect({
  protocol: 'lovense',
  deviceId: 'device-123',
});

// Process a tip
await client.payments.processTip({
  amount: 100,
  currency: 'tokens',
  recipientId: stream.creatorId,
});
```

### Using Individual Libraries

```typescript
// Core types and utilities
import {
  isAdult,
  formatMoney,
  validatePasswordStrength,
  USER_LIMITS,
} from '@aphrodite/core';

// Streaming
import { StreamManager, createStreamSession } from '@aphrodite/streaming-core';

// Device integration
import { DeviceManager, LovenseProtocol } from '@aphrodite/device-protocols';

// Payments
import { TipService, TokenService } from '@aphrodite/payments';

// Analytics
import { AnalyticsManager, createEventService } from '@aphrodite/analytics';
```

---

## Core Libraries

### @aphrodite/core

The foundation library providing types, validation, and utilities.

```typescript
import {
  // Validation
  isAdult,
  calculateAge,
  isValidUsername,
  isValidEmail,
  validatePasswordStrength,

  // Formatting
  formatMoney,
  formatTokens,
  formatViewerCount,
  formatDuration,

  // Crypto
  generateSecureToken,
  generateStreamKey,
  hashSHA256,

  // Age verification
  validateDateOfBirth,
  generateAgeVerificationToken,

  // Pricing
  calculateBroadcasterEarnings,
  calculateTipPayout,

  // Moderation
  evaluateModerationScores,
  evaluateChatMessage,

  // Permissions
  hasPermission,
  canAccessContent,

  // Constants
  PLATFORM_NAME,
  MINIMUM_AGE,
  USER_LIMITS,
  CONTENT_LIMITS,
} from '@aphrodite/core';
```

### @aphrodite/event-publisher

Event publishing and subscription system.

```typescript
import {
  EventPublisher,
  EventSubscriber,
  createStreamEvent,
  createTipEvent,
} from '@aphrodite/event-publisher';

const publisher = new EventPublisher(repository);

// Publish events
await publisher.publish(
  createStreamEvent({
    type: 'stream_started',
    streamId: 'stream-123',
    creatorId: 'creator-456',
  })
);

// Subscribe to events
const subscriber = new EventSubscriber(repository);
subscriber.on('stream_started', (event) => {
  console.log('Stream started:', event.streamId);
});
```

---

## Device Integration

### @aphrodite/device-protocols

Unified device protocol support.

```typescript
import {
  DeviceManager,
  LovenseProtocol,
  KiirooProtocol,
  HandyProtocol,
  ButtplugProtocol,

  // Command types
  VibrateCommand,
  StrokeCommand,
  PatternCommand,
} from '@aphrodite/device-protocols';

const manager = new DeviceManager();

// Connect a device
const device = await manager.connect({
  protocol: 'lovense',
  connectionType: 'bluetooth',
});

// Send commands
await device.vibrate({ intensity: 50, duration: 1000 });
await device.executePattern({ pattern: 'wave', speed: 1.0 });
```

### @aphrodite/buttplug

Buttplug.io integration for universal device support.

```typescript
import { ButtplugClient, createButtplugServer } from '@aphrodite/buttplug';

const client = new ButtplugClient('Aphrodite');
await client.connect(serverUrl);

// Scan for devices
await client.startScanning();
client.on('deviceadded', (device) => {
  console.log('Device connected:', device.name);
});
```

---

## Streaming Features

### @aphrodite/streaming-core

Core streaming functionality.

```typescript
import {
  StreamManager,
  createStreamSession,
  StreamSessionRepository,
} from '@aphrodite/streaming-core';

const manager = new StreamManager(repository, config);

// Start a stream
const session = await manager.startStream({
  broadcasterId: 'broadcaster-123',
  title: 'Live Stream',
  category: 'amateur',
  tags: ['solo', 'interactive'],
});

// Track viewers
await manager.addViewer(session.id, 'viewer-456');
const analytics = await manager.getAnalytics(session.id);

// End stream
await manager.endStream(session.id);
```

### @aphrodite/vr-core

VR streaming capabilities.

```typescript
import {
  VRStreamManager,
  getPresetForBandwidth,
  getStereoConversionConfig,
  VR_QUALITY_PRESETS,
} from '@aphrodite/vr-core';

// Get optimal preset for bandwidth
const preset = getPresetForBandwidth(15000, '180');
console.log('Using preset:', preset.name);

// Configure stereo conversion
const conversion = getStereoConversionConfig('side-by-side', 'top-bottom');
```

---

## Payment Systems

### @aphrodite/payments

Payment processing system.

```typescript
import { TipService, TokenService, EarningsService } from '@aphrodite/payments';

// Process a tip
const tipService = new TipService(repository);
const tip = await tipService.processTip({
  senderId: 'viewer-123',
  recipientId: 'creator-456',
  amount: 100,
  message: 'Great stream!',
});

// Manage tokens
const tokenService = new TokenService(repository);
await tokenService.purchaseTokens({
  userId: 'viewer-123',
  amount: 1000,
  paymentMethod: 'credit_card',
});
```

### @aphrodite/gamification

Gamification features.

```typescript
import {
  AchievementService,
  LeaderboardService,
  LevelService,
  LoyaltyService,
} from '@aphrodite/gamification';

// Award achievements
const achievements = new AchievementService(repository);
await achievements.checkAndAward('viewer-123', 'first_tip');

// Leaderboards
const leaderboards = new LeaderboardService(repository);
const topTippers = await leaderboards.getLeaderboard('weekly_tips', 10);
```

---

## Configuration

### Environment Variables

```bash
# Database
APHRODITE_DATABASE_URL=postgresql://...
APHRODITE_REDIS_URL=redis://...

# Storage
APHRODITE_S3_BUCKET=aphrodite-media
APHRODITE_CDN_URL=https://cdn.aphrodite.com

# Payment providers
APHRODITE_STRIPE_KEY=sk_...
APHRODITE_CCBILL_ACCOUNT=...

# Device integration
APHRODITE_LOVENSE_TOKEN=...
APHRODITE_BUTTPLUG_SERVER=ws://...

# Security
APHRODITE_JWT_SECRET=...
APHRODITE_ENCRYPTION_KEY=...
```

### Library Configuration

```typescript
import { DEFAULT_ANALYTICS_CONFIG } from '@aphrodite/analytics';
import { DEFAULT_PLATFORM_FEES } from '@aphrodite/core';
import { DEFAULT_REVENUE_CONFIG } from '@aphrodite/analytics';

// Override defaults as needed
const analyticsConfig = {
  ...DEFAULT_ANALYTICS_CONFIG,
  batchSize: 100,
  flushInterval: 5000,
};
```

---

## Testing

All Aphrodite libraries include comprehensive test suites using Vitest.

### Running Tests

```bash
# Run all Aphrodite tests
pnpm nx run-many --target=test --projects="@aphrodite/*"

# Run tests for a specific library
pnpm nx test @aphrodite/core

# Run with coverage
pnpm nx test @aphrodite/core --coverage
```

### Test Utilities

```typescript
import {
  createMockStreamSession,
  createMockDevice,
  createMockTip,
} from '@aphrodite/testing';

describe('MyService', () => {
  it('should process tips', async () => {
    const tip = createMockTip({ amount: 100 });
    // ... test code
  });
});
```

---

## Related Documentation

- [Service Inventory](./service-inventory.md) - Detailed service breakdown
- [Database Schemas](./database-schemas.md) - Database design
- [Communication Architecture](./communication-architecture.md) - Real-time
  architecture
- [External Integrations](./external-integrations.md) - Third-party integrations
- [Security Audit Report](./security-audit-report.md) - Security considerations
- [Code Quality Report](./code-quality-report.md) - Code quality metrics

---

## Contributing

When contributing to Aphrodite libraries:

1. Follow the existing code style and patterns
2. Add comprehensive tests for new functionality
3. Update documentation as needed
4. Use semantic commit messages with `scope:shared`

```bash
# Example commit
git commit -m "feat(shared): add new haptic pattern to @aphrodite/haptics"
```

---

## License

Proprietary - All Rights Reserved
