Instructions on how to build/run your application
- Clone the repository to your local machine
- Navigate to the project directory in the terminal
- Run npm install to install all dependencies
- Start the server by running node server.js (or npm start if you have a start script defined in your package.json)
- The application runs on localhost:3000 by default. You can change the port by modifying the value in the server.js file.
Testing For testing this implementation, I primarily used Postman, a popular API client. The steps I followed were:
- Unit Testing: Before integrating all the components, I tested the smallest units of code, which are the functions. This ensured that the functions were working as expected.
- Integration Testing: After confirming that all units of code were functioning properly, I started testing how they work when combined. This helped me ensure that the data flow across various units is working as expected and the units are working in harmony.
- Functional Testing with Postman: I used Postman to simulate client requests to the server. This involved sending various HTTP requests (GET, POST) to the server and observing the server's response. For the POST request, I tested file uploading by sending a multipart/form-data request that included the CSV file. I then verified whether the response received was as expected. For the GET request, I sent a request to the server to fetch the report and then inspected the returned JSON object to verify that it was structured correctly and contained the right data.
If this application was destined for a production environment, the following would be added or changed:
- Error Handling and Logging: Implement better error handling and logging for easier troubleshooting and monitoring.
- Authentication and Authorization: Secure the endpoints and only allow authorized users to access the services.
- Input Validation: All inputs (including CSV files) would be validated before processing.
- Environment Configuration: Use environment variables for sensitive data like database connection details.
- Performance Optimization: Implement caching and other performance optimization strategies.
- Testing: More robust and comprehensive testing, including load and stress testing.
Compromises Due to the time constraints of this challenge, a few compromises had to be made:
- Error Handling: The application's error handling is fairly basic and may not account for all potential issues.
- Frontend: The application currently lacks a frontend for a better user experience.
- Documentation: Due to time limitations, some aspects of the application may not be fully documented.
- Code Refactoring: There might be parts of the code that could be optimized or made more efficient. With more time, refactoring could be done to improve the code quality.
- Limited Testing: Due to the time constraint, I was not able to write extensive tests for all scenarios.