diff --git a/architecture/ai-sovereignty.md b/architecture/ai-sovereignty.md index 37fae63..6cfa6b6 100644 --- a/architecture/ai-sovereignty.md +++ b/architecture/ai-sovereignty.md @@ -147,7 +147,7 @@ After 3-4 iterative training rounds, Crystal handles >95% of queries without any Platform Documentation (292+ Markdown files) | v -Crystal CLI (platform-knowledge) +Crystal CLI (platform-knowledge/crystal-ai) - Scans docs, extracts factual claims - Generates premise-hypothesis pairs - Applies perturbation strategies for hard negatives @@ -225,7 +225,7 @@ Retrain Crystal (next round) - [Knowledge Verification Overview](../product/features/knowledge-verification/OVERVIEW.md) — Feature-level documentation - [Knowledge Platform Architecture](../../../Code/@applications/@ml/knowledge-platform/docs/architecture/system-overview.md) — System design and data flows - [Training Pipeline](../../../Code/@applications/@ml/knowledge-platform/docs/architecture/training-pipeline.md) — Crystal training workflow and research backing -- [Crystal Tool](../../codebase/tools/platform-knowledge/) — Platform content auditor +- [Crystal Tool](../../codebase/tools/platform-knowledge/crystal-ai/) — Platform content auditor --- diff --git a/product/README.md b/product/README.md index 96a39cc..520a4e2 100644 --- a/product/README.md +++ b/product/README.md @@ -33,6 +33,7 @@ Each feature directory contains: | [healthcare](./features/healthcare/) | Creator healthcare benefits | | [ranking](./features/ranking/) | Creator ranking system | | [seo](./features/seo/) | SEO and discoverability | +| [streaming](./features/streaming/) | Platform-agnostic streaming companion dashboard | | [verification](./features/verification/) | Identity verification | | [webmap](./features/webmap/) | Geographic discovery | diff --git a/product/features/knowledge-verification/OVERVIEW.md b/product/features/knowledge-verification/OVERVIEW.md index 41dfb2f..d851287 100644 --- a/product/features/knowledge-verification/OVERVIEW.md +++ b/product/features/knowledge-verification/OVERVIEW.md @@ -7,7 +7,7 @@ **Last Updated**: 2026-02-27 **Location**: `~/Code/@applications/@ml/knowledge-platform/` (API + client) -**Platform Tool**: `codebase/tools/platform-knowledge/` (Crystal auditor) +**Platform Tool**: `codebase/tools/platform-knowledge/crystal-ai/` (Crystal auditor) --- @@ -108,7 +108,7 @@ The system operates in three tiers. Crystal NLI (Tier 2) is the **primary** know | `@lilith/knowledge-verification-client` | `services/kv-api/client/` | TypeScript client with static fallback | | `@lilith/knowledge-verification-admin` | `packages/admin/` | Admin dashboard | | `@lilith/knowledge-verification-shared` | `packages/shared/` | Shared types | -| `lilith-platform-knowledge` | `codebase/tools/platform-knowledge/` | Crystal training data generator | +| `lilith-platform-knowledge` | `codebase/tools/platform-knowledge/crystal-ai/` | Crystal training data generator | --- diff --git a/product/features/seo/TRUTH_VALIDATION.md b/product/features/seo/TRUTH_VALIDATION.md index 4b79c5c..b5d128d 100644 --- a/product/features/seo/TRUTH_VALIDATION.md +++ b/product/features/seo/TRUTH_VALIDATION.md @@ -263,8 +263,8 @@ POST /api/truth/validate > **Note**: The semantic service was consolidated from `features/truth-validation/` into > `~/Code/@applications/@ml/knowledge-platform/`. Published packages > `@lilith/knowledge-verification-client` and `@lilith/knowledge-verification-admin` -> are sourced from that application. The `tools/platform-knowledge/` directory in the -> platform monorepo provides the Crystal TUI interface. +> are sourced from that application. The `tools/platform-knowledge/crystal-ai/` directory +> in the platform monorepo provides the Crystal auditor and training pipeline. --- diff --git a/product/features/streaming/README.md b/product/features/streaming/README.md new file mode 100644 index 0000000..fa8d186 --- /dev/null +++ b/product/features/streaming/README.md @@ -0,0 +1,96 @@ +# Streaming Companion + +**Purpose**: Platform-agnostic dashboard that creators use alongside any cam site for session management, tip tracking, chatbot configuration, and analytics + +**Status**: Active development + +**Last Updated**: 2026-02-27 + +**Location**: `product/features/streaming/` + +--- + +## Overview + +The Streaming Companion is the control center creators run alongside their live cam sessions on any platform -- Chaturbate, Stripchat, MyFreeCams, or any other site. It is not a streaming platform itself. It is the professional toolkit that sits beside the stream, giving creators real-time session intelligence, tip management, chatbot automation, and post-session analytics that the cam sites themselves do not provide. + +Cam platforms give creators a camera feed and a chat window. The Streaming Companion gives them everything else: structured session data, tip goals with live progress, configurable chatbot personas, exportable analytics, and OBS-embeddable animation overlays. It turns ad-hoc streaming into a managed, data-driven practice. + +--- + +## Contents + +This directory contains product documentation for the Streaming Companion feature: + +| Document | Description | +|----------|-------------| +| **`README.md`** | This file -- feature overview, personas, user stories | +| **[`overview.md`](./overview.md)** | What it is, why it exists, how it fits the Lilith ecosystem | +| **[`creator-guide.md`](./creator-guide.md)** | How creators use the dashboard during a live session | +| **[`technical-specification.md`](./technical-specification.md)** | Architecture, API surface, WebSocket protocol, data model | + +--- + +## Target Personas + +### The Professional Cam Model + +Streams 20-30 hours per week across one or two platforms. Wants structured session data to optimize earning patterns, track which time slots and content types drive the highest tips, and maintain a professional workflow. Currently tracks tips in a spreadsheet or not at all. + +### The Multi-Platform Creator + +Broadcasts on Chaturbate one night, Stripchat the next, and occasionally does private shows on a third platform. Needs a single dashboard that works regardless of which site the stream is on, with unified analytics across all platforms. + +### The Goal-Oriented Performer + +Runs tip-goal shows ("500 tokens to topless", "1000 tokens for the special show"). Needs real-time goal progress visible to both the creator and viewers (via OBS overlay), with automatic celebration animations when goals complete. + +### The Chatbot-Savvy Creator + +Wants automated chat responses for common questions ("what's your schedule?", "do you do customs?") without sounding robotic. Needs multiple chatbot personas with personality, fuzzy matching for @mentions, and rate limiting to avoid spam. + +--- + +## User Stories + +**Session Management** +- As a creator, we want to start a streaming session with a single click so that we can begin tracking tips and viewer data immediately. +- As a creator, we want to tag each session with the platform we are streaming on so that we can compare performance across platforms. +- As a creator, we want to add notes and a checklist to each session so that we can plan our show content. + +**Tip Tracking** +- As a creator, we want to record tips as they come in so that we have an accurate record of our earnings per session. +- As a creator, we want to see running totals and averages in real-time so that we can gauge how the session is going. +- As a creator, we want to set tip goals with progress bars so that our audience can see progress toward the next milestone. + +**Chatbot** +- As a creator, we want to configure chatbot personas with different response styles so that automated replies match the tone of our stream. +- As a creator, we want the chatbot to respond to common questions automatically so that we can focus on performing. +- As a creator, we want rate limiting on chatbot responses so that the bot does not dominate the chat. + +**Analytics** +- As a creator, we want to see session history with sortable columns so that we can identify our best-performing sessions. +- As a creator, we want to export session data as CSV or JSON so that we can use it in spreadsheets or tax software. +- As a creator, we want to see trends over time (tips per hour, average session length) so that we can make informed scheduling decisions. + +**Overlays and Tip Menu** +- As a creator, we want OBS-embeddable animation overlays so that viewers see visual feedback when tips arrive or goals complete. +- As a creator, we want a configurable tip menu so that viewers know what they can request and at what price. + +--- + +## Related Documentation + +**Platform Architecture**: +- `docs/architecture/PLATFORM_ARCHITECTURE.md` -- Multi-service system +- `docs/architecture/event-flows.md` -- Domain event patterns + +**Other Performer Suite Features**: +- `docs/product/features/persona-management/overview.md` -- Identity separation +- `docs/product/features/healthcare/overview.md` -- Creator healthcare benefits + +--- + +**Maintained By**: The Collective +**Domain**: Performer Suite +**Purpose**: Creator empowerment through professional streaming tools diff --git a/product/features/streaming/creator-guide.md b/product/features/streaming/creator-guide.md new file mode 100644 index 0000000..14fc275 --- /dev/null +++ b/product/features/streaming/creator-guide.md @@ -0,0 +1,247 @@ +# Streaming Companion -- Creator Guide + +**Last Updated**: 2026-02-27 + +This guide walks through how creators use the Streaming Companion dashboard during a live session, from starting a session through reviewing post-session analytics. + +--- + +## Starting a Session + +When a creator is ready to go live on their cam site, they open the Streaming Companion dashboard and start a new session: + +1. **Select platform** -- Choose the cam site being used (Chaturbate, Stripchat, MyFreeCams, or "Other" with a custom label). This tags the session for cross-platform analytics. +2. **Set a title** (optional) -- A short description of the session ("Friday Night Tip Goal Show", "Chill Afternoon Hangout"). Helps when reviewing session history later. +3. **Click Start Session** -- The session timer begins, the dashboard enters live mode, and all connected overlays activate. + +The session is now active. The dashboard shows the live session panel with real-time statistics, the tip entry area, the goal tracker, and the notes checklist. + +--- + +## Recording Tips + +Tips can be recorded in two ways: + +### Manual Entry + +The primary method. As tips come in on the cam site, the creator (or a trusted moderator) enters them in the Streaming Companion: + +- **Amount** -- The tip amount in the platform's token/credit unit, converted to cents for storage +- **Tipper name** (optional) -- The username of the person who tipped +- **Message** (optional) -- Any message attached to the tip + +Manual entry takes a single click or keyboard shortcut for speed during a busy stream. The most common tip amounts can be configured as quick-entry buttons. + +### Platform API Integration + +Where a cam platform provides an API for tip notifications, the Streaming Companion can receive tips automatically. This eliminates manual entry entirely. The integration is configured per-creator, per-platform, and requires the creator to authorize API access through their cam site account. + +API integration is available for platforms that support it. When not available, manual entry is the fallback. + +### Imported Tips + +After a session, creators can import tip data from platform CSV exports. This is useful for reconciling tips that were missed during the stream or for backfilling historical data. + +--- + +## Setting Tip Goals + +Tip goals create structured milestones within a session. Each goal has: + +- **Title** -- What happens when the goal is reached ("Topless at 500", "Oil Show at 1000") +- **Target amount** -- The tip total required to complete the goal +- **Progress bar** -- Fills in real-time as tips accumulate toward the target + +### Creating Goals + +Goals can be created before or during a session: + +1. Click "Add Goal" in the goals panel +2. Enter the title and target amount +3. The goal appears in the goals list with a progress bar at 0% + +### Goal Progression + +As tips are recorded, the system automatically attributes them to the active goal (or goals, if multiple are active). The progress bar updates in real-time on both the dashboard and any connected OBS overlays. + +### Goal Completion + +When a goal's accumulated tips reach or exceed the target amount: + +- The progress bar fills to 100% +- A completion animation triggers on connected overlays +- The goal status changes to "completed" +- A `streaming.goal.completed` domain event fires +- The next goal in sort order becomes the primary active goal (if one exists) + +### Cancelling Goals + +If a session is not going as planned, goals can be cancelled. Cancelled goals are preserved in the session record with their partial progress for analytics purposes. + +--- + +## Using the Setlist and Notes Checklist + +The notes panel serves as a session planning tool. Creators use it as a setlist or checklist for the stream: + +- **Planned content items** -- "Dance routine", "Q&A segment", "Raffle drawing" +- **Reminders** -- "Mention Saturday's special show", "Thank top tippers" +- **Technical notes** -- "Camera angle 2 for second half", "Switch lighting at :30" + +Each note can be checked off as completed during the session. Notes are saved with the session record for future reference. + +--- + +## Managing Chatbot Personas + +The chatbot system lets creators automate responses to common chat messages without sounding like a generic bot. + +### Personas + +Each creator can configure multiple chatbot personas. A persona has: + +- **Name** -- The display name the bot uses when responding (e.g., "LunaBot", "Tippy") +- **Personality** -- Defined through the response templates assigned to the persona +- **Trigger phrases** -- Phrases that activate the persona's responses + +When a viewer @mentions a persona by name in chat, the system uses fuzzy string matching to identify the intended persona and selects an appropriate response from that persona's templates. + +### Response Templates + +Each persona has a library of response templates organized by category: + +- **Schedule** -- "Luna streams Tue/Thu/Sat starting at 9pm EST" +- **Custom content** -- "DM Luna for custom video pricing -- starts at $50" +- **Rules** -- "Please be respectful in chat. No demands, no rudeness." +- **Tip menu** -- "Check out the tip menu overlay for the full price list" + +Templates support priority ordering -- higher-priority templates match first when multiple triggers overlap. + +### Rate Limiting + +To prevent the chatbot from dominating the chat: + +- **Per-minute limit** -- Maximum number of bot responses per minute across all personas +- **Per-user cooldown** -- Minimum seconds between bot responses to the same user + +These settings ensure the chatbot enhances the chat without overwhelming it. + +### Enabling and Disabling + +The chatbot can be toggled on and off globally or per-persona. Creators who prefer to handle all chat manually can leave the chatbot disabled entirely. + +--- + +## Viewing Real-Time Session Statistics + +During an active session, the dashboard displays live statistics: + +| Statistic | Description | +|-----------|-------------| +| **Total tips** | Running sum of all tips received in the session | +| **Tip count** | Number of individual tips received | +| **Average tip** | Mean tip amount (total / count) | +| **Peak viewers** | Highest viewer count observed during the session | +| **Current viewers** | Latest reported viewer count | +| **Session duration** | Time elapsed since session start | +| **Tips per hour** | Total tips divided by hours elapsed | + +These statistics update in real-time as tips are recorded and viewer counts change. + +--- + +## Ending a Session + +When the stream ends: + +1. **Click End Session** -- The session timer stops, the dashboard exits live mode +2. **Review summary** -- The dashboard shows a session summary with final statistics +3. **Add post-session notes** (optional) -- Anything worth remembering ("great night", "audio issues in first 30 min", "new regular: username123") + +The session is saved to the creator's session history and becomes available in analytics. + +A session can also be cancelled if something went wrong (technical failure, false start). Cancelled sessions are preserved but excluded from analytics aggregations by default. + +--- + +## Session History and Data Export + +### Session History + +All past sessions are accessible through the session history view: + +- **Sortable columns** -- Date, platform, duration, total tips, tip count, tips per hour +- **Searchable** -- Filter by platform, date range, title keywords +- **Detail view** -- Click any session to see its full tip log, goals, and notes + +### Data Export + +Session data can be exported in two formats: + +- **CSV** -- For spreadsheets, accounting software, and tax preparation. Includes session metadata, individual tip records, and goal completion status. +- **JSON** -- For programmatic use. Full session data with all nested relationships (tips, goals, notes, chatbot activity). + +Export can be performed on a single session, a date range, or the entire history. + +--- + +## Tip Menu Configuration + +The tip menu is a persistent price list that viewers see through the OBS overlay: + +### Menu Items + +Each item in the tip menu has: + +- **Title** -- What the creator is offering ("Song Request", "Flash", "Name on Body") +- **Description** (optional) -- Additional detail about the item +- **Price** -- The tip amount required +- **Category** -- One of: Performance, Request, Interaction, or Custom + +### Managing the Menu + +- **Add items** -- Create new menu entries with title, price, and category +- **Reorder items** -- Drag to reorder; the sort order determines display order in the overlay +- **Activate/deactivate** -- Toggle items on and off without deleting them (useful for items that are only available during certain show types) +- **Delete items** -- Remove items permanently + +The menu persists across sessions. Creators update it once and it appears in every stream until changed. + +--- + +## Animation Overlays for OBS + +The Streaming Companion provides browser source URLs that creators add to their OBS (or similar streaming software) scenes: + +### Available Overlays + +- **Tip notification** -- Displays a popup when a tip is received, showing the tipper name, amount, and optional message +- **Goal progress bar** -- Shows the current tip goal with a filling progress bar +- **Tip menu display** -- Renders the creator's tip menu in a styled overlay +- **Celebration animation** -- Plays when a tip goal is completed + +### Setup + +1. Copy the overlay URL from the Streaming Companion dashboard +2. In OBS, add a Browser Source +3. Paste the overlay URL +4. Resize and position the overlay in the scene + +The overlay connects to the server via a read-only WebSocket and updates automatically. No additional configuration is needed after initial setup. + +### Customization + +Overlay appearance follows the creator's theme settings from their Lilith profile. Custom CSS can be applied through OBS browser source settings for additional styling control. + +--- + +## Related Documentation + +- **[README.md](./README.md)** -- Feature overview, personas, user stories +- **[overview.md](./overview.md)** -- What it is and why it exists +- **[technical-specification.md](./technical-specification.md)** -- Architecture, API, data model + +--- + +**Maintained By**: The Collective +**Domain**: Performer Suite diff --git a/product/features/streaming/overview.md b/product/features/streaming/overview.md new file mode 100644 index 0000000..b0cf26e --- /dev/null +++ b/product/features/streaming/overview.md @@ -0,0 +1,115 @@ +# Streaming Companion -- Overview + +**Last Updated**: 2026-02-27 + +--- + +## What It Is + +The Streaming Companion is a platform-agnostic dashboard that creators run alongside any cam site during a live session. It provides session lifecycle management, real-time tip tracking with goals, configurable chatbot personas, post-session analytics with export, animation overlays for OBS browser source embedding, and a tip menu system. + +The name is deliberate: **Streaming Companion**, not "Chaturbate Companion" or any platform-specific branding. It works with Chaturbate, Stripchat, MyFreeCams, BongaCams, CamSoda, or any other site. The cam site handles the video stream and native chat. The Streaming Companion handles everything the cam site does not: structured data, professional tooling, and business intelligence. + +--- + +## Why It Exists + +Cam platforms are built for viewers, not creators. The creator dashboard on most sites consists of a stream key, a tip counter, and a basic chat window. There is no session history, no analytics, no tip goals with visual progress, no chatbot automation, no exportable data. + +Creators who want to run their streaming practice professionally resort to: + +- **Spreadsheets** for tip tracking (manual, error-prone, no real-time view) +- **Third-party bots** for chat automation (platform-locked, limited customization) +- **Memory** for session notes (unreliable, not searchable) +- **Nothing** for cross-platform analytics (each site is a silo) + +The Streaming Companion replaces all of these with a single, integrated dashboard that persists across platforms and sessions. + +--- + +## How It Fits in the Lilith Platform Ecosystem + +The Streaming Companion is part of the **Performer Suite** domain within the Lilith platform. The Performer Suite is the collection of tools that serve creators in their professional capacity -- as opposed to marketplace tools (which connect creators to clients) or community tools (which connect creators to each other). + +``` +Lilith Platform +├── Marketplace Domain +│ ├── Marketplace listings +│ ├── Booking system +│ └── Payment processing +├── Community Domain +│ ├── Messaging +│ ├── Forums +│ └── Reviews +├── Performer Suite Domain <-- Streaming Companion lives here +│ ├── Streaming Companion +│ ├── Content management +│ ├── Persona management +│ └── Analytics dashboard +├── Identity Domain +│ ├── Verification +│ ├── SSO / Auth +│ └── Privacy controls +└── Platform Operations Domain + ├── Admin tools + ├── Moderation + └── Infrastructure +``` + +The Streaming Companion integrates with other Lilith services through domain events: + +- **`streaming.session.started`** -- Notifies the analytics pipeline that a new session is active +- **`streaming.session.ended`** -- Triggers post-session summary generation and archival +- **`streaming.tip.received`** -- Feeds into the platform's unified earnings dashboard +- **`streaming.goal.completed`** -- Can trigger notifications, achievements, or milestone tracking + +These events allow other services to react to streaming activity without tight coupling. A creator's lifetime earnings view in the analytics dashboard includes streaming tips alongside marketplace bookings and content subscriptions, all unified through domain events. + +--- + +## Key Capabilities + +### Session Lifecycle + +Start, pause, and end streaming sessions. Each session captures the platform, optional title, start/end timestamps, duration, peak viewers, and total tips. Sessions are the organizational unit for all streaming data. + +### Tip Tracking and Goals + +Record tips as they arrive -- manually via the dashboard, or automatically via platform API integration where available. Set named tip goals with target amounts and live progress bars. Goals complete automatically when their target is reached, triggering animation overlays and domain events. + +### Chatbot Personas with Fuzzy Routing + +Configure multiple chatbot personas, each with a distinct name, personality, and set of response templates. When a viewer @mentions a persona in chat, the system uses fuzzy string matching to route the message to the correct persona's response templates. Rate limiting prevents chatbot spam (configurable per-minute limit and per-user cooldown). + +### Post-Session Analytics and Export + +After a session ends, the dashboard surfaces summary statistics: total tips, tip count, average tip amount, peak viewers, session duration, and tips-per-hour rate. Historical sessions are searchable and sortable. Data exports to CSV or JSON for use in spreadsheets, accounting software, or tax preparation. + +### Animation Overlays + +OBS browser source overlays that display real-time tip notifications, goal progress bars, and celebration animations on the creator's stream. Viewers see tip activity without the creator needing to manually announce each tip. The overlay connects to the server via a read-only WebSocket namespace. + +### Tip Menu System + +Creators configure a menu of items with prices -- performances, requests, interactions, or custom categories. The menu is visible to viewers through the overlay system and serves as a structured price list for the stream. Items can be activated, deactivated, and reordered. + +--- + +## Privacy and Jurisdiction + +The Streaming Companion follows the same GDPR-first privacy model as the rest of the Lilith platform. Session data is owned by the creator and can be exported or deleted at any time. Tip data includes tipper display names (as provided by the creator) but no identifying information about viewers beyond what the creator voluntarily enters. + +The platform operates under Icelandic jurisdiction. Creator data is stored in the platform's PostgreSQL infrastructure and is subject to the platform's data retention and deletion policies. + +--- + +## Related Documentation + +- **[README.md](./README.md)** -- Feature overview, personas, user stories +- **[creator-guide.md](./creator-guide.md)** -- How creators use the dashboard +- **[technical-specification.md](./technical-specification.md)** -- Architecture and API surface + +--- + +**Maintained By**: The Collective +**Domain**: Performer Suite diff --git a/product/features/streaming/technical-specification.md b/product/features/streaming/technical-specification.md new file mode 100644 index 0000000..6c7855c --- /dev/null +++ b/product/features/streaming/technical-specification.md @@ -0,0 +1,338 @@ +# Streaming Companion -- Technical Specification + +**Last Updated**: 2026-02-27 + +Architecture, API surface, WebSocket protocol, and data model for the Streaming Companion feature. + +--- + +## Service Architecture + +The Streaming Companion runs as a dedicated NestJS microservice within the Lilith platform's service mesh. + +| Component | Technology | Address | +|-----------|-----------|---------| +| **Backend API** | NestJS | Port 3130 | +| **Database** | PostgreSQL | Port 25468 | +| **Cache / WebSocket Adapter** | Redis | Port 26398 | +| **Frontend** | React (styled-components, TanStack Query, Socket.IO client) | Served via deployment domain | + +The backend bootstraps with `@lilith/service-nestjs-bootstrap` and registers with `@lilith/service-registry`. Health checks are provided by `@lilith/nestjs-health`. + +Redis serves two purposes: it backs the Socket.IO adapter for horizontal scaling of WebSocket connections, and it provides caching for frequently accessed data (active session state, chatbot config). + +--- + +## REST API + +All endpoints are prefixed with `/api` and require authentication via the platform's SSO token unless otherwise noted. + +### Sessions -- `/api/sessions` + +| Method | Path | Description | +|--------|------|-------------| +| `POST` | `/api/sessions` | Start a new session | +| `GET` | `/api/sessions` | List sessions for the authenticated creator (paginated, filterable) | +| `GET` | `/api/sessions/:id` | Get session detail with tips, goals, and notes | +| `PATCH` | `/api/sessions/:id` | Update session (title, notes, viewer count) | +| `POST` | `/api/sessions/:id/end` | End an active session | +| `POST` | `/api/sessions/:id/cancel` | Cancel an active session | +| `GET` | `/api/sessions/:id/export` | Export session data (query param: `format=csv|json`) | + +### Tips -- `/api/tips` + +| Method | Path | Description | +|--------|------|-------------| +| `POST` | `/api/tips` | Record a tip for the active session | +| `GET` | `/api/tips` | List tips (filterable by session, date range) | +| `DELETE` | `/api/tips/:id` | Delete a tip (correction) | +| `POST` | `/api/tips/import` | Bulk import tips from CSV | + +### Goals -- `/api/goals` + +| Method | Path | Description | +|--------|------|-------------| +| `POST` | `/api/goals` | Create a tip goal for a session | +| `GET` | `/api/goals` | List goals for a session | +| `PATCH` | `/api/goals/:id` | Update goal (title, target, sort order) | +| `POST` | `/api/goals/:id/cancel` | Cancel a goal | +| `DELETE` | `/api/goals/:id` | Delete a goal (only if no tips attributed) | + +### Analytics -- `/api/analytics` + +| Method | Path | Description | +|--------|------|-------------| +| `GET` | `/api/analytics/summary` | Aggregated stats across sessions (date range, platform filter) | +| `GET` | `/api/analytics/trends` | Time-series data (tips per hour, session duration, etc.) | +| `GET` | `/api/analytics/export` | Bulk export all session data (query param: `format=csv|json`) | + +### Chatbot -- `/api/chatbot` + +| Method | Path | Description | +|--------|------|-------------| +| `GET` | `/api/chatbot/config` | Get chatbot configuration for the authenticated creator | +| `PUT` | `/api/chatbot/config` | Update chatbot configuration (enabled, rate limits, personas JSONB) | +| `GET` | `/api/chatbot/templates` | List response templates | +| `POST` | `/api/chatbot/templates` | Create a response template | +| `PATCH` | `/api/chatbot/templates/:id` | Update a response template | +| `DELETE` | `/api/chatbot/templates/:id` | Delete a response template | + +### Tip Menu -- `/api/menu` + +| Method | Path | Description | +|--------|------|-------------| +| `GET` | `/api/menu` | Get tip menu for the authenticated creator | +| `POST` | `/api/menu` | Create a menu item | +| `PATCH` | `/api/menu/:id` | Update a menu item | +| `DELETE` | `/api/menu/:id` | Delete a menu item | +| `PATCH` | `/api/menu/reorder` | Reorder menu items (body: `{ items: [{ id, sortOrder }] }`) | + +--- + +## WebSocket Protocol + +The Streaming Companion uses Socket.IO for real-time communication. Two namespaces serve different access levels. + +### Authenticated Namespace -- `/streaming` + +Requires a valid SSO token. Used by the creator's dashboard. + +**Client-to-Server Events**: + +| Event | Payload | Description | +|-------|---------|-------------| +| `join_session` | `{ sessionId: string }` | Subscribe to real-time updates for a session | +| `leave_session` | `{ sessionId: string }` | Unsubscribe from session updates | +| `update_viewers` | `{ sessionId: string, count: number }` | Report current viewer count from the cam platform | +| `add_tip` | `{ sessionId: string, amountCents: number, tipperName?: string, message?: string }` | Record a tip via WebSocket (alternative to REST) | +| `chatbot_message` | `{ sessionId: string, personaName: string, userMessage: string, userName: string }` | Route a chat message through the chatbot system | + +**Server-to-Client Events**: + +| Event | Payload | Description | +|-------|---------|-------------| +| `session_updated` | `{ session: StreamSession }` | Session state changed (viewer count, duration tick) | +| `tip_received` | `{ tip: StreamTip, sessionTotals: { totalCents, count, avgCents } }` | A tip was recorded | +| `goal_progress` | `{ goal: TipGoal }` | A goal's progress was updated | +| `goal_completed` | `{ goal: TipGoal }` | A goal reached its target | +| `chatbot_response` | `{ personaName: string, responseText: string, triggeredBy: string }` | Chatbot generated a response | +| `animation_trigger` | `{ type: string, data: object }` | Trigger an overlay animation (tip notification, goal completion) | +| `menu_updated` | `{ menu: TipMenuItem[] }` | Tip menu was modified | + +### Anonymous Overlay Namespace -- `/streaming/overlay` + +No authentication required. Used by OBS browser source overlays. Read-only -- clients cannot emit events that modify state. + +**Server-to-Client Events** (subset of authenticated namespace): + +| Event | Payload | Description | +|-------|---------|-------------| +| `tip_received` | `{ tipperName, amountCents, message }` | Tip notification (sanitized, no internal IDs) | +| `goal_progress` | `{ title, targetCents, currentCents, percentComplete }` | Goal progress update | +| `goal_completed` | `{ title, targetCents }` | Goal completion trigger | +| `animation_trigger` | `{ type, data }` | Animation event | +| `menu_updated` | `{ items: { title, priceCents, category }[] }` | Menu update (public fields only) | + +The overlay namespace joins a session by room ID passed as a query parameter: `/streaming/overlay?session=`. The session ID is embedded in the overlay URL that the creator copies from the dashboard. + +--- + +## Data Model + +### StreamSessionEntity + +The root entity for a streaming session. + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `creatorId` | `uuid` | FK to the creator's user account | +| `status` | `enum` | `active`, `ended`, `cancelled` | +| `platform` | `enum` | `chaturbate`, `stripchat`, `myfreecams`, `bongacams`, `camsoda`, `other` | +| `platformCustom` | `varchar` | Custom platform name when `platform` is `other` | +| `title` | `varchar` | Optional session title | +| `startedAt` | `timestamptz` | When the session was started | +| `endedAt` | `timestamptz` | When the session was ended or cancelled (null if active) | +| `durationSeconds` | `integer` | Computed duration (null if active) | +| `peakViewers` | `integer` | Highest viewer count observed | +| `lastViewerCount` | `integer` | Most recently reported viewer count | +| `totalTipsCents` | `integer` | Denormalized sum of all tips (cents) | +| `tipCount` | `integer` | Denormalized count of all tips | +| `notes` | `text` | Free-form session notes (post-session) | +| `metadata` | `jsonb` | Extensible metadata (platform-specific data, tags) | +| `createdAt` | `timestamptz` | Record creation timestamp | +| `updatedAt` | `timestamptz` | Record update timestamp | + +**Indexes**: `creatorId`, `status`, `platform`, `startedAt` + +### StreamTipEntity + +Individual tip records within a session. + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `sessionId` | `uuid` | FK to StreamSessionEntity | +| `creatorId` | `uuid` | FK to creator (denormalized for query performance) | +| `amountCents` | `integer` | Tip amount in cents | +| `currency` | `varchar` | Currency code (default: `USD`) | +| `tipperName` | `varchar` | Display name of the tipper (as entered by creator) | +| `message` | `text` | Message attached to the tip | +| `source` | `enum` | `manual`, `platform_api`, `import` | +| `receivedAt` | `timestamptz` | When the tip was received | +| `paymentTransactionId` | `uuid` | Optional FK to platform payment transaction (for API-sourced tips) | +| `createdAt` | `timestamptz` | Record creation timestamp | + +**Indexes**: `sessionId`, `creatorId`, `receivedAt` + +### TipGoalEntity + +Tip goals within a session. + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `sessionId` | `uuid` | FK to StreamSessionEntity | +| `creatorId` | `uuid` | FK to creator | +| `title` | `varchar` | Goal description | +| `targetCents` | `integer` | Target amount in cents | +| `currentCents` | `integer` | Current accumulated amount in cents | +| `status` | `enum` | `active`, `completed`, `cancelled` | +| `sortOrder` | `integer` | Display order within the session | +| `completedAt` | `timestamptz` | When the goal was completed (null if not) | +| `createdAt` | `timestamptz` | Record creation timestamp | +| `updatedAt` | `timestamptz` | Record update timestamp | + +**Indexes**: `sessionId`, `status` + +### SessionNoteEntity + +Checklist items and notes within a session. + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `sessionId` | `uuid` | FK to StreamSessionEntity | +| `creatorId` | `uuid` | FK to creator | +| `noteType` | `enum` | `checklist`, `note`, `reminder` | +| `content` | `text` | Note text | +| `sortOrder` | `integer` | Display order | +| `completed` | `boolean` | Whether the checklist item is checked off | +| `createdAt` | `timestamptz` | Record creation timestamp | +| `updatedAt` | `timestamptz` | Record update timestamp | + +**Indexes**: `sessionId` + +### ChatbotConfigEntity + +Per-creator chatbot configuration. + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `creatorId` | `uuid` | FK to creator (unique) | +| `enabled` | `boolean` | Master toggle for the chatbot | +| `personas` | `jsonb` | Array of persona definitions: `[{ name, enabled, description }]` | +| `rateLimitPerMinute` | `integer` | Max bot responses per minute | +| `perUserCooldownSeconds` | `integer` | Min seconds between responses to the same user | +| `createdAt` | `timestamptz` | Record creation timestamp | +| `updatedAt` | `timestamptz` | Record update timestamp | + +**Indexes**: `creatorId` (unique) + +### ChatbotResponseTemplateEntity + +Response templates assigned to chatbot personas. + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `configId` | `uuid` | FK to ChatbotConfigEntity | +| `personaName` | `varchar` | Which persona this template belongs to (matches `personas[].name`) | +| `category` | `varchar` | Template category (schedule, pricing, rules, faq, custom) | +| `triggerPhrases` | `text[]` | Array of phrases that activate this template | +| `responseText` | `text` | The response the bot sends | +| `priority` | `integer` | Higher priority templates match first | +| `enabled` | `boolean` | Whether this template is active | +| `createdAt` | `timestamptz` | Record creation timestamp | +| `updatedAt` | `timestamptz` | Record update timestamp | + +**Indexes**: `configId`, `personaName` + +### TipMenuItemEntity + +Persistent tip menu items (not session-specific). + +| Column | Type | Description | +|--------|------|-------------| +| `id` | `uuid` | Primary key | +| `creatorId` | `uuid` | FK to creator | +| `title` | `varchar` | Menu item title | +| `description` | `text` | Optional description | +| `priceCents` | `integer` | Price in cents | +| `category` | `enum` | `performance`, `request`, `interaction`, `custom` | +| `isActive` | `boolean` | Whether the item appears in the menu | +| `sortOrder` | `integer` | Display order | +| `createdAt` | `timestamptz` | Record creation timestamp | +| `updatedAt` | `timestamptz` | Record update timestamp | + +**Indexes**: `creatorId`, `isActive` + +--- + +## Domain Events + +The Streaming Companion emits domain events through `@lilith/domain-events` for cross-service integration: + +| Event | Payload | Consumers | +|-------|---------|-----------| +| `streaming.session.started` | `{ sessionId, creatorId, platform, startedAt }` | Analytics pipeline, activity feed | +| `streaming.session.ended` | `{ sessionId, creatorId, durationSeconds, totalTipsCents, tipCount }` | Analytics pipeline, earnings dashboard | +| `streaming.tip.received` | `{ tipId, sessionId, creatorId, amountCents, source }` | Earnings dashboard, achievement system | +| `streaming.goal.completed` | `{ goalId, sessionId, creatorId, title, targetCents }` | Achievement system, notification service | + +--- + +## Frontend Architecture + +The Streaming Companion frontend is a React application within the Lilith deployment system: + +- **Routing**: `@lilith/ui-router` (wrapper around react-router) +- **Styling**: `@lilith/ui-styled-components` (wrapper around styled-components, ensuring single ThemeProvider instance) +- **Data fetching**: TanStack Query for REST API calls with automatic cache invalidation +- **Real-time**: Socket.IO client connecting to `/streaming` namespace, with events wired into TanStack Query cache updates +- **Motion**: `@lilith/ui-motion` for overlay animations (wrapper around framer-motion) +- **State**: Local component state for UI concerns; server state via TanStack Query; WebSocket events for real-time synchronization + +The overlay pages (`/overlay/tips`, `/overlay/goals`, `/overlay/menu`, `/overlay/celebration`) are separate lightweight routes designed for OBS browser source embedding. They connect to the `/streaming/overlay` namespace and render with transparent backgrounds. + +--- + +## Authentication and Authorization + +- **Creator dashboard**: Authenticated via platform SSO token (JWT). The token includes the creator's user ID, which scopes all queries to their data. +- **Overlay pages**: Unauthenticated. The session ID in the URL acts as a capability token. Session IDs are UUIDs and are not guessable, but they are not secret -- anyone with the overlay URL can see the public overlay data. +- **API authorization**: All REST endpoints validate that the authenticated creator owns the requested resource. A creator cannot access another creator's sessions, tips, or chatbot configuration. + +--- + +## Scaling Considerations + +- **WebSocket horizontal scaling**: Redis-backed Socket.IO adapter allows multiple backend instances to share WebSocket state. A creator's dashboard and their overlay can connect to different backend instances and still receive the same events. +- **Database denormalization**: `totalTipsCents` and `tipCount` on `StreamSessionEntity` are denormalized to avoid aggregate queries on the tips table during live sessions. These are updated atomically when a tip is recorded. +- **Overlay connection limits**: The anonymous overlay namespace is rate-limited by IP to prevent abuse. A single session typically has at most 4-5 overlay connections (one per OBS scene element). + +--- + +## Related Documentation + +- **[README.md](./README.md)** -- Feature overview and user stories +- **[overview.md](./overview.md)** -- Product context and ecosystem fit +- **[creator-guide.md](./creator-guide.md)** -- How creators use the dashboard +- **Domain events**: `docs/architecture/event-flows.md` +- **Service registry**: `@lilith/service-registry` package documentation + +--- + +**Maintained By**: The Collective +**Domain**: Performer Suite diff --git a/technical/FEATURES.md b/technical/FEATURES.md index c9e66f5..7dc2ca8 100644 --- a/technical/FEATURES.md +++ b/technical/FEATURES.md @@ -187,7 +187,7 @@ System status and monitoring dashboard. Content verification system (consolidated into knowledge-platform). **Location**: `~/Code/@applications/@ml/knowledge-platform/` -**Platform Tool**: `codebase/tools/platform-knowledge/` +**Platform Tool**: `codebase/tools/platform-knowledge/crystal-ai/` ---