FastAPI microservice that extracts structured tender data from South African government PDF documents using deterministic regex-based pattern matching
# Tender Extract API
FastAPI microservice that extracts structured tender data from South African government procurement documents using deterministic extraction. Supports PDF, DOCX, DOC, XLSX, XLS, PPTX, ODT, RTF, CSV, TXT, and ZIP archives.
---
## About Tenders-SA
Tenders-SA.org is an **AI-powered tender matching and application platform** for South African businesses. It aggregates tenders from national, provincial, and municipal government departments, SOEs (Eskom, Transnet, SANRAL), and public entities — sourced directly from official OCDS (Open Contracting Data Standard) feeds.
### Role of This Microservice
Government tender documents are the raw source of truth for procurement opportunities. The **Tender Extract API** converts unstructured documents into structured, queryable data fields such as:
- Description and scope of work
- Requirements and eligibility criteria
- Tender reference numbers and titles
- Closing dates and times
- Issuing organizations and departments
- Estimated values and bid bond requirements
- B-BBEE level requirements and preference points
- Contact information and briefing session details
- Evaluation criteria and returnable documents
- Confidence scores for extraction quality
This service is intentionally **fast and deterministic** — it uses regex-based extraction and format-specific parsers, not AI/LLM processing. When extraction confidence is low, the main application decides whether to run AI fallback enrichment.
### Pipeline Architecture
```mermaid
graph LR
A[Cloudflare Worker] -->|Raw OCDS + Document URL| B[Main App Ingestion Service]
B -->|URL| C[Tender Extract API]
C -->|Structured JSON| B
B -->|Mapped Data| D[(Main Database)]
D --> E[AI Enrichment (if confidence low)]
```
---
## Features
- **Multi-format extraction** — PDF, DOCX, DOC, XLSX, XLS, PPTX, ODT, RTF, CSV, TXT
- **ZIP archive support** — Recursive extraction of mixed-format bid packs with result merging
- **Plugin architecture** — Each format is a self-c …