|
| 1 | +# Core Functionality |
| 2 | + |
| 3 | +## vCon Data Model |
| 4 | + |
| 5 | +### Structure |
| 6 | +The vCon (Voice Conversation) is the fundamental data structure that represents a conversation: |
| 7 | + |
| 8 | +```json |
| 9 | +{ |
| 10 | + "uuid": "unique-identifier", |
| 11 | + "vcon": "0.0.1", |
| 12 | + "created_at": "ISO-8601-timestamp", |
| 13 | + "redacted": {}, |
| 14 | + "group": [], |
| 15 | + "parties": [ |
| 16 | + { |
| 17 | + "tel": "+1234567890", |
| 18 | + "mailto": "user@example.com", |
| 19 | + "name": "John Doe", |
| 20 | + "role": "agent" |
| 21 | + } |
| 22 | + ], |
| 23 | + "dialog": [ |
| 24 | + { |
| 25 | + "type": "recording", |
| 26 | + "start": "timestamp", |
| 27 | + "duration": 300, |
| 28 | + "parties": [0], |
| 29 | + "url": "https://example.com/recording.mp3" |
| 30 | + } |
| 31 | + ], |
| 32 | + "attachments": [ |
| 33 | + { |
| 34 | + "type": "transcript", |
| 35 | + "body": "conversation text...", |
| 36 | + "encoding": "none" |
| 37 | + } |
| 38 | + ], |
| 39 | + "analysis": [ |
| 40 | + { |
| 41 | + "type": "summary", |
| 42 | + "dialog": [0], |
| 43 | + "vendor": "openai", |
| 44 | + "body": "analysis results..." |
| 45 | + } |
| 46 | + ] |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +### Key Components |
| 51 | + |
| 52 | +1. **Parties**: Participants in the conversation |
| 53 | + - Phone numbers, emails, names |
| 54 | + - Roles (agent, customer, etc.) |
| 55 | + - Indexed for efficient searching |
| 56 | + |
| 57 | +2. **Dialog**: The actual conversation content |
| 58 | + - Recordings with URLs |
| 59 | + - Text messages |
| 60 | + - Timestamps and duration |
| 61 | + |
| 62 | +3. **Attachments**: Additional data |
| 63 | + - Transcripts |
| 64 | + - Metadata |
| 65 | + - Tags |
| 66 | + - Custom data |
| 67 | + |
| 68 | +4. **Analysis**: AI-generated insights |
| 69 | + - Summaries |
| 70 | + - Sentiment analysis |
| 71 | + - Custom analysis types |
| 72 | + - Vendor attribution |
| 73 | + |
| 74 | +## Processing Pipeline |
| 75 | + |
| 76 | +### Chain Architecture |
| 77 | +- **Ingress Lists**: Entry points for vCons |
| 78 | +- **Processing Links**: Sequential processing steps |
| 79 | +- **Storage Operations**: Persistence to backends |
| 80 | +- **Egress Lists**: Output queues for processed vCons |
| 81 | + |
| 82 | +### Chain Configuration Example |
| 83 | +```yaml |
| 84 | +chains: |
| 85 | + main_chain: |
| 86 | + links: |
| 87 | + - deepgram_link # Transcription |
| 88 | + - analyze # AI analysis |
| 89 | + - tag # Tagging |
| 90 | + - webhook # External notification |
| 91 | + storages: |
| 92 | + - postgres # Primary storage |
| 93 | + - s3 # Backup storage |
| 94 | + ingress_lists: |
| 95 | + - main_ingress |
| 96 | + egress_lists: |
| 97 | + - processed_queue |
| 98 | + enabled: 1 |
| 99 | +``` |
| 100 | +
|
| 101 | +### Processing Flow |
| 102 | +1. vCon enters via ingress list |
| 103 | +2. Each link processes sequentially |
| 104 | +3. Storage operations execute |
| 105 | +4. vCon moves to egress lists |
| 106 | +5. Dead letter queue for failures |
| 107 | +
|
| 108 | +## API Functionality |
| 109 | +
|
| 110 | +### Core Endpoints |
| 111 | +
|
| 112 | +#### vCon Management |
| 113 | +- `POST /api/vcon` - Create new vCon |
| 114 | +- `GET /api/vcon/{uuid}` - Retrieve vCon |
| 115 | +- `PUT /api/vcon/{uuid}` - Update vCon |
| 116 | +- `DELETE /api/vcon/{uuid}` - Delete vCon |
| 117 | +- `GET /api/vcons` - Batch retrieval |
| 118 | + |
| 119 | +#### Search Operations |
| 120 | +- `GET /api/vcons/search?tel={phone}` - Search by phone |
| 121 | +- `GET /api/vcons/search?mailto={email}` - Search by email |
| 122 | +- `GET /api/vcons/search?name={name}` - Search by name |
| 123 | +- Multiple parameters for AND operations |
| 124 | + |
| 125 | +#### Chain Management |
| 126 | +- `POST /api/chain/{chain_name}/ingress` - Add to chain |
| 127 | +- `POST /api/chain/{chain_name}/egress` - Process chain |
| 128 | + |
| 129 | +#### Configuration |
| 130 | +- `GET /api/config` - Get configuration |
| 131 | +- `POST /api/config` - Update configuration |
| 132 | + |
| 133 | +#### Queue Management |
| 134 | +- `GET /api/dlq` - View dead letter queue |
| 135 | +- `POST /api/dlq/reprocess` - Reprocess failed items |
| 136 | + |
| 137 | +### Authentication |
| 138 | +- Header-based: `x-conserver-api-token` |
| 139 | +- File-based token management |
| 140 | +- Environment variable support |
| 141 | + |
| 142 | +## Redis Integration |
| 143 | + |
| 144 | +### Caching Strategy |
| 145 | +1. **Primary Storage**: vCons stored as JSON |
| 146 | +2. **Sorted Sets**: Timestamp-based ordering |
| 147 | +3. **Index Sets**: Search acceleration |
| 148 | +4. **Expiration**: Configurable TTL |
| 149 | + |
| 150 | +### Key Patterns |
| 151 | +- `vcon:{uuid}` - vCon data |
| 152 | +- `tel:{number}` - Phone index |
| 153 | +- `mailto:{email}` - Email index |
| 154 | +- `name:{name}` - Name index |
| 155 | +- `vcons` - Sorted set by timestamp |
| 156 | + |
| 157 | +### Performance Features |
| 158 | +- Automatic cache population from storage |
| 159 | +- Configurable expiration (VCON_REDIS_EXPIRY) |
| 160 | +- Index expiration (VCON_INDEX_EXPIRY) |
| 161 | +- Batch operations support |
| 162 | + |
| 163 | +## Error Handling |
| 164 | + |
| 165 | +### Dead Letter Queue (DLQ) |
| 166 | +- Automatic failure capture |
| 167 | +- Per-ingress-list DLQs |
| 168 | +- Reprocessing capability |
| 169 | +- Error tracking |
| 170 | + |
| 171 | +### Retry Mechanisms |
| 172 | +- Configurable retry counts |
| 173 | +- Exponential backoff |
| 174 | +- Link-specific retry logic |
| 175 | +- Metrics tracking |
| 176 | + |
| 177 | +## Metrics & Monitoring |
| 178 | + |
| 179 | +### Built-in Metrics |
| 180 | +- Processing time per link |
| 181 | +- Success/failure rates |
| 182 | +- Storage operation timing |
| 183 | +- API request metrics |
| 184 | + |
| 185 | +### Integration Points |
| 186 | +- Datadog support |
| 187 | +- Custom metrics via StatsD |
| 188 | +- Structured logging |
| 189 | +- Error tracking services |
0 commit comments