Production-oriented backend assessment for the Senior Backend Engineer role.
This service accepts maritime documents such as certificates, passports, PEME reports, and drug tests, extracts structured data using a vision-capable LLM, supports both sync and async processing, validates multi-document sessions, and generates a final compliance report from persisted data.
POST /api/extractfor sync and async document extractionGET /api/jobs/:jobIdfor async job pollingGET /api/sessions/:sessionIdfor session-level document summaryPOST /api/sessions/:sessionId/validatefor cross-document compliance validationGET /api/sessions/:sessionId/reportfor a derived compliance reportGET /api/healthfor service and dependency health
Core stack:
- Bun + TypeScript
- Express.js
- MongoDB + Mongoose
- Redis + BullMQ
- Gemini/OpenAI-compatible LLM provider abstraction
- Install dependencies:
bun install- Create your env file:
cp .env.example .env- Make sure these are running:
- MongoDB
- Redis
- Fill the required env vars in
.env:
MONGODB_URIREDIS_URLLLM_PROVIDERLLM_MODELLLM_API_KEY
- Start the API:
bun run start- Start the worker in a separate terminal:
bun run worker- Optional validation:
bun run check- Client uploads a maritime document to
POST /api/extract. - Server validates the file, computes SHA-256, resolves/creates a session, and checks deduplication.
- In
syncmode, extraction runs immediately and returns the structured result. - In
asyncmode, a BullMQ job is created and processed by the worker. - Multiple extracted documents can be grouped under one
sessionId. - Once a session has enough completed documents,
POST /api/sessions/:sessionId/validateruns cross-document compliance validation. GET /api/sessions/:sessionId/reportreturns a final derived report without another LLM call.
Use the included Postman collection:
Import it into Postman, set your base URL and environment variables, and use it to exercise the endpoints quickly.
- JPEG, PNG, and PDF uploads are accepted.
- Async jobs require both Redis and the worker process.
- Duplicate uploads in the same session are deduplicated by SHA-256 hash.
- Validation and reporting are session-based.
- The implementation favors clear service boundaries, explicit error handling, and a queue-backed extraction pipeline over a “single-file demo” style solution.