How boredmayonnaise/smart-autocomplete works
SmartAutocomplete is a local C++ teaching editor for trie prefix lookup, Levenshtein distance, and KMP search. The user edits text or supplies algorithm inputs; the browser requests C++ results or traces, then displays and replays them. Dictionary replacement and usage-based ranking are another user-facing capability. The sampled code shows the server-to-API call and core algorithm implementations; endpoint-to-algorithm wiring is supported by the README, while several UI and API details are unsampled.
Main entry points: api.cpp HTTP API · app.js Editor UI · dictionary.cpp Trie and ranking · main.cpp Crow server
Components 16
Editor and visualization
- Editor UI
static/app.js - Editor page
static/index.html - Layout and styles
static/style.css - Trace replay and views
static/app.js
HTTP application
- Crow server
src/main.cpp - HTTP API
src/web/api.cpp - API contract
src/web/api.hpp
Core algorithms
- Trie prefix lookup
src/core/dictionary.cpp - Fuzzy suggestions
src/core/dictionary.cpp - Levenshtein trace
src/core/algorithms.cpp - KMP trace and matches
src/core/algorithms.cpp
Vocabulary and text
- Trie and ranking
src/core/dictionary.cpp - Bundled vocabulary
data/words.txt - Unicode text handling
src/core/text.cpp - Core types and limits
include/smartautocomplete/core.hpp
Other components
- User
Connections 22
- User → Editor UI: edits and selects
README.md - Editor page → Editor UI: loads script
- Editor page → Layout and styles: loads styles
- Editor UI → HTTP API: requests results and traces
static/app.js - HTTP API → Editor UI: returns JSON
README.md - Editor UI → Trace replay and views: replays traces
README.md - User → Trace replay and views: steps and switches views
README.md - Crow server → HTTP API: dispatches requests
src/main.cpp - Crow server → Bundled vocabulary: loads vocabulary
src/main.cpp - Crow server → Editor page: serves assets
src/main.cpp - HTTP API → API contract: implements interface
src/web/api.cpp - HTTP API → Trie prefix lookup: requests completions
README.md - HTTP API → Fuzzy suggestions: requests spelling candidates
README.md - HTTP API → Levenshtein trace: requests distance trace
README.md - HTTP API → KMP trace and matches: requests search trace
README.md - HTTP API → Trie and ranking: replaces and updates usage
README.md - Trie and ranking → Bundled vocabulary: builds vocabulary from
- Trie prefix lookup → Trie and ranking: reads trie and cache
src/core/dictionary.cpp - Fuzzy suggestions → Trie and ranking: searches trie words
src/core/dictionary.cpp - HTTP API → Unicode text handling: uses text conversion
- Levenshtein trace → Core types and limits: uses trace and result types
src/core/algorithms.cpp - KMP trace and matches → Core types and limits: uses search and trace types
src/core/algorithms.cpp