Document Q&A API: answer questions about a PDF

Your first deliverable: a service someone else can run, that takes a PDF and answers questions about it.

The brief

A small legal team keeps asking the same questions of the same contracts. They want to upload a PDF and ask plain questions, without pasting pages into a chat window.

What you will build

  • An endpoint that accepts a PDF upload
  • An endpoint that takes a question and returns an answer
  • A typed response with the answer and the page it came from
  • A README that gets a stranger running in five minutes

Requirements

RequirementDone when
UploadA PDF up to 20 pages is accepted and its text extracted
AnswerQuestions return a typed object, never free text you have to parse
SourceEach answer names the page it relied on
ErrorsA scanned PDF with no text returns a clear error, not a crash
TestsUpload, answer and error paths have tests
Run itOne command starts it, in a container

What to learn it from

Milestones

  1. Extract text from a PDF and print it
  2. Answer one hard-coded question from that text
  3. Wrap it in two API endpoints
  4. Return a typed answer with the page number
  5. Add tests and a container
  6. Write the README and ask someone else to run it
How it is judged
A stranger clones the repository, runs one command, uploads a PDF and gets a correct answer with a page reference. Nothing else counts.

Stretch goals

  • Handle documents longer than the context window
  • Stream the answer as it is written
  • Cache answers to repeated questions

Before you call it done

Worth remembering
  • It runs from the README alone
  • Every answer carries its source page
  • The failure cases have tests
Back toAll frameworks

Every expert started right here.