| Metadata | Value |
|---|---|
| Status | Active |
| Version | 1.1.0 |
| Last Updated | 2026-09-10 |
| Author | Sangeetha Grantha Team |
| Document Type | Design reference |
[!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
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”.
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
For a content-heavy application like Sangeetha Grantha, reads outnumber writes by 1000:1. We must aggressively cache at the edge.
/v1/krithis/{id}) should send Cache-Control: public, max-age=3600, s-maxage=3600. The CDN serves these directly, shielding the backend.krithi:{id}, ref:ragas, search:{hash}.A single PostgreSQL instance is a single point of failure and a vertically limited bottleneck.
PgBouncer or application-level routing to send all GET requests (excluding Admin) to replicas.krithis table exceeds 100M rows, shard by composer_id or musical_form. (Likely not needed for <10M users if caching is effective).PostgreSQL ILIKE or even tsvector trigram searches are computationally expensive and degrade O(N) with data size.
The application servers (Ktor) must be stateless and horizontally scalable.
AI tasks (Transliteration, Scraping) are slow and resource-intensive. They must not block API threads.
job_id (202 Accepted).job_id or uses WebSockets/SSE for updates.You cannot scale what you cannot see.
cache_hit_ratio, db_pool_utilization, p99_latency, error_rate.GET endpoints.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.