Intelligent document classifier
Web application that classifies documents using a multimodal LLM and generates outputs in Excel or Word.
01 Problem and context
Digitizing heterogeneous documents (scanned invoices, records, spreadsheets) requires manually classifying and transcribing them into the correct format: a repetitive, error-prone task.
Back-office document automation: invoices, purchase orders, inventories, reports, contracts and work orders that arrive mixed together, in different formats, and that someone has to read, classify and turn into usable data. The hard part is not reading a document, it is that the right destination depends on the content: tabular material belongs in a spreadsheet, narrative material in a word processor. The application hands that decision to a multimodal model and writes the output file directly.
02 Solution
A four-stage orchestrator (classification, extraction, generation, summarization) uses LLM vision for scanned images and text classification for office documents, automatically routing the results: tabular data to Excel and narrative content to Word, complete with an executive summary.
- Intake and validation: 14 accepted extensions (images, PDF, Word, Excel, PowerPoint, TXT and CSV) with a 20 MB ceiling and explicit rejection for anything else.
- Branching by input type: images go through the model's vision path; office documents are text-extracted first, since sending the page as an image would throw away information the file already carries.
- Classification: Llama 4 Scout, served through the Groq API at temperature 0.1, returns JSON with document type, confidence, target format and reasoning.
- Structured extraction: relevant fields are pulled according to the assigned destination rather than a single schema.
- File generation: tabular content is written to Excel with openpyxl; narrative content to Word with python-docx.
- Executive summary: a synthesis of the content alongside the downloadable file, so the result can be judged without opening it.
- Deployment: a Flask application on Vercel, with temporary storage and scheduled deletion after download.
03 Results
Verifiable figures in the repository and its documentation:
04 How it's built
A Flask-based web system that accepts documents (images, PDF, Word, Excel, PowerPoint, TXT, CSV), classifies them by type using the Groq API with the Llama 4 Scout multimodal model, extracts structured data, and generates an output file in Excel or Word based on the content. A central orchestrator coordinates the classification, extraction, generation, and executive summary pipeline with intelligent routing: tabular documents to .xlsx and narrative ones to .docx. It features a REST API and a drag-and-drop web interface, complete with automatic cleanup of temporary files.
05 Ethical decisions
- Generated files are deleted from the server 60 seconds after download; no copy of the user's document stays behind.
- Classification returns confidence and the model's reasoning, which keeps the decision auditable instead of a black box.
- When the model fails to return valid JSON, the system falls back to a conservative, declared classification rather than guessing silently.
- Processing depends on an external API: documents travel to Groq. That is stated plainly, because unlike a local engine this tool is not suitable for confidential material.
- The API key is handled through an environment variable and never committed.
06 Highlights
- Four-stage orchestrated pipeline (classification, extraction, generation, summarization) implemented in architecture/orchestrator.py.
- Multimodal classification: LLM vision for scanned images and text classification for PDF, Word, Excel, and PowerPoint.
- Automated output format routing: tabular data to Excel (.xlsx) and narrative documents to Word (.docx).
- REST API with processing, download, and health check endpoints, plus a drag-and-drop web interface built in vanilla JS.
- Temporary files with deferred automatic cleanup and configuration ready for serverless deployment on Vercel.
07 Limitations
There is no training and no labelled set: classification is zero-shot, driven by a prompt defining seven document categories and their routing rules. The confidence value is emitted by the model itself and is not calibrated against ground truth, so it should not be read as a probability. The project reports no measured accuracy on a test set.