A full-stack knowledge graph application that extracts, structures, and explores physics and propulsion concepts from @TMBSPACESHIPS tweets — a retired 38-year USAF PhD engineer who posts about plasma physics, electromagnetic propulsion, fusion energy, and advanced aerospace technology.
- Extracts topics, entities, and themes from 583 tweets using Claude AI
- Builds a graph database (SurrealDB) with bidirectional links between tweets, topics, entities, themes, and images
- Explores the graph through a web UI with interactive D3.js force-directed visualization
- Chats with Claude, which navigates the graph using tool-use to answer questions about the content
Tweets (583) ──discusses──> Topics (852) ──belongs_to──> Themes (15)
│ │ ↕ ↕
│──cites──> Entities (236) ─┘ relates_to theme_overlap
│ ↕
│──has_image──> Images (308)
│ associated_with
└───────────── entity_relates_to
Node types: tweet, topic, theme, entity, image Edge types: discusses, cites, has_image, belongs_to, relates_to, associated_with, entity_relates_to, theme_overlap
| Layer | Technology |
|---|---|
| Database | SurrealDB 3.0 (graph DB with SurrealKV backend) |
| Backend | Python / FastAPI |
| AI | Anthropic Claude (extraction + chat) |
| Frontend | Vanilla JS + D3.js force-directed graph |
| API Client | httpx (X/Twitter API v2) |
- Python 3.14+
- uv (Python package manager)
- SurrealDB 3.0+
- Anthropic API key
- X/Twitter API credentials (for fetching tweets)
git clone https://github.com/postrv/tmbspaceships.git
cd tmbspaceships
cp .env.example .env
# Edit .env with your API keys
uv syncsurreal start --user root --pass root surrealkv:./surreal_data --bind 0.0.0.0:8000uv run python x_client.pyThis uses Claude to extract topics, entities, and themes from the tweets, then derives bidirectional graph edges:
uv run python ingest.pyuv run uvicorn main:app --port 8001Open http://localhost:8001/ui for the web interface.
| Endpoint | Description |
|---|---|
GET /stats |
Graph statistics |
GET /search/topics?q= |
Full-text topic search |
GET /search/tweets?q= |
Full-text tweet search |
GET /search/entities?q= |
Entity search |
GET /themes |
List all themes |
GET /themes/{id} |
Theme detail with topics + connected themes |
GET /topics |
Top topics by mention count |
GET /topics/{id} |
Topic detail with relations, entities |
GET /topics/{id}/tweets |
Tweets discussing a topic |
GET /topics/{id}/entities |
Entities associated with a topic |
GET /entities/{id} |
Entity detail with topics, related entities |
GET /entities/{id}/topics |
Topics associated with an entity |
GET /entities/{id}/related |
Co-cited entities |
GET /graph/viz |
Graph data for D3 visualization |
GET /graph/neighborhood/{table}/{id} |
All connections from any node |
GET /bridge?a=&b= |
Tweets connecting two topics |
POST /chat |
Claude chat with graph navigation |
GET /clusters |
Topic clustering analysis |
The /chat endpoint runs an agentic loop where Claude uses 20 graph query tools to explore the knowledge graph before synthesizing an answer. Ask it things like:
- "How does antigravity connect to plasma physics?"
- "What papers does TMBSPACESHIPS reference most?"
- "Explain the E-M-K axis framework"
See .env.example for all configuration options. Key variables:
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
Yes | For AI extraction and chat |
X_BEARER_TOKEN |
For fetching | X/Twitter API bearer token |
SURREALDB_URL |
No | Default: ws://localhost:8000/rpc |
SURREALDB_USER |
No | Default: root |
SURREALDB_PASS |
No | Default: root |
MIT