How jayaprabhapalani/search-engine works
This is a Hacker News story search product: users search and page through stories, get title autocomplete, inspect search analytics, and can request reindexing. The backend fetches and preprocesses stories, builds in-memory search indexes, serves hybrid search, and records analytics; reindexing can also run as a background Celery task. The graph preserves these distinct stages and the frontend flow. Source excerpts and the index support the shown calls; crawler internals and deployment wiring were not inspected.
Main entry points: main.py FastAPI routes · App.jsx App coordinator · tasks.py Reindex task · api.js API client
Components 22
Web client
- App coordinator
frontend/src/App.jsx - Home page
frontend/src/pages/HomePage.jsx - Results page
frontend/src/pages/ResultsPage.jsx - Search bar
frontend/src/components/search/SearchBar.jsx - Result card
frontend/src/components/search/ResultCard.jsx - Search state
frontend/src/hooks/useSearch.js - Autocomplete state
frontend/src/hooks/useAutocomplete.js - Analytics views
frontend/src/components/analytics/AnalyticsPage.jsx - API client
frontend/src/services/api.js
Search API
- FastAPI routes
hn_search/main.py - Hybrid search
hn_search/search.py - Title trie
hn_search/trie.py
Indexing
- Text preprocessing
hn_search/preprocessor.py - Story crawler
hn_search/crawler.py - Reindex task
hn_search/tasks.py - Celery app
hn_search/celery_app.py
State and analytics
- Result cache
hn_search/cache.py - Rate limiting
hn_search/ratelimiter.py - Story and analytics models
hn_search/models.py - SQL database access
hn_search/database.py
Other components
- User
- Redis
Connections 30
- User → App coordinator: uses
frontend/src/App.jsx - App coordinator → Home page: renders
frontend/src/App.jsx - App coordinator → Results page: renders
frontend/src/App.jsx - App coordinator → Analytics views: renders
frontend/src/App.jsx - App coordinator → Search state: uses
frontend/src/App.jsx - App coordinator → Autocomplete state: uses
frontend/src/App.jsx - App coordinator → API client: requests reindex
frontend/src/App.jsx - Home page → Search bar: renders
frontend/src/pages/HomePage.jsx - Results page → Search bar: renders
frontend/src/pages/ResultsPage.jsx - Results page → Result card: renders
frontend/src/pages/ResultsPage.jsx - Search state → API client: requests search
frontend/src/hooks/useSearch.js - Autocomplete state → API client: requests suggestions
frontend/src/hooks/useAutocomplete.js - Analytics views → API client: loads analytics
frontend/src/components/analytics/AnalyticsPage.jsx - API client → FastAPI routes: calls search routes
frontend/src/services/api.js - FastAPI routes → Rate limiting: checks requests
hn_search/main.py - FastAPI routes → SQL database access: loads and persists
hn_search/main.py - FastAPI routes → Story and analytics models: queries models
hn_search/main.py - FastAPI routes → Result cache: reads and writes
hn_search/main.py - FastAPI routes → Hybrid search: runs hybrid search
hn_search/main.py - Hybrid search → Text preprocessing: uses text processing
hn_search/search.py - FastAPI routes → Story crawler: fetches stories
hn_search/main.py - FastAPI routes → Text preprocessing: processes stories
hn_search/main.py - FastAPI routes → Title trie: builds suggestions
hn_search/main.py - FastAPI routes → Reindex task: dispatches reindex
hn_search/main.py - Reindex task → Celery app: registers task
hn_search/tasks.py - Reindex task → Story crawler: fetches stories
hn_search/tasks.py - Reindex task → Text preprocessing: processes stories
hn_search/tasks.py - Reindex task → SQL database access: saves stories
hn_search/tasks.py - Result cache → Redis: uses cache store
- Rate limiting → Redis: checks limits