How thepushkarp/etymology-explorer works
EtymEx is a multilingual etymology explorer. A visitor searches for a word, then the word page serves a cached entry or presents a live trace; the etymology endpoint coordinates research and structured LLM synthesis for uncached words. The graph also covers pronunciation, suggestions, random words, and supporting usage and corpus features. Edges are limited to calls visible in excerpts, SOURCE INDEX references, or README documentation; some unsampled implementation details and runtime wiring are therefore omitted.
Main entry points: research.ts Source research · page.tsx Word page · route.ts Etymology endpoint · cache.ts Result and audio cache
Components 25
Search and results
- Word search
components/SearchBox.tsx - Word page
app/word/[...segments]/page.tsx - Entry display
components/EntryView.tsx - Live trace
components/WordTraceExperience.tsx
API services
- Etymology endpoint
app/api/etymology/route.ts - Admin usage stats
app/api/admin/stats/route.ts
Research and synthesis
- Source research
lib/research.ts - Source clients
lib/multilingualSources.ts - Etymology parsing
lib/etymologyParser.ts - LLM synthesis
lib/llm.ts - OpenRouter adapter
lib/openrouterResponses.ts
Caching and safeguards
- Result and audio cache
lib/cache.ts - Redis service
lib/redis.ts - Spend controls
lib/costGuard.ts
Discovery and audio
- Suggestions endpoint
app/api/suggestions/route.ts - Suggestion ranking
lib/wordSuggestions.ts - Random word endpoint
app/api/random-word/route.ts - Pronunciation endpoint
app/api/pronunciation/route.ts - Speech generation
lib/elevenlabs.ts - N-gram endpoint
app/api/ngram/route.ts - N-gram lookup
lib/ngrams.ts
Other components
- Visitor
- Dictionary and reference sources
- OpenRouter
- ElevenLabs
Connections 27
- Visitor → Word search: searches
- Visitor → Word page: opens word
- Word search → Suggestions endpoint: requests suggestions
components/SearchBox.tsx - Word page → Result and audio cache: reads cached entry
app/word/[...segments]/page.tsx - Word page → Entry display: renders cached result
app/word/[...segments]/page.tsx - Word page → Live trace: renders live trace
app/word/[...segments]/page.tsx - Live trace → Etymology endpoint: streams lookup
- Etymology endpoint → Result and audio cache: checks and stores
app/api/etymology/route.ts - Etymology endpoint → Source research: runs research
app/api/etymology/route.ts - Etymology endpoint → LLM synthesis: requests synthesis
app/api/etymology/route.ts - Source research → Source clients: fetches evidence
lib/research.ts - Source research → Etymology parsing: parses source text
lib/research.ts - Source research → OpenRouter adapter: extracts roots
lib/research.ts - LLM synthesis → Source research: uses research context
lib/llm.ts - LLM synthesis → OpenRouter adapter: requests completion
lib/llm.ts - OpenRouter adapter → OpenRouter: calls API
lib/openrouterResponses.ts - Source clients → Dictionary and reference sources: fetches reference data
- Result and audio cache → Redis service: reads and writes
lib/cache.ts - Spend controls → Redis service: tracks spend
lib/costGuard.ts - Admin usage stats → Spend controls: reads budget
app/api/admin/stats/route.ts - Admin usage stats → Redis service: reads counters
app/api/admin/stats/route.ts - Suggestions endpoint → Suggestion ranking: gets suggestions
app/api/suggestions/route.ts - Random word endpoint → Dictionary and reference sources: selects word list
- Pronunciation endpoint → Result and audio cache: checks and stores audio
app/api/pronunciation/route.ts - Pronunciation endpoint → Speech generation: requests audio
app/api/pronunciation/route.ts - Speech generation → ElevenLabs: generates speech
- N-gram endpoint → N-gram lookup: requests frequency
app/api/ngram/route.ts