This project challenges you to build a sophisticated NestJS backend system that can ingest, process, and broadcast real-time user activity data. You will design a system capable of handling a stream of events, aggregating them into meaningful analytics, and serving these insights instantly to a hypothetical dashboard via WebSockets. This requires a strong understanding of event-driven architecture, real-time communication, and robust data management.
YouYou will develop a multi-service NestJS application that simulates a simplified analytics pipeline. The core components include:
Event Ingestion Endpoint: Create a POST /events API endpoint that accepts raw user activity events (e.g., eventType: 'pageView', userId: 'uuid', timestamp: 'ISOString', payload: { url: '/home' }).
class-validator).NestJS-Queue with BullMQ for a more robust solution, if you wish to tackle an extra challenge).Analytics Processor: Develop a service that consumes events from the queue.
pageView, login, itemAddedToCart) per minute/hour.Real-time Dashboard Gateway: Implement a NestJS WebSocket Gateway (@nestjs/platform-socket.io or similar).
/dashboard should receive real-time updates as new analytics data becomes available.Database Management: Utilize PostgreSQL for storing both raw (if desired for auditing) and aggregated analytics data.
Error Handling: Implement comprehensive error handling across all services, including input validation, database operations, and queue interactions.
Testing: Include basic unit tests for core event processing and aggregation logic, and e2e tests for the event ingestion API endpoint and WebSocket connectivity/authentication.
Scalability & Performance Considerations: Briefly discuss in your README.md any considerations you made for scaling the event ingestion or processing, even if not fully implemented.
package.json: With all dependencies listed.README.md: A detailed README.md file that includes:
POST /events structure).curl commands or a Postman collection to demonstrate submitting events and connecting to the WebSocket endpoint (with an example JWT).Workspace
47 viewsThe AI reads your code and gives you a score and feedback — no login required.
Upload your code for free AI feedback
Choose a ZIP or select up to 10 code files directly. No account is required.
We read supported text-based source files only; binaries, node_modules and .git content are ignored.