Call Recording & Transcription Service
A robust, production-ready API service built with NestJS that enables users to record phone calls and automatically transcribe them using asynchronous background processing.
- Overview
- Features
- Tech Stack
- Architecture Diagram
- Architecture Decisions
- Getting Started
- API Endpoints
- Environment Variables
- Docker Setup
- Development
- Project Structure
- TODO / Future Improvements
- License
This platform allows users to:
- Register and authenticate using JWT-based authentication with refresh token support
- Create and manage phone call records with metadata (title, duration, participants)
- Automatically trigger transcription when a call is created (asynchronous background processing)
- Track transcription status with real-time updates (pending β processing β completed / failed)
- Retrieve transcription results with error handling and retry mechanisms
The project simulates AI transcription with:
- Random processing delays (2-10 seconds)
- 5% random failure rate for testing retry logic
- Mock transcription text generation
- Exponential backoff retry strategy (3 attempts max)
- β User registration with unique nickname validation
- β JWT-based authentication (access + refresh tokens)
- β Secure password hashing with bcrypt
- β Token refresh endpoint
- β Protected routes with AuthGuard
- β Redis-based refresh token storage
- β Create new call records
- β List calls with pagination, sorting, and filtering
- β Search calls by title or participants
- β Get call details by ID
- β Update call information
- β Delete calls (cascades to transcriptions)
- β User ownership validation
- β Automatic transcription initiation on call creation
- β Asynchronous background processing with BullMQ
- β
Status tracking:
pendingβprocessingβcompleted/failed - β Retry mechanism with exponential backoff (3 attempts)
- β Error logging and handling
- β Mock AI transcription simulation
- β Queue job persistence and monitoring
- β
Swagger/OpenAPI documentation (
/api) - β Interactive API testing interface
- β Complete request/response schemas
- β Error response documentation
- β Postman / Thunder collection (share link)
Postman/Thunder collection (import):
- Shared collection: https://universal-rocket-51567.postman.co/workspace/My-Workspace~c74fd85a-7e6f-40d2-8173-85982193135a/collection/27067617-a5ed3ddc-341a-49d1-983b-c49d6dc463b7?action=share&creator=27067617&active-environment=27067617-35c32dbb-9495-48d9-83e1-24c6265cd6cd
- To import into Postman: File β Import β Paste Link β Import
- To import into Thunder Client (VS Code): Export collection from Postman (or use the Postman link) and import JSON via Thunder Client import.
- NestJS (v11.0.1) - Progressive Node.js framework with excellent TypeScript support, built-in dependency injection, and modular architecture
- TypeScript (v5.7.3) - Type safety and improved developer experience
- MongoDB (via Mongoose v8.19.1) - NoSQL database chosen for:
- Flexible schema for evolving call/transcription data structures
- Excellent performance for document-based operations
- Native support for complex queries and aggregations
- Easy horizontal scaling
- Redis (via ioredis v5.8.1) - Used for:
- Refresh token storage (session management)
- Future: Rate limiting and caching
- BullMQ (v5.61.0) - Robust job queue for:
- Asynchronous transcription processing
- Retry mechanisms and job persistence
- Background task monitoring
- JWT (@nestjs/jwt v11.0.0) - Stateless authentication
- bcryptjs (v3.0.2) - Secure password hashing
- Swagger (@nestjs/swagger v11.2.1) - Auto-generated API documentation
- class-validator (v0.14.2) - DTO validation
- class-transformer (v0.5.1) - Object transformation
- Docker & Docker Compose - Containerization for consistent environments
- ESLint & Prettier - Code quality and formatting
- Modular Architecture: Clear separation of concerns with modules, services, and controllers
- TypeScript-first: Full type safety and excellent IDE support
- Dependency Injection: Easy testing and maintainable code
- Ecosystem: Built-in support for Swagger, validation, and microservices
- Production-ready: Battle-tested in enterprise applications
- Document Model: Natural fit for call records and transcription data
- Flexibility: Easy to add new fields without migrations
- Performance: Fast reads/writes for our use case
- Scalability: Horizontal scaling support for future growth
- Reliability: Job persistence and fault tolerance
- Retry Logic: Built-in exponential backoff
- Monitoring: Redis-based queue dashboard support
- Performance: Efficient job processing with worker pools
- Speed: In-memory storage for fast token validation
- TTL Support: Auto-expiring refresh tokens
- Queue Backend: Required for BullMQ
- Future-proof: Ready for caching and rate limiting
- Repository Pattern: Data access abstraction
- Service Layer Pattern: Business logic separation
- DTO Pattern: Request/response validation and transformation
- Guard Pattern: Authentication and authorization
- Interceptor Pattern: Request/response transformation
- Exception Filter Pattern: Centralized error handling
- Node.js (v18 or higher)
- Docker & Docker Compose
- Git
-
Clone the repository
git clone https://github.com/alakkaya/call-assistant-platform.git cd call-assistant-platform -
Create environment file
cp .env.example .env
-
Update
.envwith your configuration (optional - defaults work for Docker)PORT=3000 MONGODB_URI=mongodb://mongo:27017/call-assistant-platform # JWT Secrets (CHANGE IN PRODUCTION!) JWT_SECRET_ACCESS=your_secure_access_secret_key_here JWT_SECRET_REFRESH=your_secure_refresh_secret_key_here JWT_EXPIRATION_ACCESS=1h JWT_EXPIRATION_REFRESH=7d # Redis REDIS_HOST=redis REDIS_PORT=6379
-
Start with Docker Compose
cd docker docker-compose up --build -d -
Verify services are running
docker ps
You should see:
call-assistant-platform-app(API server)call-assistant-platform-mongo(MongoDB)call-assistant-platform-redis(Redis)
-
Access the application
- API: http://localhost:3000
- Swagger UI: http://localhost:3000/api
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/auth/register |
Register new user | β |
POST |
/auth/login |
Login and get tokens | β |
POST |
/auth/logout |
Logout (invalidate refresh token) | β |
POST |
/auth/refresh-token |
Refresh access token | β |
GET |
/auth/me |
Get current user info | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/calls |
Create new call (auto-starts transcription) | β |
GET |
/calls |
List calls (with pagination, sorting, search) | β |
GET |
/calls/:id |
Get call details | β |
PUT |
/calls/:id |
Update call information | β |
DELETE |
/calls/:id |
Delete call (cascades to transcription) | β |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/calls/:callId/transcription |
Get transcription status/result | β |
Detailed example requests were intentionally removed from the public README to keep documentation concise.
Use the Swagger UI at /api for interactive testing and concrete request examples.
This project already includes a .env.example in the repository root. Copy it to .env and update values as needed. The .env.example covers the required variables (PORT, MONGODB_URI, JWT secrets and Redis settings).
Security note: Keep secrets out of version control and rotate JWT secrets in production.
# Navigate to docker directory
cd docker
# Build and start all services
docker-compose up --build -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose downThe docker-compose.yml defines 3 services:
-
call-assistant-platform-app (Node.js API)
- Port:
3000:3000 - Depends on: MongoDB, Redis
- Volume mounts source code for hot-reload
- Port:
-
call-assistant-platform-mongo (MongoDB)
- Port:
27016:27017(external:internal) - Persistent data storage
- Port:
-
call-assistant-platform-redis (Redis)
- Port:
6378:6379(external:internal) - Used for queues and token storage
- Port:
docker restart call-assistant-platform-app docker logs -f call-assistant-platform-app docker exec -it call-assistant-platform-app sh docker exec -it call-assistant-platform-mongo mongosh docker exec -it call-assistant-platform-redis redis-cli
Local development steps are intentionally shortened in this README. Use the following quick commands for development and testing; more detailed guides live in the developer docs or project wiki.
# Install dependencies
npm install
# Start in development mode (requires MongoDB and Redis to be available)
npm run start:dev
# Build & run production
npm run build
npm run start:prod
# Lint & format
npm run lint
npm run format
# Testing
npm run test
npm run test:e2e
npm run test:covcall-assistant-platform/
βββ docker/
β βββ Dockerfile # Node.js app container
β βββ docker-compose.yml # Multi-container setup
βββ src/
β βββ core/ # Shared utilities and core functionality
β β βββ cache/ # Redis service and cache utilities
β β βββ decorator/ # Custom decorators (ApiResponse, ReqUser, etc.)
β β βββ enum/ # Shared enums (TranscriptionStatus)
β β βββ error/ # Custom exceptions and error codes
β β βββ filter/ # Global exception filter
β β βββ guard/ # Authentication guard
β β βββ helper/ # Utility functions (mongo, mask)
β β βββ interceptor/ # Response transformation interceptor
β β βββ interface/ # TypeScript interfaces
β βββ modules/
β β βββ auth/ # Authentication module
β β β βββ controller/ # Login, register, refresh endpoints
β β β βββ dto/ # Request/response DTOs
β β β βββ service/ # JWT logic, token management
β β βββ calls/ # Call management module
β β β βββ controller/ # CRUD endpoints
β β β βββ dto/ # Call DTOs
β β β βββ model/ # Mongoose schema
β β β βββ repository/ # Data access layer
β β β βββ service/ # Business logic
β β βββ transcription/ # Transcription module
β β β βββ controller/ # Get transcription endpoint
β β β βββ dto/ # Transcription DTOs
β β β βββ model/ # Mongoose schema
β β β βββ processor/ # BullMQ job processor
β β β βββ repository/ # Data access layer
β β β βββ service/ # Queue management, status updates
β β βββ user/ # User module
β β β βββ dto/ # User DTOs
β β β βββ model/ # Mongoose schema
β β β βββ repository/ # Data access layer
β β β βββ service/ # User operations
β β βββ utils/
β β βββ bullmq/ # BullMQ configuration module
β βββ app.module.ts # Root application module
β βββ main.ts # Application entry point
βββ test/ # Test files
βββ .env.example # Environment variables template
βββ .gitignore
βββ nest-cli.json
βββ package.json
βββ README.md
βββ tsconfig.json
βββ tsconfig.build.json
- Unit Tests: Add comprehensive test coverage for services and repositories
- E2E Tests: Implement end-to-end API tests with supertest
- CI/CD Pipeline: Set up GitHub Actions for automated testing and deployment
- Logging: Implement structured logging (Winston/Pino) with log levels
- Monitoring: Add health check endpoints and metrics (Prometheus)
- Event-Driven Architecture: Replace circular dependencies with event emitters (NestJS EventEmitter)
- Decouple CallService β TranscriptionService dependency
- Use domain events:
call.created,call.deleted, etc.
- Database Indexing: Add indexes on frequently queried fields (userId, callId, status)
- Caching Strategy: Cache frequently accessed data (user profiles, call summaries)
- Rate Limiting: Implement API rate limiting to prevent abuse
- Input Sanitization: Add MongoDB injection protection
- CORS Configuration: Properly configure CORS for production
- Helmet.js: Add security headers
- API Versioning: Implement versioned API endpoints (
/v1/calls) - Secrets Management: Integrate with AWS Secrets Manager or Vault
- Audit Logs: Track sensitive operations (login, data modifications)
- Real AI Integration: Replace mock transcription with actual AI service (OpenAI Whisper, Google Speech-to-Text)
- Audio File Upload: Support actual call recording file uploads (S3/MinIO storage)
- Webhooks: Notify external systems when transcription completes
- Search Improvements: Full-text search on transcription content (Elasticsearch)
- Analytics Dashboard: User statistics, transcription success rates, average processing time
- Call Tags/Categories: Add tagging system for better organization
- Shared Calls: Allow users to share call transcriptions with others
- SonarQube Integration: Static code analysis
- Dependency Updates: Automated dependency update checks (Dependabot)
- Performance Profiling: Add APM (Application Performance Monitoring)
- Error Tracking: Integrate Sentry or similar error tracking service
This project is MIT licensed.
Contributions, issues, and feature requests are welcome!
For questions or support, please open an issue on GitHub.
Built with β€οΈ using NestJS
