# hanshikasahu/redrob-talentmatchai architecture

> Architecture diagram of the GitHub repository hanshikasahu/redrob-talentmatchai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/hanshikasahu/redrob-talentmatchai
- Repository: https://github.com/hanshikasahu/redrob-talentmatchai

## Overview

#### Purpose and Entry Points
TalentMatchAI is an offline Python candidate-ranking pipeline for a Senior AI Engineer role. It is designed to rank a large candidate dataset under a CPU-only, five-minute online-ranking constraint.

Primary entry points:
- `precompute.py` — offline survivor filtering and embedding generation.
- `rank.py` — online ranking and CSV submission generation.
- `validate_submission.py` — validates the produced submission format.

#### Input, Output, and Contract Boundary
The pipeline consumes a candidate dataset (described as `candidates.jsonl`, not committed) plus role requirements embedded or read by the ranking logic. Candidate shape is documented by `candidate_schema.json`.

Primary output is a ranked CSV, represented in the repo by `submission.csv` and `Edward.csv`. Submission requirements and metadata are captured in `submission_spec.docx` and `submission_metadata.yaml`.

#### Offline Precomputation Stage
`precompute.py` is the expensive, one-time stage. It streams the candidate dataset rather than loading all records at once, applies hard disqualification rules, and encodes surviving career histories with Sentence Transformers.

Its architectural purpose is to move model inference outside the constrained ranking window. Generated artifacts—embeddings, survivor IDs, and survivor profiles—are intentionally excluded from source control and become the interface consumed by `rank.py`.

Grounding paths:
- `precompute.py`
- `candidate_schema.json`
- `.gitignore`

#### Hard Eligibility Gate
Before semantic scoring, the system removes candidates who appear to have only consulting-company experience or who have been inactive for six or more months. This is a major control-flow boundary: rejected candidates never enter embedding generation or downstream scoring.

The gate reduces the candidate population and protects the online stage from unnecessary compute. Its rules are part of the ranking design rather than a separate service.

Grounding paths:
- `precompute.py`
- `rank.py`

#### Semantic Relevance Layer
Career-history text, rather than candidate skill lists alone, is represented as embeddings using the `all-MiniLM-L6-v2` Sentence Transformers model. `rank.py` compares survivor embeddings against the job-description embedding using cosine similarity.

Candidates below a semantic-similarity threshold are zeroed, creating a second relevance boundary after hard eligibility. Embedding computation is offline; similarity evaluation is online.

Grounding paths:
- `precompute.py`
- `rank.py`
- `requirements.txt`

#### Composite Ranking and Penalties
`rank.py` combines semantic similarity with structured recruiter-style signals: experience quality, behavioral availability, verification/assessment evidence, and role-specific nice-to-haves. It then applies title-relevance and job-hopping penalties before ordering candidates and writing the submission.

This stage owns final score formation and deterministic rank ordering; it should load precomputed artifacts directly and avoid rereading the full raw candidate dataset during normal ranking.

Grounding paths:
- `rank.py`
- `submission.csv`

#### Runtime and Dependencies
The system is a local Python 3.13, CPU-only batch workflow. Key libraries are Sentence Transformers for embeddings and NumPy/scikit-learn for vector and scoring operations. There is no indicated web service, database, GPU dependency, or external runtime infrastructure.

Exploration and score-development work is separated from production execution in:
- `notebooks/explore.ipynb`
- `notebooks/top500_final.json`

#### Validation and Delivery Flow
The expected operational sequence is: run offline precompute, run online ranking to create a CSV, then validate the CSV against submission expectations. Validation is a final delivery boundary rather than part of scoring.

Grounding paths:
- `precompute.py`
- `rank.py`
- `validate_submission.py`

