Architecture

The Engineering Behind VaniSagar: How to Host & Search 745,000+ Verses in 133 Languages with Zero Hosting Costs

A deep dive into the serverless architecture of VaniSagar. Learn how we store, render, and index 745,000+ verses of sacred scriptures in 133 languages.

Sachin Sharma
Sachin SharmaCreator
May 23, 2026
4 min read
The Engineering Behind VaniSagar: How to Host & Search 745,000+ Verses in 133 Languages with Zero Hosting Costs
Featured Resource
Quick Overview

A deep dive into the serverless architecture of VaniSagar. Learn how we store, render, and index 745,000+ verses of sacred scriptures in 133 languages.

The Engineering Behind VaniSagar: How to Host & Search 745,000+ Verses in 133 Languages with Zero Hosting Costs

When I set out to build VaniSagar, my goal was simple yet incredibly ambitious: to build a free, open-source, ad-free digital library that makes humanity’s greatest wisdom—sacred scriptures like the Bhagavad Gita, Valmiki Ramayana, Quran, Bible, Dhammapada, Guru Granth Sahib, and Stoic philosophy—accessible to anyone on Earth in 133 languages.

Today, VaniSagar hosts over 745,000 verses. If you build this the traditional way using a relational database (like PostgreSQL or MongoDB) and a standard dynamic server, a search query or page view across this volume in multiple languages would cost hundreds of dollars a month in database read operations and server compute.

Instead, VaniSagar runs with zero hosting costs, loads in under 100ms globally, and remains 100% ad-free. Here is the technical breakdown of the architecture that makes this possible.


🛠️ 1. The Core Challenge: Data Scale and Multilingualism

Managing 745,000 verses isn't just about storage space; it’s about text complexity and organization. We needed to support:

  • Multilingual alignments: Storing original Sanskrit, Arabic, or Greek alongside English translations, transliterations, and word-by-word breakdowns.
  • 133 languages: Seamless localization without bloating client bundle sizes.
  • Highly complex Unicode: Devanagari (Sanskrit), Gurmukhi, Arabic, and Hebrew require precise text-shaping and font rendering to ensure readability on modern screens.

To solve this, I designed a hierarchical content schema that decoupled the raw text from the presentation layer, storing texts in optimized JSON flat-files rather than a live-query database.


🗄️ 2. Going 100% Serverless: Flat-File JSON Database

Instead of querying a SQL database on every page load, VaniSagar uses a Static Flat-File Architecture.

Every book, chapter, and verse is stored as a compressed static JSON asset. For example, a request to read the Bhagavad Gita Chapter 2, Verse 47 triggers a static fetch for: /data/gita/chapter-2/verse-47.json

Why this works:

  1. 2.
    Immutability: Sacred texts do not change. The Bhagavad Gita written thousands of years ago will be the same tomorrow. Querying a dynamic database for static, immutable text is a massive waste of compute.
  2. 4.
    CDN Caching: By utilizing Next.js static routing and Cloudflare/Vercel edge networks, these JSON files are cached at the edge. The server is completely bypassed, and the user gets the content from the nearest CDN node.
  3. 6.
    Zero Hosting Overhead: Serving static JSON files from edge memory costs virtually zero, while scaling infinitely under traffic spikes.

🔍 3. Lightning-Fast Client-Side Search Indexing

How do you search through 745,000 verses without an expensive Elasticsearch or Algolia cluster?

For VaniSagar, I engineered a hybrid, decentralized search model:

  • Categorized Triphone Indexes: Rather than index all 745,000 verses in a single, massive file, we generated triphone-based indexes grouped by text.
  • Client-Side Web Workers: When a user types a query, a background Web Worker downloads a highly-compressed, lightweight index (less than 150KB) and performs a local prefix-matching and scoring algorithm using a modified TF-IDF logic in JavaScript.
  • Fuzzy Searching for Transliterations: Many users search for Sanskrit terms using Latin characters (e.g., "nishkama karma"). The search algorithm dynamically normalizes spelling variations using a custom phonological distance matching engine, returning instant results in under 5ms without server-side latency.

🎨 4. Design & Typography for Devotional Reading

Devotional and philosophical reading requires intense focus. If the page is cluttered with popups, banners, or ads, the user experience is ruined.

  • Aesthetics: We adopted a premium glassmorphic UI, with HSL-tailored warm amber and dark ivory themes designed specifically to reduce eye strain during long reading sessions.
  • Typography: We used Google Fonts to load curated web fonts specifically optimized for classical scripts:
    • Sanskrit (Devanagari): Yatra One and Rozha One for headers, and Siddhanta for word-by-word reading.
    • Arabic: Amiri, designed to capture the beauty of classical Arabic typesetting.
  • Word-by-Word Breakdown: For Sanskrit texts, each word in a verse is an interactive element. Clicking it opens a dynamic popover displaying the grammatical root (vibhakti), definition, and philosophical context.

🚀 5. Performance Metrics

VaniSagar’s static compilation architecture has yielded incredible results:

  • Largest Contentful Paint (LCP): < 0.6 seconds.
  • Cumulative Layout Shift (CLS): 0.0 (fully locked layout boundaries).
  • Page Weight: The initial load is under 120KB (excluding fonts).
  • Hosting Cost: $0.00 (leveraging static asset caching at scale).

🏁 6. Conclusion: Preserving Wisdom for the Future

VaniSagar shows that with modern web architecture (Next.js, Wasm, Static Flat-Files, Edge CDNs), you don't need a massive budget to build a globally scalable digital ecosystem. By using engineering principles to reduce operational costs to zero, we've created a platform that can preserve humanity's spiritual and philosophical legacy forever, without ever needing commercialization.

Explore the library yourself at VaniSagar.in and let me know your thoughts!

Sachin Sharma

Sachin Sharma

Software Developer

Building digital experiences at the intersection of design and code. Sharing weekly insights on engineering, productivity, and the future of tech.