Public search and discovery API for finding and exploring media content (podcasts, documentaries, etc.) in the Thmanyah platform.
The Discovery API serves as the public-facing search interface that allows users to:
This service is part of the Thmanyah microservices architecture:
Example :Discovery API โ Elasticsearch โ Search Results
The Discovery API is read-only and serves content that has been indexed by the Sync Worker from the CMS API.
GET /search
- Search programs with filtersGET /search/suggest
- Get search suggestionsGET /search/facets
- Get available search facetsGET /programs/:id
- Get program details by IDGET /programs
- List programs with paginationGET /health
- Service health check# Install dependencies (from root)
pnpm install
# Start in development mode
pnpm --filter discovery-api dev
# Or from the app directory
cd apps/discovery-api
pnpm dev
Required environment variables (see root .env.example
):
# Elasticsearch
ELASTICSEARCH_URL=http://localhost:9200
ELASTICSEARCH_USERNAME=elastic
ELASTICSEARCH_PASSWORD=changeme
ELASTICSEARCH_INDEX_NAME=programs
# API Configuration
DISCOVERY_API_PORT=3002
NODE_ENV=development
# Optional: CORS
CORS_ORIGINS=http://localhost:3000
Once running, access the Swagger documentation at:
# Unit tests
pnpm --filter discovery-api test
# E2E tests
pnpm --filter discovery-api test:e2e
# Test coverage
pnpm --filter discovery-api test:cov
# Watch mode
pnpm --filter discovery-api test:watch
# Development
pnpm dev # Start in development mode
pnpm start # Start in production mode
pnpm start:dev # Start with watch mode
pnpm start:debug # Start in debug mode
pnpm start:prod # Start in production mode
# Testing
pnpm test # Run unit tests
pnpm test:watch # Run tests in watch mode
pnpm test:cov # Run tests with coverage
pnpm test:debug # Run tests in debug mode
pnpm test:e2e # Run e2e tests
# Building
pnpm build # Build the application
pnpm build:watch # Build in watch mode
# Linting
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
apps/discovery-api/
โโโ src/
โ โโโ app.module.ts # Main application module
โ โโโ main.ts # Application entry point
โ โโโ common/ # Shared utilities
โ โ โโโ filters/ # Exception filters
โ โโโ health/ # Health check endpoints
โ โโโ search/ # Search functionality
โ โโโ search.controller.ts
โ โโโ search.service.ts
โ โโโ search.module.ts
โ โโโ dto/ # Data transfer objects
โ โโโ services/ # Business logic services
โ โโโ utils/ # Utility functions
โโโ test/ # E2E tests
โโโ package.json
GET /health
# Build image
docker build --build-arg TARGET_APP=discovery-api -t thmanyah/discovery-api .
# Run container
docker run -p 3002:3002 --env-file .env thmanyah/discovery-api
# Build for production
pnpm --filter discovery-api build
# Start production server
pnpm --filter discovery-api start:prod
The service manages an Elasticsearch index with the following mapping:
Example :{
"mappings": {
"properties": {
"id": { "type": "keyword" },
"title": {
"type": "text",
"analyzer": "standard",
"fields": { "keyword": { "type": "keyword" } }
},
"description": { "type": "text", "analyzer": "standard" },
"type": { "type": "keyword" },
"language": { "type": "keyword" },
"tags": { "type": "keyword" },
"createdAt": { "type": "date" },
"updatedAt": { "type": "date" }
}
},
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
}
}
This project is part of the Thmanyah backend system and is licensed under the MIT License.