# harish-k000/jobfit-nlp architecture

> Architecture diagram of the GitHub repository harish-k000/jobfit-nlp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/harish-k000/jobfit-nlp
- Repository: https://github.com/harish-k000/jobfit-nlp

## Overview

#### Purpose and Entry Points
JobFit-NLP scores a resume bullet against a job requirement as `strong_match`, `partial_match`, or `no_match`, then ranks evidence for every requirement in pasted documents. The runtime service starts in `api/main.py`; its main user-facing flow is `POST /api/v1/match-documents`. Offline workflows are exposed through `Makefile` and model/script modules.

#### Dataset and Labeling Boundary
Labeled sentence-pair data is JSONL, with job descriptions decomposed into atomic requirements and paired with resume bullets. Splits are by `job_id`, preventing job-description leakage across train/validation/test.
- `data/train.jsonl`
- `data/validation.jsonl`
- `data/test.jsonl`
- `docs/labeling_rubric.md`
- `docs/dataset_spec.md`

Raw material may contain PII and is isolated under `data/raw/`; processed data is the training contract.

#### Data Collection and Split Pipeline
Dataset authoring imports and selects job requirements, builds candidate-pair labeling queues, and materializes leakage-safe splits. This is an offline pipeline, distinct from serving.
- `scripts/import_jobs_csv.py`
- `scripts/select_requirements.py`
- `scripts/build_labeling_queue.py`
- `scripts/split_dataset.py`

Requirement segmentation is shared production logic rather than API dependence on authoring scripts:
- `model/segmentation.py`

#### Modeling and Evaluation
The core predictor is a DistilBERT three-class sequence-pair classifier, trained with PyTorch and Hugging Face Trainer. Model code also establishes baseline comparators—majority class, keyword overlap, and TF-IDF + Logistic Regression—so transformer quality is measured rather than assumed.
- `model/train.py`
- `model/dataset.py`
- `model/baselines.py`
- `model/predict.py`
- `model/evaluate.py`

Evaluation prioritizes macro F1, class-level metrics, confusion analysis, and structured artifacts. Current recorded results indicate the transformer trails keyword overlap, so inference should be treated as evidence-ranking rather than definitive matching.
- `model/metrics.py`
- `artifacts/evaluation_results.json`
- `artifacts/baseline_results.json`
- `artifacts/error_analysis.csv`

#### API Inference and Document Matching
FastAPI request schemas and dependencies define the serving boundary. Single and batch pair endpoints delegate to model inference; document matching orchestrates full-text preprocessing, bounded cross-product scoring, ranking, and coverage aggregation.
- `api/main.py`
- `api/schemas.py`
- `api/dependencies.py`
- `api/inference.py`
- `api/document_matching.py`

For a document request: extract requirements → extract resume bullets → cap at 25 requirements and 20 bullets → score up to 500 pairs → rank bullets per requirement → return top evidence, best match, probabilities/confidence, and strong/partial/none coverage. Resume parsing is local in-process logic:
- `api/resume_splitter.py`

#### Runtime, Deployment, and External Dependencies
The service runs as a Python FastAPI process, loading a trained tokenizer/model from the local model-output convention. Training/inference depend on PyTorch, Hugging Face Transformers/Datasets, Pandas, and scikit-learn; no hosted model or database service is identified. Docker packages the service, with compose available for local orchestration.
- `Dockerfile`
- `docker-compose.yml`
- `requirements.txt`

#### Experiment Governance
Hyperparameter and multi-seed workflows select by validation performance and gate promotion of a model output against the keyword baseline; artifacts provide the experiment record.
- `scripts/hparam_search.py`
- `scripts/multi_seed_train.py`
- `artifacts/hparam_search_results.json`
- `artifacts/multi_seed_results_tuned.json`