Main entry points: [`precompute.py`](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/precompute.py) (Hard eligibility gate), [`.gitignore`](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/.gitignore) (Survivor artifacts), [`requirements.txt`](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/requirements.txt) (MiniLM embeddings), [`rank.py`](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py) (Ranking entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_offline["Offline precompute"]
  node_precompute["Precompute entry point<br/>Python batch job<br/>[precompute.py]"]
  node_eligibility_gate{{"Hard eligibility gate<br/>filter rules<br/>[precompute.py]"}}
  node_embedding_model["MiniLM embeddings<br/>Sentence Transformers<br/>[requirements.txt]"]
  node_survivor_artifacts[("Survivor artifacts<br/>generated files<br/>[.gitignore]")]
end

subgraph group_online["Online ranking"]
  node_rank["Ranking entry point<br/>Python batch job<br/>[rank.py]"]
  node_semantic_scoring{{"Semantic relevance<br/>cosine scoring<br/>[rank.py]"}}
  node_composite_scoring["Composite scoring<br/>ranking logic<br/>[rank.py]"]
end

subgraph group_delivery["Delivery"]
  node_submission_csv["Ranked submission<br/>CSV output<br/>[submission.csv]"]
  node_validator["Submission validator<br/>Python validation job"]
end

node_candidate_data["Candidate dataset<br/>JSONL input"]
node_candidate_schema["Candidate schema<br/>schema contract"]
node_exploration["Score exploration<br/>notebook workflow<br/>[explore.ipynb]"]
node_top500_reference["Top-500 reference<br/>analysis output<br/>[top500_final.json]"]

node_candidate_schema -.->|"defines records"| node_precompute
node_candidate_data -->|"streamed input"| node_precompute
node_precompute -->|"applies"| node_eligibility_gate
node_eligibility_gate -->|"eligible histories"| node_embedding_model
node_embedding_model -->|"writes vectors"| node_survivor_artifacts
node_eligibility_gate -->|"writes IDs and profiles"| node_survivor_artifacts
node_survivor_artifacts -->|"loads"| node_rank
node_rank -->|"computes similarity"| node_semantic_scoring
node_semantic_scoring -->|"thresholded relevance"| node_composite_scoring
node_composite_scoring -->|"orders and writes"| node_submission_csv
node_submission_csv -->|"validates"| node_validator
node_exploration -.->|"produces"| node_top500_reference

click node_candidate_schema "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/candidate_schema.json"
click node_precompute "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/precompute.py"
click node_eligibility_gate "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/precompute.py"
click node_embedding_model "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/requirements.txt"
click node_survivor_artifacts "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/.gitignore"
click node_rank "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py"
click node_semantic_scoring "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py"
click node_composite_scoring "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py"
click node_submission_csv "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/submission.csv"
click node_validator "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/validate_submission.py"
click node_exploration "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/notebooks/explore.ipynb"
click node_top500_reference "https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/notebooks/top500_final.json"

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_precompute,node_eligibility_gate,node_embedding_model,node_survivor_artifacts toneBlue
class node_rank,node_semantic_scoring,node_composite_scoring toneAmber
class node_submission_csv,node_validator toneMint
class node_candidate_data,node_candidate_schema,node_exploration,node_top500_reference toneNeutral
```

## Components

### Offline precompute

One-time CPU-heavy survivor and embedding preparation.

- [Precompute entry point](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/precompute.py): Python batch job · Streams records and produces reusable survivor artifacts. · `precompute.py`
- [Hard eligibility gate](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/precompute.py): filter rules · Excludes consulting-only and inactive candidates before inference. · `precompute.py`
- [MiniLM embeddings](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/requirements.txt): Sentence Transformers · all-MiniLM-L6-v2 represents career histories. · `requirements.txt`
- [Survivor artifacts](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/.gitignore): generated files · Embeddings, survivor IDs, and profiles excluded from source control. · `.gitignore`

### Online ranking

CPU-bound ranking path constrained to five minutes.

- [Ranking entry point](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py): Python batch job · Loads precomputed artifacts without rereading the full dataset. · `rank.py`
- [Semantic relevance](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py): cosine scoring · Compares survivor vectors with the job-description embedding and zeroes low matches. · `rank.py`
- [Composite scoring](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/rank.py): ranking logic · Combines recruiter signals and applies title and job-hopping penalties. · `rank.py`

### Delivery

Submission creation and format validation.

- [Ranked submission](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/submission.csv): CSV output · `submission.csv`
- [Submission validator](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/validate_submission.py): Python validation job · Final format and delivery boundary. · `validate_submission.py`

### Other components

- **Candidate dataset**: JSONL input · Uncommitted candidate records streamed by precompute.
- [Candidate schema](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/candidate_schema.json): schema contract · `candidate_schema.json`
- [Score exploration](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/notebooks/explore.ipynb): notebook workflow · Separate score-development work from production execution. · `notebooks/explore.ipynb`
- [Top-500 reference](https://github.com/hanshikasahu/redrob-talentmatchai/blob/main/notebooks/top500_final.json): analysis output · `notebooks/top500_final.json`

## Connections

- Candidate schema → Precompute entry point: defines records
- Candidate dataset → Precompute entry point: streamed input
- Precompute entry point → Hard eligibility gate: applies
- Hard eligibility gate → MiniLM embeddings: eligible histories
- MiniLM embeddings → Survivor artifacts: writes vectors
- Hard eligibility gate → Survivor artifacts: writes IDs and profiles
- Survivor artifacts → Ranking entry point: loads
- Ranking entry point → Semantic relevance: computes similarity
- Semantic relevance → Composite scoring: thresholded relevance
- Composite scoring → Ranked submission: orders and writes
- Ranked submission → Submission validator: validates
- Score exploration → Top-500 reference: produces
