You are provided with a REST API for a task management system built with NestJS, TypeScript, Prisma, and Redis. The application is functional but has several performance issues that need to be addressed. Additionally, you need to implement a new feature.
- Ensure you have Docker and Docker Compose installed
- Clone the repository
- Run
docker-compose up -dto start PostgreSQL and Redis - Run
npm install - Run
npm run prisma:migrateto set up the database - Run
npm run seedto populate sample data - Run
npm run start:devto start the application
The API will be available at http://localhost:3000
GET /tasks- List all tasks with filtersGET /tasks/:id- Get a single taskPOST /tasks- Create a new taskPUT /tasks/:id- Update a taskDELETE /tasks/:id- Delete a taskGET /projects- List all projectsGET /users- List all users
Users have reported that the API becomes noticeably slow as the amount of data grows. The application works correctly with small datasets but exhibits performance degradation with larger volumes of data.
- API Response Times: The
/tasksendpoint response time increases significantly with the number of tasks in the system. Some users report response times over 5 seconds with just a few hundred tasks. - Database Load: The database server shows unusually high activity during normal operations, particularly when fetching task lists.
- Task Assignment Delays: Creating or updating tasks with assignees takes longer than expected, sometimes causing timeouts in client applications.
- Search Performance: Filtering tasks by various criteria (status, dates, assignee, etc.) becomes progressively slower as the dataset grows.
Investigate the codebase to identify and fix performance bottlenecks. The application should be able to handle thousands of tasks efficiently. Consider:
- Database query efficiency
- Application architecture patterns
- Asynchronous vs synchronous operations
- Database optimization techniques
Document all performance issues you find and the solutions you implement in your SOLUTION.md file.
Implement a comprehensive activity logging system that tracks all changes made to tasks.
-
Track all changes to tasks including:
- Field updates (title, description, status, priority, due date, assignee)
- Task creation and deletion
- Tag additions/removals
-
API Endpoints to implement:
GET /tasks/:id/activities- Get all activities for a specific task- Should return who made the change, when, and what changed
- Support pagination
GET /activities- Get all activities across all tasks- Support filtering by user, date range, and action type
- Support pagination
-
Activity Log Format: Each activity should include:
- User who made the change
- Timestamp
- Action type (created, updated, deleted)
- Changed fields with old and new values
- Task ID and title
{
"data": [
{
"id": "uuid",
"taskId": "task-uuid",
"taskTitle": "Implement authentication",
"userId": "user-uuid",
"userName": "John Doe",
"action": "updated",
"changes": {
"status": {
"old": "in_progress",
"new": "completed"
},
"assigneeId": {
"old": "user-uuid-1",
"new": "user-uuid-2"
}
},
"createdAt": "2024-01-15T10:30:00Z"
}
],
"meta": {
"total": 150,
"page": 1,
"perPage": 20
}
}- Clean, readable, and maintainable code
- Proper error handling
- Following NestJS best practices
- TypeScript usage
- Efficiency of database queries
- Proper use of indexes
- Caching strategy where appropriate
- Scalability considerations
- All requirements implemented
- Edge cases handled
- API documentation
- Unit tests for new features
- Integration tests for API endpoints
- Fix all performance issues identified in Part 1
- Implement the new feature as specified in Part 2
- Include a
SOLUTION.mdfile explaining:- Your approach to fixing each performance issue
- Your implementation strategy for the activity log
- Any trade-offs or assumptions made
- Potential future improvements
- Ensure all tests pass and the application runs correctly
This assignment should take approximately 3-4 hours for a senior engineer. If you find yourself spending significantly more time, please document where the complexity arose.
- Focus on backend performance and code quality
- You may install additional npm packages if needed
- Feel free to refactor existing code structure if it improves the solution
- Redis is available for caching if you choose to use it
- The email service is mocked - just ensure it's called asynchronously