How sunbird-all/all-content-service works
Project type and purpose
• This is a monolithic backend REST‐API service built with NestJS (a Node.js/TypeScript framework).
• It exposes “collections” and “content” endpoints, uses schema definitions (likely Mongoose) to persist data, supports clustering for CPU scaling, and contains static language content assets.
• The presence of Dockerfile, docker-compose.yml, deploy.sh, and multiple GitHub Actions workflows indicates containerized deployment and CI/CD pipelines.
File structure
• Top-level:
• Dockerfile, docker-compose.yml, deploy.sh → container build & local orchestration
• .github/workflows/*.yml → CI/CD definitions
• src/ → application code
• Language content/ → static data assets (Excel, text files)
• src/ structure follows Nest conventions:
• main.ts → application entry point
• app-cluster.service.ts → spawns Node.js worker processes
• controllers/ → HTTP handlers (collection.controller.ts, content.controller.ts)
• services/ → business logic (collection.service.ts, content.service.ts)
• schemas/ → data models (collection.schema.ts, content.schema.ts)
• config/ → configuration modules (commonConfig, language files by locale)
README
• Confirms NestJS starter repo, outlines install/run/test commands.
a. Main components
• External clients (e.g., UI, mobile apps, API consumers)
• HTTP Load Balancer / Cluster Manager (Node’s cluster service)
• NestJS Application Process(es)
• Module: AppModule
• Submodules: CollectionModule, ContentModule, ConfigModule
• Controllers → Services → Schemas
• Database (e.g., MongoDB)
• Static File Store (Language content directory)
• CI/CD Pipeline & Container Registry
• Deployment Environment (e.g., Docker Swarm, Kubernetes, or plain Docker Compose)
b. Relationships and interactions
• Clients → HTTP Load Balancer → NestJS Worker Process
• Worker Process:
– Controllers receive requests
– Controllers call Services
– Services access Database via Schemas
– Services read static files from Language content on disk
• Cluster Manager evenly distributes requests across worker processes
• CI/CD pipelines build Docker image → push to registry → deploy via docker-compose or cloud
c. Architectural patterns / design principles
• Layered architecture (Controller → Service → Data Model)
• Dependency Injection (Nest’s providers and modules)
• High availability & horizontal scaling via Node.js clustering
• Configuration managed via environment‐aware modules (commonConfig + locale files)
• Containerization and infrastructure as code (Dockerfile & docker-compose.yml)
d. Key technologies / frameworks / libraries
• NestJS / Node.js / TypeScript
• Mongoose (implied by *.schema.ts)
• Docker / Docker Compose
• GitHub Actions (CI/CD)
• Optional: Nginx or cloud load balancer in front of containers