Architecture
Request Lifecycle
End-to-end request path from browser to rendered page.
Request Lifecycle
Full request path
Server vs client responsibilities
Server (RSC pages)
- Resolve tenant from headers
- Fetch content from MongoDB
- Encode KV values for ad targeting
- Inject tracking scripts in layout
- Pass serialized props to client components
Client (interactive components)
- Render theme overlay (questionnaire, WhatsApp, guide)
- Manage ad timing via
useAdThemeTiming - Fire conversion pixels via hooks
- Handle rewarded ad lifecycle
- KV2 fallback popup on no-fill
Category page lifecycle
API routes
Client-side theme components fetch dynamic data via API:
| Route | Used by |
|---|---|
GET /api/questionnaire?slug= | QuestionnaireModal |
GET /api/whatsapp?categorySlug= | WhatsAppTheme |
GET /api/category/[slug] | Client-side category refresh |
GET /api/article/[slug] | Client-side article refresh |
All API routes require the x-tenant-id header set by proxy.js.