File size: 10,049 Bytes
6abfd9d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
# Verified Guest Network API

This module implements the two-sided marketplace for MicProtocol, transforming it from a SaaS tool into a network with network effects.

## Architecture Overview

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    VERIFIED GUEST NETWORK                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”‚
β”‚  β”‚   Reputation β”‚    β”‚   Discovery  β”‚    β”‚     Graph    β”‚       β”‚
β”‚  β”‚    Engine    │◄──►│   (Search)   │◄──►│   Service    β”‚       β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚         β”‚                   β”‚                   β”‚               β”‚
β”‚         β–Ό                   β–Ό                   β–Ό               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              Guest Public Profile DB                    β”‚    β”‚
β”‚  β”‚  β€’ Profile data  β€’ Booking history  β€’ Reliability       β”‚    β”‚
β”‚  β”‚  β€’ Expertise tags β€’ Availability    β€’ Reviews           β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                              β”‚                                  β”‚
β”‚                              β–Ό                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              Network Queue Processor                    β”‚    β”‚
β”‚  β”‚  β€’ Booking notifications  β€’ Reputation recalc           β”‚    β”‚
β”‚  β”‚  β€’ Graph ingestion        β€’ Weekly digests              β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                              β”‚                                  β”‚
β”‚                              β–Ό                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚
β”‚  β”‚              SMS/WhatsApp Service                       β”‚    β”‚
β”‚  β”‚  β€’ WhatsApp Business API  β€’ Africa's Talking            β”‚    β”‚
β”‚  β”‚  β€’ Multi-language         β€’ USSD fallback               β”‚    β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚
β”‚                                                                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
```

## Features

### 1. Guest Public Profiles

Guests can create public, discoverable profiles with:

- Vanity URLs (`MicProtocol.io/in/john-nduati`)
- Expertise tags and professional bio
- Country/city for regional discovery
- Availability windows
- Social proof and track record

### 2. Reputation Engine

Behavioral scoring system (not subjective endorsements):

| Dimension | Weight | Metrics |
|-----------|--------|---------|
| Responsiveness | 30% | Response time, response rate |
| Reliability | 40% | Asset delivery, show-up rate |
| Quality | 30% | Host ratings, engagement |

**African Market Adaptations:**

- Regional thresholds for response times (Nigeria: 72h, Kenya: 48h)
- Mobile data considerations for asset uploads
- WhatsApp response time counts

### 3. Discovery Search

Meilisearch-powered search with:

- Typo-tolerant full-text search
- Faceted filtering (country, expertise, language)
- Geo-search for regional discovery
- Reputation-boosted ranking

### 4. Social Graph

"Who knows who" network for recommendations:

- "Podcasters who booked X also booked Y"
- Trust paths between hosts and guests
- Community detection (tech hubs, countries)

### 5. Booking Requests

Frictionless booking flow:

1. Host discovers guest via search
2. One-click booking request
3. Guest receives WhatsApp + Email notification
4. Guest accepts β†’ Auto-creates pipeline entry
5. Host receives confirmation

### 6. Mobile-First Notifications

African market-optimized:

- WhatsApp Business API (primary)
- SMS fallback (Twilio, Africa's Talking)
- Multi-language (EN, Swahili, Yoruba, Zulu)
- USSD codes for feature phones (`*384*88#`)

## API Endpoints

### Public Endpoints

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/network/guests/search` | Search guest profiles |
| GET | `/network/guests/trending` | Get trending guests by region |
| GET | `/network/guests/:vanityUrl` | Get public profile |
| POST | `/network/views` | Track profile view |

### Protected Endpoints (Require Auth)

**Profiles:**

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/network/profiles` | Create public profile |
| PUT | `/network/profiles/me` | Update my profile |
| GET | `/network/profiles/me` | Get my profile with analytics |
| GET | `/network/profiles/:id/views` | Get view statistics |

