# dhananjayporwal/xml-to-pdf-converter-candor-investing architecture

> Architecture diagram of the GitHub repository dhananjayporwal/xml-to-pdf-converter-candor-investing, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dhananjayporwal/xml-to-pdf-converter-candor-investing
- Repository: https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing

## Overview

##### Project Type and Purpose
- The project is a web-based data conversion tool, built with Streamlit.
- Its primary function is to let users upload XML files, process and parse them, convert the data into readable TXT and PDF formats (including generating a ZIP for multiple files), and view key extracted data in a summary table.
- The tool is designed for both local usage and deployment on cloud platforms (like Streamlit Cloud).

##### Analyzing the File Structure
- Top-level Files:
- app.py: The main application file that drives the Streamlit interface and implements the file upload, XML parsing, and conversion logic.
- requirements.txt, runtime.txt: Define software dependencies and runtime configuration for deployment.
- Procfile: Indicates how to run the app on certain cloud platforms.
- BulkConverter.ipynb: Likely serves as an exploratory notebook or demo of the conversion process.
- styles.css: Contains custom styles to enhance the app’s UI.
- Directories:
- .streamlit: Contains configuration files (e.g., config.toml) specific to how Streamlit should run and render the UI.
- .devcontainer: Provides development container settings (e.g., for VSCode) to ensure a consistent development environment.

##### Key Components and Architecture
- Frontend (User Interface):
- Built with Streamlit (code largely in app.py).
- Manages file uploads, displays the interactive summary table, and incorporates custom UI styling (styles.css).
- File Upload & Data Intake:
- Handles user-selected XML files.
- Includes input validations for multiple file uploads.
- Data Processing & Conversion:
- Contains routines for parsing XML and extracting required data (e.g., Name, Gender, PAN, DOB, etc.).
- Converts XML content into human-readable TXT files.
- Generates PDF files (using fpdf) that feature a formatted header (with the company logo) and additional styling.
- Temporary File Storage and Cleanup:
- Leverages temporary directories to hold uploaded as well as processed files.
- Implements cleanup routines post-processing to manage temporary files.
- Download & Export:
- Provides options to download individual converted files or a single ZIP archive when multiple files are processed.
- Deployment & Environment:
- Supports local execution (as per the setup instructions) and cloud deployment via Streamlit Sharing.
- Configuration files (Procfile, runtime.txt, .devcontainer, .streamlit) aid in deployment and development setup.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Application Components
    subgraph "Application Core"
        direction TB
        U["User"]:::frontend
        UI["Streamlit UI (app.py)"]:::frontend
        Upload["XML Upload Module (app.py)"]:::frontend
        Parser["XML Parser & Data Extraction (app.py)"]:::processing
        Temp["Temporary File Storage/Cleanup (app.py)"]:::processing
        TXT["TXT Converter Module (app.py)"]:::processing
        PDF["PDF Generator Module (app.py)"]:::processing
        Download["Download Manager (app.py)"]:::processing
    end

    U -->|"uploadXML"| UI
    UI -->|"handleUpload"| Upload
    Upload -->|"passToParser"| Parser
    Parser -->|"storeTempData"| Temp
    Parser -->|"extractSummary"| UI
    Parser -->|"feedTXT"| TXT
    Parser -->|"feedPDF"| PDF
    TXT -->|"TXTReady"| Download
    PDF -->|"PDFReady"| Download

    %% Deployment & Infrastructure Components
    subgraph "Deployment & Infrastructure"
        direction TB
        Styling["Custom UI Styling (styles.css)"]:::infra
        Proc["Deployment Config (Procfile)"]:::infra
        Runtime["Runtime Config (runtime.txt)"]:::infra
        StreamlitConf["Streamlit Config (.streamlit/config.toml)"]:::infra
        DevEnv["Development Environment (.devcontainer/devcontainer.json)"]:::infra
    end

    Styling --> UI
    Proc --> UI
    Runtime --> UI
    StreamlitConf --> UI
    DevEnv --> UI

    %% Click Events
    click UI "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click Upload "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click Parser "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click TXT "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click PDF "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click Temp "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click Download "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/app.py"
    click Styling "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/styles.css"
    click Proc "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/tree/main/Procfile"
    click Runtime "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/runtime.txt"
    click StreamlitConf "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/.streamlit/config.toml"
    click DevEnv "https://github.com/dhananjayporwal/xml-to-pdf-converter-candor-investing/blob/main/.devcontainer/devcontainer.json"

    %% Styles
    classDef frontend fill:#ffcccc,stroke:#cc3300,stroke-width:2px;
    classDef processing fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef infra fill:#d4edda,stroke:#155724,stroke-width:2px;
```
