# omkarpathak/pyresparser architecture

> Architecture diagram of the GitHub repository omkarpathak/pyresparser, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/omkarpathak/pyresparser
- Repository: https://github.com/omkarpathak/pyresparser

## Overview

##### Main Components
- API Layer / Library Entry Point: Highlight the key class/function (e.g., the ResumeParser in pyresparser/resume_parser.py) which API consumers call.
- Command-Line Interface (CLI): Represent the command_line module (pyresparser/command_line.py) that allows users to run the parser from the terminal.
- Parsing Modules:
– Extraction Core: The resume_parser component that organizes the extraction of data like name, email, phone number, etc.
– NLP Integration: Modules and utilities that wrap external NLP libraries (like spaCy and nltk) and perform text tokenization (pyresparser/tokenizer) and Named Entity Recognition (the pyresparser/ner subfolder containing cfg, model, moves).
- Data/Resource Files:
– Vocabulary: The vocab directory that contains lexemes, key mappings (key2row), vectors, and other data structures used for NLP.
– Custom Training Data: Files like custom_train.py and custom_t.py, which are likely used to customize the extraction (potentially for skills or pattern matching).
- External Dependencies: Note the reliance on external libraries (spaCy, nltk, and optionally textract for DOC extraction) that are invoked during parsing.
- Supporting Scripts and Tests: Include modules like export_to_csv.py and test_name.py that aid in testing or data export, representing auxiliary but important paths.

##### Establish Relationships and Data Flow
- The starting point is the CLI or direct API call where a resume (PDF, DOCx, etc.) is provided.
– Text Extraction Subcomponent: Where the resume file is first converted into text.
– NLP/NER Processing: Where tokens are processed using spaCy/nltk, and named entities are extracted.
- Data flows between the NLP processing and utility components (like tokenizer, custom modules, and vocab).

##### Architectural Patterns and Design Principles
- Modular Design: Each component (CLI, parsing engine, NLP handling, utilities, vocabulary) is separated into different modules and folders, indicating a clean separation of concerns.
- Extensibility: The presence of custom modules (custom_t.py and custom_train.py) suggests the design allows for future extensions and training adjustments.
- Integration with External Tools: Make it clear that while the core extraction is handled within the code, the reliance on established NLP libraries (spaCy and nltk) is an external integration point.

##### Relevant Technologies and Frameworks
- Python (core language).
- spaCy and nltk for NLP tasks.
- textract (optional) for DOC file extraction.
- GitHub and Continuous Integration (Travis CI indicated by .travis.yml).
- Packaging and distribution files (setup.py, MANIFEST.in) that emphasize its role as a pip-installable package.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input
    A["Resume File Input"]:::input

    %% Interface Layer
    subgraph "Interface Layer"
        B["CLI Handler"]:::cli
    end

    %% Core Parsing Engine
    subgraph "Core Parsing Engine"
        D["ResumeParser Module"]:::core
        E["Text Extraction"]:::core
        F["Tokenization Engine"]:::nlp
        G["NER Processor"]:::nlp
    end

    %% Utilities and Resources
    subgraph "Utilities & Resources"
        H["Utilities"]:::util
        I["Constants"]:::util
        J["Vocabulary"]:::data
    end

    %% Custom Training Modules
    subgraph "Custom Training Modules"
        L["Custom Train Module"]:::custom
        M["Custom T Module"]:::custom
    end

    %% Parsed Output
    K["Parsed Resume Output"]:::output

    %% External Dependencies
    N["External NLP Libraries (spaCy,nltk,textract)"]:::external

    %% Supporting Scripts
    subgraph "Supporting Scripts"
        O["Data Export Script"]:::support
        P["Testing Module"]:::support
    end

    %% Connections for Interface and Core Parsing
    A --> B
    B --> D

    %% Core Parsing Workflow
    D -->|"extract_text"| E
    E -->|"tokenize"| F
    E -->|"entity_recognition"| G

    %% External Dependencies used by NLP modules
    F -->|"uses"| N
    G -->|"uses"| N

    %% Core Parsing aggregation to output
    F -->|"collect_tokens"| K
    G -->|"collect_entities"| K
    D -->|"apply_logic"| K

    %% Utilities & Resources feeding into output
    D --> H
    D --> I
    D --> J
    H --> K
    I --> K
    J --> K

    %% Custom Training Modules influencing output
    D --> L
    D --> M
    L --> K
    M --> K

    %% Click Events
    click D "https://github.com/omkarpathak/pyresparser/blob/master/pyresparser/resume_parser.py"
    click B "https://github.com/omkarpathak/pyresparser/blob/master/pyresparser/command_line.py"
    click F "https://github.com/omkarpathak/pyresparser/tree/master/pyresparser/tokenizer"
    click G "https://github.com/omkarpathak/pyresparser/tree/master/pyresparser/ner"
    click H "https://github.com/omkarpathak/pyresparser/blob/master/pyresparser/utils.py"
    click I "https://github.com/omkarpathak/pyresparser/blob/master/pyresparser/constants.py"
    click J "https://github.com/omkarpathak/pyresparser/tree/master/pyresparser/vocab"
    click L "https://github.com/omkarpathak/pyresparser/blob/master/pyresparser/custom_train.py"
    click M "https://github.com/omkarpathak/pyresparser/blob/master/pyresparser/custom_t.py"
    click O "https://github.com/omkarpathak/pyresparser/blob/master/export_to_csv.py"
    click P "https://github.com/omkarpathak/pyresparser/blob/master/test_name.py"

    %% Styles
    classDef input fill:#eef,stroke:#333,stroke-width:2px;
    classDef cli fill:#ccf,stroke:#333,stroke-width:2px;
    classDef core fill:#f96,stroke:#333,stroke-width:2px;
    classDef nlp fill:#afa,stroke:#333,stroke-width:2px;
    classDef util fill:#cff,stroke:#333,stroke-width:2px;
    classDef data fill:#fcf,stroke:#333,stroke-width:2px;
    classDef custom fill:#ff9,stroke:#333,stroke-width:2px;
    classDef external fill:#ddd,stroke:#333,stroke-width:2px;
    classDef output fill:#dfd,stroke:#333,stroke-width:2px;
    classDef support fill:#ffb,stroke:#333,stroke-width:2px;
```
