Sangeetha-Grantha

TRACK-070: Import Pipeline Fix Checklist

Date: 2026-02-25 Status: Superseded by TRACK-071 (most items completed via new TOC-based approach) Scope: End-to-end fix of the Dikshitar krithi import pipeline — from PDF extraction through PostgreSQL seeding to frontend display Context: Original pipeline had multiple issues documented below. TRACK-071 replaced the broken extraction with a TOC-based approach that resolved most issues.


Pipeline Overview (for reference)

mdeng.pdf / mdskt.pdf
    ↓ [REPLACED] extract_eng_pymupdf.py → extract_toc_based.py
    ↓ eng_krithis.json / skt_krithis.json
    ↓ [REPLACED] import_matched_csv.py → import_dikshitar_krithis.py (standalone)
PostgreSQL (krithis, krithi_sections, krithi_lyric_variants, krithi_lyric_sections)
    ↓ [FIXED] Admin Web /krithis table with search, pagination, filters

PHASE 1 — Fix PDF Extraction (extract_eng_pymupdf.py)

1.1 — Upgrade PyMuPDF text extraction mode

1.2 — Implement deterministic section header detection (root cause of “Squashed Content Bug”)

1.3 — Strip embedded images from extracted text

1.4 — Strip PDF page numbers and entry numbers from lyric content

1.5 — Add extraction validation step


PHASE 2 — Fix eng_krithis.json and skt_krithis.json

2.1 — Regenerate eng_krithis.json from fixed extractor

2.2 — Fix raga name normalisation in eng_krithis.json

2.3 — Regenerate skt_krithis.json with Devanagari content

2.4 — Ensure JSON section key names are canonical and consistently ordered

2.5 — Capture footnote / variant readings


PHASE 3 — Fix import_matched_csv.py

3.1 — Fix hardcoded primary language (te)

3.2 — Fix section ordering (canonical musical order, not dict.keys() order)

3.3 — Fix madhyamakala section type mapping

3.4 — Fix Sanskrit section mapping

3.5 — Strip base64 image data before inserting into DB

3.6 — Fix en_lyrics_full / sa_lyrics_full concatenation

3.7 — Fix raga name lookup to handle IAST diacritics

3.8 — Add tala name normalisation

3.9 — Add AUDIT_LOG entries per krithi (project requirement)

3.10 — Fix logger.info placement


PHASE 4 — Database Migration & Re-import

4.1 — Reset and clean the import

4.2 — Re-run fixed import script

4.3 — Post-import DB validation queries

4.4 — Spot-check 5 krithis manually


PHASE 5 — Frontend Bug Fixes

5.1 — Fix Raga column in Krithis listing table

5.2 — Fix Language display in Krithis listing

5.3 — Verify Structure tab section order

5.4 — Verify Lyrics tab content

5.5 — Verify Lyric Variants tab (Devanagari)

5.6 — Fix “Modi” badge on Raga field


PHASE 6 — Structural Schema Improvements

6.1 — Add MADHYAMA_KALA as a first-class section type

6.2 — Model Lyric Variant Readings

6.3 — Add Incipit field population


PHASE 7 — Pipeline Hardening & Tests

7.1–7.4 — Unit/integration tests


Additional Work Done (not in original checklist)

Search Functionality Fix

Pagination

Filter Panel

CORS / Auth Fix


Ref: application_documentation/04-database/schema.md · database/for_import/ · TRACK-071