Main entry points: [`api/document_matching.py`](https://github.com/harish-k000/jobfit-nlp/blob/main/api/document_matching.py) (Document matcher), [`model/train.py`](https://github.com/harish-k000/jobfit-nlp/blob/main/model/train.py) (DistilBERT trainer), [`data/train.jsonl`](https://github.com/harish-k000/jobfit-nlp/blob/main/data/train.jsonl) (Labeled JSONL splits), [`api/inference.py`](https://github.com/harish-k000/jobfit-nlp/blob/main/api/inference.py) (Pair inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data &amp; labeling"]
  node_raw_data[("Raw source data<br/>PII-isolated input")]
  node_requirements_import["Job requirement authoring<br/>offline scripts<br/>[import_jobs_csv.py]"]
  node_split_pipeline["Leakage-safe split<br/>offline script<br/>[split_dataset.py]"]
  node_labeled_splits[("Labeled JSONL splits<br/>training contract<br/>[train.jsonl]")]
  node_labeling_guidance["Labeling contract<br/>documentation<br/>[labeling_rubric.md]"]
end

subgraph group_modeling["Modeling &amp; experiments"]
  node_segmentation["Requirement segmentation<br/>shared model logic<br/>[segmentation.py]"]
  node_dataset_loader["Pair dataset loader<br/>model module<br/>[dataset.py]"]
  node_trainer["DistilBERT trainer<br/>3-class classifier<br/>[train.py]"]
  node_baselines["Baseline comparators<br/>model module<br/>[baselines.py]"]
  node_evaluation["Evaluation &amp; analysis<br/>model module<br/>[evaluate.py]"]
  node_experiment_governance["Promotion workflows<br/>experiment scripts<br/>[hparam_search.py]"]
  node_experiment_artifacts["Experiment records<br/>evaluation artifacts"]
end

subgraph group_serving["API serving"]
  node_api_entry["FastAPI application<br/>service entry point<br/>[main.py]"]
  node_api_contract["Request schemas &amp; dependencies<br/>API boundary<br/>[schemas.py]"]
  node_pair_inference["Pair inference<br/>API inference layer<br/>[inference.py]"]
  node_document_matching["Document matcher<br/>orchestrator"]
  node_resume_splitter["Resume bullet extraction<br/>local parser<br/>[resume_splitter.py]"]
  node_match_documents{{"POST match-documents<br/>document endpoint<br/>[main.py]"}}
end

subgraph group_runtime["Runtime packaging"]
  node_model_output[("Local model output<br/>trained model/tokenizer")]
  node_container_runtime["Containerized service<br/>deployment"]
end

node_raw_data -->|"source jobs"| node_requirements_import
node_requirements_import -->|"labeled candidate pairs"| node_split_pipeline
node_labeling_guidance -.->|"labeling rules"| node_split_pipeline
node_split_pipeline -->|"job_id-separated splits"| node_labeled_splits
node_labeled_splits -->|"examples"| node_dataset_loader
node_dataset_loader -->|"train/validation data"| node_trainer
node_labeled_splits -->|"benchmark data"| node_baselines
node_trainer -->|"trained weights/tokenizer"| node_model_output
node_trainer -->|"transformer predictions"| node_evaluation
node_baselines -->|"baseline predictions"| node_evaluation
node_evaluation -->|"metrics and errors"| node_experiment_artifacts
node_experiment_governance -->|"tuned training runs"| node_trainer
node_experiment_artifacts -->|"validation results"| node_experiment_governance
node_api_entry -->|"validates requests"| node_api_contract
node_api_entry -->|"routes request"| node_match_documents
node_match_documents -->|"document payload"| node_document_matching
node_document_matching -->|"extract requirements"| node_segmentation
node_document_matching -->|"extract bullets"| node_resume_splitter
node_document_matching -->|"up to 500 pairs"| node_pair_inference
node_pair_inference -->|"loads classifier"| node_model_output
node_pair_inference -->|"class probabilities"| node_document_matching
node_container_runtime -->|"runs service"| node_api_entry

click node_requirements_import "https://github.com/harish-k000/jobfit-nlp/blob/main/scripts/import_jobs_csv.py"
click node_split_pipeline "https://github.com/harish-k000/jobfit-nlp/blob/main/scripts/split_dataset.py"
click node_labeled_splits "https://github.com/harish-k000/jobfit-nlp/blob/main/data/train.jsonl"
click node_labeling_guidance "https://github.com/harish-k000/jobfit-nlp/blob/main/docs/labeling_rubric.md"
click node_segmentation "https://github.com/harish-k000/jobfit-nlp/blob/main/model/segmentation.py"
click node_dataset_loader "https://github.com/harish-k000/jobfit-nlp/blob/main/model/dataset.py"
click node_trainer "https://github.com/harish-k000/jobfit-nlp/blob/main/model/train.py"
click node_baselines "https://github.com/harish-k000/jobfit-nlp/blob/main/model/baselines.py"
click node_evaluation "https://github.com/harish-k000/jobfit-nlp/blob/main/model/evaluate.py"
click node_experiment_governance "https://github.com/harish-k000/jobfit-nlp/blob/main/scripts/hparam_search.py"
click node_experiment_artifacts "https://github.com/harish-k000/jobfit-nlp/blob/main/artifacts/evaluation_results.json"
click node_api_entry "https://github.com/harish-k000/jobfit-nlp/blob/main/api/main.py"
click node_api_contract "https://github.com/harish-k000/jobfit-nlp/blob/main/api/schemas.py"
click node_pair_inference "https://github.com/harish-k000/jobfit-nlp/blob/main/api/inference.py"
click node_document_matching "https://github.com/harish-k000/jobfit-nlp/blob/main/api/document_matching.py"
click node_resume_splitter "https://github.com/harish-k000/jobfit-nlp/blob/main/api/resume_splitter.py"
click node_match_documents "https://github.com/harish-k000/jobfit-nlp/blob/main/api/main.py"
click node_container_runtime "https://github.com/harish-k000/jobfit-nlp/blob/main/Dockerfile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_raw_data,node_requirements_import,node_split_pipeline,node_labeled_splits,node_labeling_guidance toneBlue
class node_segmentation,node_dataset_loader,node_trainer,node_baselines,node_evaluation,node_experiment_governance,node_experiment_artifacts toneAmber
class node_api_entry,node_api_contract,node_pair_inference,node_document_matching,node_resume_splitter,node_match_documents toneMint
class node_model_output,node_container_runtime toneRose
```

## Components

### Data & labeling

Leakage-safe sentence-pair dataset creation.

- **Raw source data**: PII-isolated input · May contain PII; not the training contract.
- [Job requirement authoring](https://github.com/harish-k000/jobfit-nlp/blob/main/scripts/import_jobs_csv.py): offline scripts · Imports jobs, selects atomic requirements, and builds labeling queues. · `scripts/import_jobs_csv.py`
- [Leakage-safe split](https://github.com/harish-k000/jobfit-nlp/blob/main/scripts/split_dataset.py): offline script · Splits examples by job_id. · `scripts/split_dataset.py`
- [Labeled JSONL splits](https://github.com/harish-k000/jobfit-nlp/blob/main/data/train.jsonl): training contract · Train, validation, and test sentence-pair data. · `data/train.jsonl`
- [Labeling contract](https://github.com/harish-k000/jobfit-nlp/blob/main/docs/labeling_rubric.md): documentation · Rubric and dataset specification for labels and examples. · `docs/labeling_rubric.md`

### Modeling & experiments

Training, comparison, evaluation, and promotion.

- [Requirement segmentation](https://github.com/harish-k000/jobfit-nlp/blob/main/model/segmentation.py): shared model logic · Extracts atomic requirements for production matching. · `model/segmentation.py`
- [Pair dataset loader](https://github.com/harish-k000/jobfit-nlp/blob/main/model/dataset.py): model module · `model/dataset.py`
- [DistilBERT trainer](https://github.com/harish-k000/jobfit-nlp/blob/main/model/train.py): 3-class classifier · Trains a sequence-pair classifier with PyTorch and Hugging Face Trainer. · `model/train.py`
- [Baseline comparators](https://github.com/harish-k000/jobfit-nlp/blob/main/model/baselines.py): model module · Majority, keyword overlap, and TF-IDF logistic regression. · `model/baselines.py`
- [Evaluation & analysis](https://github.com/harish-k000/jobfit-nlp/blob/main/model/evaluate.py): model module · Produces macro F1, class metrics, confusion analysis, and artifacts. · `model/evaluate.py`
- [Promotion workflows](https://github.com/harish-k000/jobfit-nlp/blob/main/scripts/hparam_search.py): experiment scripts · Validation-selected hyperparameters and multi-seed baseline gate. · `scripts/hparam_search.py`
- [Experiment records](https://github.com/harish-k000/jobfit-nlp/blob/main/artifacts/evaluation_results.json): evaluation artifacts · Records baseline, evaluation, tuning, and seed outcomes. · `artifacts/evaluation_results.json`

### API serving

FastAPI document and pair matching flow.

- [FastAPI application](https://github.com/harish-k000/jobfit-nlp/blob/main/api/main.py): service entry point · Hosts versioned matching endpoints. · `api/main.py`
- [Request schemas & dependencies](https://github.com/harish-k000/jobfit-nlp/blob/main/api/schemas.py): API boundary · `api/schemas.py`
- [Pair inference](https://github.com/harish-k000/jobfit-nlp/blob/main/api/inference.py): API inference layer · Runs single and batch classifier scoring. · `api/inference.py`
- [Document matcher](https://github.com/harish-k000/jobfit-nlp/blob/main/api/document_matching.py): orchestrator · Bounds, scores, ranks, and aggregates requirement evidence. · `api/document_matching.py`
- [Resume bullet extraction](https://github.com/harish-k000/jobfit-nlp/blob/main/api/resume_splitter.py): local parser · In-process resume preprocessing. · `api/resume_splitter.py`
- [POST match-documents](https://github.com/harish-k000/jobfit-nlp/blob/main/api/main.py): document endpoint · Returns ranked evidence and coverage by requirement. · `api/main.py`

### Runtime packaging

- **Local model output**: trained model/tokenizer · Local convention loaded by inference.
- [Containerized service](https://github.com/harish-k000/jobfit-nlp/blob/main/Dockerfile): deployment · Docker packaging with local compose orchestration. · `Dockerfile`

## Connections

- Raw source data → Job requirement authoring: source jobs
- Job requirement authoring → Leakage-safe split: labeled candidate pairs
- Labeling contract → Leakage-safe split: labeling rules
- Leakage-safe split → Labeled JSONL splits: job_id-separated splits
- Labeled JSONL splits → Pair dataset loader: examples
- Pair dataset loader → DistilBERT trainer: train/validation data
- Labeled JSONL splits → Baseline comparators: benchmark data
- DistilBERT trainer → Local model output: trained weights/tokenizer
- DistilBERT trainer → Evaluation & analysis: transformer predictions
- Baseline comparators → Evaluation & analysis: baseline predictions
- Evaluation & analysis → Experiment records: metrics and errors
- Promotion workflows → DistilBERT trainer: tuned training runs
- Experiment records → Promotion workflows: validation results
- FastAPI application → Request schemas & dependencies: validates requests
- FastAPI application → POST match-documents: routes request
- POST match-documents → Document matcher: document payload
- Document matcher → Requirement segmentation: extract requirements
- Document matcher → Resume bullet extraction: extract bullets
- Document matcher → Pair inference: up to 500 pairs
- Pair inference → Local model output: loads classifier
- Pair inference → Document matcher: class probabilities
- Containerized service → FastAPI application: runs service
