dg-node
Node.js backend for searching and reading Pāli Canon texts using SuttaCentral Bilara and DhammaGift translations.
This project powers the search index, reader endpoints, static assets, and compatibility layer for the legacy Dhamma.Gift stack. The production server runs on Fastify; the older Express-based implementation is kept only for legacy support.
Architecture and development rules: CLAUDE.md
Features
- Search across the Pāli Canon with SQLite/FTS5
- Reader routes for clean URLs such as
/dn22 and /dn22:12.1
- Segment-aware links and scroll targets
- Support for offline mirror data and environment-based path resolution
- Legacy compatibility with older PHP/Apache frontends
Quick start
build-search-db should be rerun whenever source texts or translations change on disk. The server reads data directly from disk and rebuilds the search index as needed.
Data paths such as SC_BILARA, DG_OFFLINE, and offline mirrors are resolved automatically based on the runtime environment (Termux, Windows development, local server, etc.).
unused/dg-light.js and unused/dblight.js (npm run start:express) are legacy Express + grep services and are not used in production. See CLAUDE.md for details.
Deployment checks
Manual browser checks:
/nodejs/res/?q=kacchapa&scope=dhamma — search, DataTables, export
/dn22 — full-text reader
- Pāli / Russian toggle (three modes: Pāli + translation → Pāli only → translation only) — should actually hide/show content correctly
/?q=dn22#12.1 (legacy format) — should continue to work alongside /dn22:12.1
Deployment notes for Apache/PHP
If the public Dhamma.Gift site is currently hosted by Apache/PHP while Node runs as a separate backend proxied only to /search, note the following:
- search requests may route to the Node backend
- static files and reader routes may still be served by Apache/PHP
- root-domain routing can differ from the local development environment
dg-fastify is the modern backend, while legacy PHP pages remain in parallel for compatibility
Project structure
License
See the repository license and project-specific notes in the root of the project.