Sangeetha-Grantha

Metadata Value
Status Active
Version 1.1.0
Last Updated 2026-09-10
Author Sangeetha Grantha Team
Document Type Design reference

Global Scale Architecture Proposal: Sangeetha Grantha


[!NOTE] Design/reference material: this page may include proposals or earlier implementation assumptions. Use current feature map for implemented behavior and current operating steps.


Status: Proposal | Version: 1.0 | Date: 2026-01-14 Target Scale: 5M+ Monthly Active Users (MAU), Distributed Globally

1. Executive Summary

Sangeetha Grantha’s current architecture (Monolithic Ktor + Single PostgreSQL) is robust for its current boutique scale but will face severe bottlenecks under global load (“The Million User Problem”).

To support millions of users distributed worldwide, the system must transition from a Vertical Scaling model to a Horizontal, Edge-First strategy. This proposal outlines the architectural evolution required to guarantee <100ms latency for 95% of requests globally while maintaining strong consistency for the editorial “System of Record”.

Key Recommendations at a Glance

  1. Edge-First Delivery: Offload 90% of read traffic to CDNs and Edge Caches.
  2. Read-Write Splitting: Decouple high-volume public reads from transactional admin writes.
  3. Dedicated Search Service: Move search workloads from PostgreSQL to Elasticsearch/OpenSearch.
  4. Asynchronous AI Pipeline: Decouple heavy AI/Scraping tasks using durable message queues.

2. High-Level Global Architecture

The proposed architecture adopts a Hub-and-Spoke model. The “Hub” (Primary Region) handles writes, consistency, and admin operations. The “Spokes” (Edge/Regions) handle public read traffic close to the user.

graph TD
    User_Global((User Global)) --> CDN[Global CDN / Edge Network]
    
    subgraph "Edge / Spoke Layer"
        CDN --> |Hit| Cached_Content[Static Assets & JSON Responses]
        CDN --> |Miss| Edge_API[Edge API Gateway]
    end

    subgraph "Core Region (Hub)"
        Edge_API --> LB[Load Balancer]
        LB --> Ktor_Cluster[Ktor App Cluster]
        
        Ktor_Cluster --> |Reads| Redis_Cluster[Redis Cache Cluster]
        Ktor_Cluster --> |Search| Search_Engine[Elasticsearch / OpenSearch]
        
        Ktor_Cluster --> |Writes/Critical Reads| PG_Primary[(PostgreSQL Primary)]
        PG_Primary -.-> |Replication| PG_Read[(PostgreSQL Read Replicas)]
        Ktor_Cluster --> |Reads| PG_Read
        
        Ktor_Cluster --> |Async Tasks| Msg_Queue[Message Queue - SQS/Kafka]
        Msg_Queue --> Worker_Cluster[Async Workers - AI/Scraping]
    end

3. Detailed Architectural Pillars

3.1 Global Traffic & Caching (The 10M User Shield)

For a content-heavy application like Sangeetha Grantha, reads outnumber writes by 1000:1. We must aggressively cache at the edge.

3.2 Database Strategy (Scaling the “Source of Truth”)

A single PostgreSQL instance is a single point of failure and a vertically limited bottleneck.

3.3 Search & Discovery Engine

PostgreSQL ILIKE or even tsvector trigram searches are computationally expensive and degrade O(N) with data size.

3.4 Compute & Autoscale

The application servers (Ktor) must be stateless and horizontally scalable.

3.5 Asynchronous Processing (AI & Bulk Ops)

AI tasks (Transliteration, Scraping) are slow and resource-intensive. They must not block API threads.


4. Operational Excellence for Scale

4.1 Observability

You cannot scale what you cannot see.

4.2 Security at Scale


5. Transition Roadmap

  1. Immediate (The Low Hanging Fruit):
    • Enable CDN caching for all public GET endpoints.
    • Introduce Redis for reference data caching.
    • Implement PgBouncer for connection stability.
  2. Near-Term (Architecture Split):
    • Spin up Read Replicas and configure Ktor to route reads there.
    • Migrate Search to Elasticsearch.
  3. Long-Term (Global Scale):
    • Move to Kubernetes/Cloud Run for auto-scaling.
    • Implement Async Workers for AI tasks.

6. Conclusion

Sangeetha Grantha is effectively a “Read-Heavy Knowledge Base”. By acknowledging this and moving aggressively to an Edge-Cached, Read-Replica backed architecture, the system can scale to millions of users with relatively modest infrastructure costs. The complexity lies not in data volume, but in maintaining low-latency access globally.


Section index · Documentation home · Feature status