Historical Documents Reader
A serverless AWS application to read, translate and analyze books on Chinese history. It extracts milestones with place, year and coordinates, and publishes them to the database that feeds China History.
You upload a PDF and can read it and translate it into Spanish, page by page. When you ask for it, an AI pipeline analyzes it: it splits it into chunks, computes embeddings, tags each chunk with its year range and extracts historical milestones with their place and coordinates. After reviewing the result, you publish it to production with a button. China History, the other app in the portfolio, reads it from there for its search and its map.
What it does
- Reader with translation — PDF viewer with continuous scroll and on-demand translation into Spanish, cached per page. If the PDF is a scan, it reads it with OCR (Amazon Textract or OpenAI vision).
- AI analysis — Tags years per chunk, extracts milestones with the book's own sentence as evidence, and character profiles without duplicates across books.
- Agent with citations — Answers questions about one book or all of them, streaming, with the page of each source. If nothing is relevant, it says it can't find it instead of making something up.
- Publish with preview — Before writing to production it shows what will happen: how many chunks, milestones and characters, and how many milestones are discarded because they are already in the database.
Technical highlights
- End-to-end serverless on AWS — S3, CloudFront, API Gateway with Cognito login, Lambdas in Python (and one in Node.js for streaming), Step Functions, DynamoDB and EventBridge. All defined with CDK in TypeScript, with continuous deployment through GitHub Actions and OIDC, no stored keys.
- Batched pipeline in Step Functions — Analyzing an 800-page book is split into batches that run in parallel, with a progress bar that reflects real progress and resume if something fails.
- Data quality, measured by hand — I reviewed the milestones of the first real book and found 5 out of 28 with the year off. That led to changes in the prompt, to validating each quote against the text, and to not merging same-name characters without asking a judge.
- Cascading geocoding with verification — Curated sources, CHGIS, Wikidata and Mapbox, accepting only clear matches. If the place is a whole state and not a city, the point is marked as "approximate".
- Contract with another app — China History is read-only: double validation of every document, idempotent writes tagged with their origin, semantic deduplication, and separate databases for testing and production.
- Controlled cost — Token and cost counter per book, an estimate before each analysis (~0.01 USD per page) and a budget with alerts in AWS.
- Tests — 436 tests in the backend, 153 in the frontend and 24 in the agent.
Technologies
- Python
- AWS Lambda
- Step Functions
- DynamoDB
- React
- TypeScript
- Vite
- Tailwind CSS
- AWS CDK
- S3
- CloudFront
- Cognito
- MongoDB Atlas
- OpenAI
Try the demo with this account
- demo@documentreader.app
- Password
- Demo12345678
This is a demo user with read-only access.