**Bookmarks:**

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/network/bookmarks` | Bookmark a guest |
| PUT | `/network/bookmarks/:id` | Update bookmark |
| DELETE | `/network/bookmarks/:id` | Remove bookmark |
| GET | `/network/bookmarks` | List bookmarks |

**Booking Requests:**

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/network/booking-requests` | Send booking request |
| PUT | `/network/booking-requests/:id/respond` | Accept/decline |
| GET | `/network/booking-requests/received` | List received |
| GET | `/network/booking-requests/sent` | List sent |

**Reputation:**

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/network/profiles/:id/reputation` | Get reputation insights |
| POST | `/network/profiles/:id/reputation/recalculate` | Recalculate score |

**Recommendations:**

| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/network/profiles/:id/recommendations` | Get recommendations |
| GET | `/network/profiles/:id/network-stats` | Get network stats |

**Reviews:**

| Method | Endpoint | Description |
|--------|----------|-------------|
| POST | `/network/reviews` | Submit host review |

## tRPC Router

All endpoints are also available via tRPC at `network.` namespace:

```typescript
// Example tRPC calls
const profile = await trpc.network.getMyProfile.query();
const results = await trpc.network.search.query({ 
  query: "fintech kenya",
  minReliabilityScore: 70 
});
const request = await trpc.network.requestBooking.mutate({
  toProfileId: "...",
  fromPodcastId: "...",
  message: "Would love to have you on..."
});
```

## Queue Jobs

The network module processes background jobs via BullMQ:

| Job | Description |
|-----|-------------|
| `booking-request.notify` | Send WhatsApp/SMS + Email to guest |
| `booking-request.response-notify` | Notify host of response |
| `booking-request.accepted` | Create pipeline entry (Guest + Episode) |
| `reputation.recalculate` | Recalculate reputation score |
| `graph.ingest-profile` | Add profile to social graph |
| `digest.weekly` | Send weekly analytics to guests |

## Configuration

Required environment variables:

```env
# Meilisearch (Search)
MEILISEARCH_HOST=http://localhost:7700
MEILISEARCH_API_KEY=...

# Twilio (SMS/WhatsApp)
TWILIO_ENABLED=true
TWILIO_ACCOUNT_SID=AC...
TWILIO_AUTH_TOKEN=...
TWILIO_PHONE_NUMBER=+1234567890
WHATSAPP_ENABLED=true

# Africa's Talking (African SMS)
AFRICAS_TALKING_ENABLED=true
AFRICAS_TALKING_USERNAME=...
AFRICAS_TALKING_API_KEY=...
AFRICAS_TALKING_FROM=...

# App URL for action links
APP_URL=https://MicProtocol.io
```

## Database Schema

See `prisma/schema.prisma` for full schema. Key models:

- `GuestPublicProfile` - Public guest identity
- `ExpertiseTag` - Skills/categories
- `AvailabilityWindow` - When guest can record
- `BookingHistory` - Cross-show track record
- `ReliabilityMetric` - Behavioral scoring data
- `NetworkBookmark` - Host saves
- `ProfileView` - Analytics
- `NetworkBookingRequest` - Booking flow
- `HostReview` - Post-episode feedback

## Regional Considerations

### East Africa (Kenya, Tanzania, Uganda)

- 48-hour expected response time
- 24-hour grace for asset uploads
- Swahili language support
- M-Pesa integration ready

### West Africa (Nigeria, Ghana)

- 72-hour expected response time (infrastructure)
- Mobile-first design
- Yoruba language support
- MTN Mobile Money ready

### Southern Africa (South Africa)

- 36-hour expected response time
- Better infrastructure = stricter thresholds
- Zulu language support

## Future Enhancements

- [ ] Mobile Money payments (M-Pesa, MTN)
- [ ] Video profiles for guests
- [ ] AI-powered matching ("Guests like you enjoyed...")
- [ ] Podcast co-host discovery
- [ ] Event/networking meetup integration