# Kenya Public Finance Accountability System (KPFAS)
A data ingestion, tracking, and auditing platform designed to monitor public financial allocations, disbursements, procurement records, and Office of the Auditor-General (OAG) audit reports in Kenya.
---
## Workspace Structure
```
├── app.ts # Fastify API Server application factory
├── setup.ts # Test environment setup for Vitest
├── apps/
│ └── api/
│ └── src/
│ └── db/
│ ├── migrations/ # Integrated database migration SQL files
│ └── seeds/ # Initial development seed data
├── db/
│ └── migrations/ # Database schema migrations
├── oag-scraper/ # Office of the Auditor-General (OAG) scraper module
│ └── src/
│ └── scrapers/
│ └── oag/ # OAG Playwright scraper (config, download, scrape, persist, run)
├── scripts/
│ └── check-connectivity.mjs # Service health check script
└── tests/
└── health.test.ts # API health & readiness Vitest test suite
```
---
## Database Architecture
The core relational database is PostgreSQL, tracking public finance accountability entities across key schemas:
1. **`ministries`**: National and County government ministries and departments.
2. **`financial_years`**: Standard financial year definitions (e.g. `2024/2025`).
3. **`budget_allocations`**: Approved vote head allocations per ministry per financial year.
4. **`disbursements`**: Quarterly disbursements and Controller of Budget (COB) approval statuses.
5. **`audit_reports`**: Scraped raw OAG audit report PDFs, metadata (`title`, `entity_type`, `entity_label`, `content_hash`), and parsed JSON output.
6. **`audit_findings`**: Individual audit findings extracted from audit reports.
7. **`procurement_records`**: Tender and contract awards with PPRA reference numbers.
8. **`anomalies`**: Automated anomaly detection flags.
9. **`escalations`**: Invest …