Practice assignment
CSV import take-home assignment
- CSV
- Validation report
- Streaming
- Spring or Node
- 3 hours
Operations uploads end-of-day trade files. Valid rows must be stored and every bad row explained so they can fix the file. A few bad rows must not block the rest. HireCheck has a Spring Boot version (the free sample ZIP was generated from a securities-processing job posting, company name removed) and a Node.js streaming version with an ISIN check digit and rollback on failure.
The starter
assignment/ ├── README.md ├── pom.xml └── src/main/java/com/example/imports/ ├── ImportController.java ├── TradeImportService.java TODO └── ImportReport.java
The TypeScript starter instead exposes POST /api/imports/trades as a raw text/csv body and asks you to stream, batch, and bound the rejection list.
Requirements
Spring Boot (sample ZIP)
POST /api/imports/trades(multipartfile) →{imported, rejected:[{line, reason}]}.- Header must be
reference,isin,side,quantity,price,tradeDate, else400 BAD_FILE. LF and CRLF both work. Line numbers are 1-based and include the header. - Reasons:
COLUMNS,ISIN,SIDE(BUY|SELL),QUANTITY,PRICE,DATE(ISO, not future),DUPLICATE(in the file or already in the database).
Node.js / TypeScript adds streaming (chunk boundaries, backpressure, batches of ≤ 500), a Luhn ISIN check digit, a 50 MB cap, a bounded report (truncated), and rollback of the current import if the request fails halfway.
Grading rubric
| Area | Points |
|---|---|
| Correctness (provided tests) | 30 |
| Validation completeness and clear reasons | 15 |
| Streaming / memory for large files | 15 |
| Own tests (huge file, encoding, quotes / chunk splits) | 15 |
| Transaction strategy (partial vs all-or-nothing), justified | 10 |
| NOTES.md: idempotent re-upload, checksums, async jobs | 15 |
Levels: junior ≥ 60, mid ≥ 75, senior ≥ 85 (and a strong NOTES.md).
What reviewers look for
- Specific reasons, not a generic “invalid row”.
- Whether you slurp the file into a giant string. A 3-hour Spring solution can use a careful
BufferedReader; the TypeScript brief requires a real stream. - A stated transaction strategy: partial success is what operations asked for; all-or-nothing needs a reason.
- NOTES.md on re-uploading the same file (file hash, import id) and when to move to an async job.
Common mistakes
- Off-by-one line numbers (forgetting that the header is line 1).
- Accepting only
\nand failing on WindowsCRLF. - Letting one bad row abort the whole file when the brief wanted a report.
- Holding every valid row in memory before the first write.
- Ignoring quotes or encodings, then being surprised by a field that contains a comma.
How to run it
Spring Boot sample: mvn verify — on the starter the tests stay red (55 errors on the published sample) until the TODOs are done. Node.js: npm ci and npm test.
Download the Spring Boot securities-import sample with no account, or generate a TypeScript streaming version from a job ad.
Download the CSV import sample ZIP Generate one from a job adRelated practice tasks
Frequently asked questions
- Where does the free Spring Boot sample come from?
- HireCheck generated it from a real Tallinn securities-processing job posting, with the company name removed. It is a practice assignment, not that employer's take-home.
- Should I use Spring Batch?
- Not required. For one HTTP upload it is often heavier than the problem. Mention in NOTES.md when you would reach for it (restartability, long jobs, an operations UI).
- Is a Luhn check required on the Java sample?
- The Java brief asks for the ISIN shape. The TypeScript brief also asks for the check digit. Doing the checksum on the Java task is a plus if the tests still pass — say so in NOTES.md.
Practice only. This is an original HireCheck practice assignment, not a real employer's take-home, and it is not affiliated with any company mentioned as a role example.