Skip to main content

System Architecture Overview

Bitcoinology is a multi-layer system that ingests podcast transcripts, extracts beliefs using AI, and serves them through a semantic search interface with multi-agent orchestration.

High-Level System Diagram

Layer Breakdown

User Layer

A single-pane terminal-style Next.js 14 app deployed on Vercel. The entire UI operates within a fixed viewport — no scrolling. Navigation happens through screen transitions managed by a Zustand store.

API Layer

Next.js Route Handlers serve as the API surface. All routes require Supabase JWT authentication except public routes (/login, /walkthrough, /share).

RoutePurposeMax Duration
/api/queryMain search — routes to direct search or playbook60s
/api/playbookDeep 4-lens analysis (beliefs, timeline, sentiment, context)120s
/api/graph/dataSpeaker aggregations + similarity for graph viz1h cache
/api/threadsThread CRUD (max 5 active per user)
/api/feedCommunity cards, cursor-based pagination

AI / Orchestration

Uses the Vercel AI SDK v6 with OpenAI provider. Two models (aliased as haiku/sonnet in code):

  • GPT-4o-mini (haiku) — Direct search (fast, cheap)
  • GPT-4o (sonnet) — Playbook synthesis (deeper reasoning)

AI tools (searchBeliefs, semanticSearch, getEpisode) allow the model to call into Supabase RPC functions and Qdrant vector search.

Data Layer

  • Supabase — Postgres 17 with pgvector extension, Row-Level Security, Google OAuth
  • Qdrant Cloud — 1536-dim vector similarity search for beliefs
  • HuggingFace — Dataset backup (ryan-beliefengines/podcast-transcripts)

Offline Pipelines

Two separate repos handle data ingestion:

  • be-flow-dtd — GPU pipeline: download → Whisper transcription → Pyannote diarization → ECAPA-TDNN speaker ID
  • be-podcast-etl — 10-stage belief extraction pipeline (see Pipeline docs)

Key Architectural Decisions

DecisionChoiceRationale
Single-pane UINo scrolling, fixed viewport"The Matrix, but orange" — app-like feel
Zustand over React ContextGlobal state with URL syncSimple, performant, supports URL-driven state
pgvector + QdrantDual vector storespgvector for co-located queries, Qdrant for dedicated vector ops
AI SDK toolsFunction calling over RAG chainDirect tool use gives model control over retrieval strategy
SSE streamingServer-sent events for playbookProgressive results, real-time agent visibility
RLS everywhereRow-level security on all tablesZero-trust data access, auth baked into queries

Non-Negotiable Invariants

These are enforced across the entire system:

  1. Every claim cites a source — No factual claim leaves the system without an evidence record
  2. Bounded retries — Max 2 attempts per stage, never infinite loops
  3. Safe fallback — If evidence is insufficient, return "insufficient evidence" instead of guessing
  4. Tenant isolation — Every retrieval includes user identity context
  5. Observable — Every orchestrated step emits trace data