How 4bits-capstone/konverter_full_pipeline works
Purpose and entry points
Konverter is a document-conversion and review system for turning uploaded PDFs into structured, publishable outputs with confidence/audit visibility. The FastAPI backend starts at backend/app/main.py; the Vite/React client starts at src/main.tsx and composes the application in src/App.tsx / src/ConverterApp.tsx.
Frontend workflow shell
The UI models a multi-stage document workflow, with route/workflow definitions in src/config/workflow.ts and route helpers in src/lib/converterRoutes.ts. src/components/AppShell.tsx provides shared layout, while src/components/StageRail.tsx exposes pipeline progress. Document-centric pages cover upload, review, metadata, preview, history, and administrative operations under src/pages/.
Client state, API boundary, and contracts
src/state/KonverterContext.tsx is the central client-side document/workflow state boundary. API calls flow through src/services/httpClient.ts and src/services/fastApi.ts, against typed service contracts in src/services/contracts.ts. Domain types reside in src/types/konverter.ts; this keeps page/components decoupled from FastAPI transport details.
Backend API and service orchestration
backend/app/main.py defines the FastAPI application and HTTP entry boundary. backend/app/service.py coordinates document operations and persistence-facing behavior, with request/domain models in backend/app/models.py. Runtime options, page limits, confidence thresholds, OCR/table/device settings, and URL/publication defaults are centralized in backend/app/config.py.
Conversion and structure pipeline
backend/app/pipeline.py is the core PDF/Docling conversion stage, configurable for CPU, CUDA, or auto device selection and optional OCR/table structure extraction. Derived content is then interpreted through backend/app/visual_structure.py, backend/app/toc_hierarchy.py, and backend/app/metadata_rules.py to establish visual/document hierarchy and publication metadata. This is the key boundary between raw converter output and reviewable structured content.
Publication, media, and storage outputs
backend/app/exporter.py creates downstream publication/export representations, including HTML assembled by backend/app/preview_html.py. backend/app/media.py manages document media assets; backend/app/storage.py provides the persistence/storage boundary for uploaded and generated artifacts. Public URL construction can use configured site, page-template, and API-origin values.
Security, audit, and infrastructure
Authentication/authorization is split between frontend Supabase integration (src/lib/supabaseClient.ts, src/lib/useIsAdmin.ts) and backend verification/privileged access in backend/app/auth.py. Admin-gated UI uses src/components/AuthGate.tsx and src/components/RequireAdmin.tsx. backend/app/audit.py records material actions, surfaced by src/pages/AuditLogPage.tsx; backend logging is managed in backend/app/logging_utils.py. Material runtimes are Node 20+ for React/Vite and Python 3.11/3.12 for FastAPI/Docling, with Supabase as the external identity service and optional CUDA-enabled PyTorch acceleration.
Main entry points: service.py Document service · ConverterApp.tsx Converter application · main.py FastAPI application · AppShell.tsx Workflow UI shell
Components 18
React client
- Vite entry
src/main.tsx - Converter application
src/ConverterApp.tsx - Workflow routing
src/config/workflow.ts - Workflow UI shell · Shared document pages expose progress, review, metadata, preview, history, and admin operations.
src/components/AppShell.tsx - Document state
src/state/KonverterContext.tsx - Typed API client
src/services/fastApi.ts - Client auth gates
src/lib/supabaseClient.ts
FastAPI backend
- FastAPI application
backend/app/main.py - Document service
backend/app/service.py - Backend authorization
backend/app/auth.py - Artifact storage · Stores uploaded and generated document artifacts.
backend/app/storage.py - Audit trail
backend/app/audit.py - Runtime configuration · Centralizes limits, confidence thresholds, device, OCR, table, and URL defaults.
backend/app/config.py
Conversion pipeline
- PDF conversion · Runs CPU, CUDA, or automatic conversion with optional OCR and table extraction.
backend/app/pipeline.py - Document structure · Transforms converter output into visual hierarchy, TOC structure, and publication metadata.
backend/app/visual_structure.py - Publication export · Builds export representations and HTML previews.
backend/app/exporter.py - Media assets
backend/app/media.py
External services
- Supabase
Connections 20
- Vite entry → Converter application: mounts
- Converter application → Workflow routing: uses stages
- Converter application → Workflow UI shell: renders
- Workflow UI shell → Document state: reads and updates
- Document state → Typed API client: invokes
- Client auth gates → Supabase: authenticates with
- Client auth gates → Workflow UI shell: gates admin UI
- Typed API client → FastAPI application: HTTP requests
- FastAPI application → Backend authorization: authorizes
- Backend authorization → Supabase: verifies identity
- FastAPI application → Document service: dispatches operations
- Document service → PDF conversion: converts uploads
- PDF conversion → Document structure: produces raw content
- Document structure → Publication export: supplies structured content
- Document service → Media assets: manages assets
- Document service → Artifact storage: persists artifacts
- Publication export → Artifact storage: stores outputs
- Document service → Audit trail: records actions
- Runtime configuration → PDF conversion: configures
- Runtime configuration → Publication export: sets publication defaults