Develop a microservice to manage the lifecycle of voice/video calls via real-time events, following call center business rules (e.g., medical interpreter-patient workflows). Focus on code quality, scalability, and integration.
| Area | Stack |
|---|---|
| Frontend | Next.js + TypeScript, Socket.io Client |
| Backend | Express.js/NestJS + TypeScript, PostgreSQL/MongoDB, Socket.io |
| Testing | Jest (unit), Cypress/Supertest (integration) |
Initiated → Routed → Answered → [Hold/Transfer] → Ended
| Event | Trigger | Sample Data | Business Rules |
|---|---|---|---|
call_initiated |
Call starts (voice/video). | { "call_id": "123", "type": "video", "queue_id": "medical_spanish" } |
- Validate queue_id exists.- Start SLA timer (30s max wait). |
call_routed |
Call assigned to agent/interpreter. | { "agent_id": "agent_55", "routing_time": 15 } |
- Re-route if agent doesn’t answer in 15s (call_retransfer). |
call_answered |
Agent accepts the call. | { "wait_time": 25 } |
- Alert supervisor if wait_time > 30s.- Update agent metrics. |
call_hold |
Call placed on hold. | { "hold_duration": 45 } |
- Max hold time: 60s. - Notify supervisor if exceeded. |
call_ended |
Call finishes (success/failure). | { "end_reason": "completed", "duration": 300 } |
- Flag calls with duration < 10s for review.- Send post-call survey. |
-
REST API:
POST /api/events: Ingests events (authenticated via API Key header).GET /api/calls?status=active: Lists calls with filters (status, queue).- Validation: Use Zod/Class-Validator for event schemas.
-
WebSockets:
- Broadcast real-time updates via Socket.io.
-
Database:
// Call Entity interface Call { id: string; status: "waiting" | "active" | "on_hold" | "ended"; queue_id: string; start_time: Date; end_time?: Date; } // CallEvent Entity (Audit Log) interface CallEvent { id: string; call_id: string; type: string; timestamp: Date; metadata?: Record<string, any>; }
- Dashboard:
- Real-time table of active/ended calls.
- Event history view per call.
- Filters by status/queue.
- Fork this repository.
- Develop your solution in the fork.
- Submit a Pull Request with:
- Functional code in
frontend/andbackend/. - Clear setup instructions in the README.
- Unit + integration tests.
- Functional code in
- Event Flow: Correct state transitions (e.g.,
call_initiated→call_ended). - Code Quality: Clean architecture (DTOs, services), error handling.
- Real-Time: Efficient WebSocket usage (no duplicates).
- Testing: 5+ unit tests, 1 integration test.
- Retry failed events (3 attempts).
- Docker setup (
docker-compose.yml).
❗ Note:
Focus on extensibility (e.g., how this module would integrate with CRM/queuing systems). Good luck! 🚀