# sowmya-bh/aijobboard architecture

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

- Interactive diagram: https://gitdiagram.com/sowmya-bh/aijobboard
- Repository: https://github.com/sowmya-bh/aijobboard

## Overview

#### Purpose and Entry Points
Job Scout is a FastAPI-hosted AI job-matching and résumé workflow. The backend serves an auth-gated vanilla HTML/JS client and coordinates search, ATS scoring, and LLM-generated application materials. Primary runtime entry points are `server.py` (FastAPI routes) and `run.py`; deployment uses `render.yaml` with Uvicorn. The separate heavyweight scorer deploys from `scorer_service/app.py`.

#### Stateful Agent Workflow
LangGraph implements the primary user workflow in `agent/graph.py`, with node behavior in `agent/nodes.py` and session state in `agent/state.py`. The graph runs résumé parsing/scouting and matching, interrupts for job selection, calls ATS scoring, then interrupts again for user-selected follow-up actions (re-score, cover letter, interview questions, tailored résumé, or chat). Checkpointed state carries the selected job, résumé, results, and per-session LLM credentials.

#### Job Search and Matching Boundary
MongoDB is the source of truth for jobs, filters, facets, and market analytics through `agent/db.py`. Search first uses Qdrant semantic ranking plus a Hugging Face-hosted Sentence-BERT embedding endpoint in `agent/vectors.py`; if that dependency set is absent or fails, `agent/matcher.py` performs local skill-overlap ranking. This keeps model inference and vector storage outside the app process.

#### ATS Scoring Boundary
ATS/HR scoring is isolated behind `agent/rq_tools.py`, which calls a remote ResumeHQ scorer rather than importing torch/SBERT into the API service. The scorer’s deployable service is `scorer_service/app.py`, with its own dependencies in `scorer_service/requirements.txt`. Errors remain explicit at this boundary rather than producing fabricated scores.

#### Identity, User Data, and Secrets
JWT authentication and bcrypt password handling live in `agent/auth.py`. User profiles, saved jobs, and encrypted BYO LLM keys are persisted in MongoDB via `agent/userstore.py`; Fernet encryption is implemented in `agent/crypto.py`. Credentials are decrypted only for graph execution and are not returned to clients.

#### LLM and Safety Layer
`agent/llm_user.py` adapts user-provided OpenAI, Anthropic, Groq, or OpenAI-compatible endpoints for generation. `agent/llm.py` supplies server-side Gemini for résumé parsing and fallback chat. Input sanitization and secret-redaction controls are in `agent/guardrails.py`; optional LangSmith instrumentation is isolated in `agent/trace.py`.

#### Data and Deployment Model
Offline ingestion deliberately separates large data/model workloads from the serving image: `data/build_mongo.py` loads jobs into MongoDB; `data/build_embeddings.py` locally generates vectors and upserts Qdrant; `data/build_canonical_skills.py` enriches skills using spaCy/Gensim. Production requires MongoDB Atlas and optionally Qdrant Cloud, Hugging Face Inference, a Hugging Face Gradio/ZeroGPU scorer, Gemini, and LangSmith. `Dockerfile` is relevant to scorer/container deployment, while Render’s Python runtime keeps the main FastAPI image lightweight.

Main entry points: [`agent/nodes.py`](https://github.com/sowmya-bh/aijobboard/blob/main/agent/nodes.py) (Workflow nodes), [`server.py`](https://github.com/sowmya-bh/aijobboard/blob/main/server.py) (FastAPI server), [`agent/graph.py`](https://github.com/sowmya-bh/aijobboard/blob/main/agent/graph.py) (LangGraph workflow), [`agent/matcher.py`](https://github.com/sowmya-bh/aijobboard/blob/main/agent/matcher.py) (Search and matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["Main API"]
  node_server["FastAPI server<br/>API runtime<br/>[server.py]"]
  node_auth["JWT authentication<br/>identity module<br/>[auth.py]"]
  node_userstore["User store<br/>profile repository<br/>[userstore.py]"]
  node_crypto["Fernet crypto<br/>secret encryption<br/>[crypto.py]"]
end

subgraph group_workflow["Agent workflow"]
  node_graph{{"LangGraph workflow<br/>stateful orchestrator<br/>[graph.py]"}}
  node_nodes["Workflow nodes<br/>agent actions<br/>[nodes.py]"]
  node_state["Session state<br/>checkpointed state<br/>[state.py]"]
  node_search["Search and matching<br/>ranking boundary<br/>[matcher.py]"]
  node_vectors["Vector search<br/>semantic retrieval<br/>[vectors.py]"]
  node_ats["ATS scorer client<br/>remote scorer adapter<br/>[rq_tools.py]"]
  node_llmuser["User LLM adapter<br/>multi-provider generation<br/>[llm_user.py]"]
  node_llm["Gemini adapter<br/>server LLM<br/>[llm.py]"]
  node_guardrails["Guardrails<br/>safety controls<br/>[guardrails.py]"]
end

subgraph group_data["Offline data pipeline"]
  node_ingest["Job ingestion<br/>offline loader<br/>[build_mongo.py]"]
  node_embeddings["Embedding build<br/>offline vector loader"]
  node_skills["Skill enrichment<br/>offline enrichment"]
end

subgraph group_external["Managed services"]
  node_mongodb[("MongoDB Atlas<br/>primary datastore")]
  node_qdrant[("Qdrant Cloud<br/>vector database")]
  node_inference["HF embedding endpoint<br/>embedding inference"]
  node_scorer["ResumeHQ scorer<br/>scoring service<br/>[app.py]"]
end

node_server -->|"authenticates"| node_auth
node_server -->|"profiles and saved jobs"| node_userstore
node_userstore -->|"encrypts stored keys"| node_crypto
node_server -->|"starts session"| node_graph
node_graph -->|"executes"| node_nodes
node_graph -->|"checkpoints"| node_state
node_nodes -->|"finds jobs"| node_search
node_search -->|"semantic ranking"| node_vectors
node_vectors -->|"queries vectors"| node_qdrant
node_vectors -->|"creates query embeddings"| node_inference
node_search -->|"jobs, filters, analytics"| node_mongodb
node_nodes -->|"requests ATS score"| node_ats
node_ats -->|"remote scoring"| node_scorer
node_nodes -->|"generates user-requested materials"| node_llmuser
node_nodes -->|"parsing and fallback chat"| node_llm
node_nodes -->|"sanitizes and redacts"| node_guardrails
node_ingest -->|"loads jobs"| node_mongodb
node_skills -->|"enriches skills"| node_ingest
node_embeddings -->|"upserts vectors"| node_qdrant
node_embeddings -.->|"separate from serving"| node_inference

click node_server "https://github.com/sowmya-bh/aijobboard/blob/main/server.py"
click node_auth "https://github.com/sowmya-bh/aijobboard/blob/main/agent/auth.py"
click node_userstore "https://github.com/sowmya-bh/aijobboard/blob/main/agent/userstore.py"
click node_crypto "https://github.com/sowmya-bh/aijobboard/blob/main/agent/crypto.py"
click node_graph "https://github.com/sowmya-bh/aijobboard/blob/main/agent/graph.py"
click node_nodes "https://github.com/sowmya-bh/aijobboard/blob/main/agent/nodes.py"
click node_state "https://github.com/sowmya-bh/aijobboard/blob/main/agent/state.py"
click node_search "https://github.com/sowmya-bh/aijobboard/blob/main/agent/matcher.py"
click node_vectors "https://github.com/sowmya-bh/aijobboard/blob/main/agent/vectors.py"
click node_ats "https://github.com/sowmya-bh/aijobboard/blob/main/agent/rq_tools.py"
click node_llmuser "https://github.com/sowmya-bh/aijobboard/blob/main/agent/llm_user.py"
click node_llm "https://github.com/sowmya-bh/aijobboard/blob/main/agent/llm.py"
click node_guardrails "https://github.com/sowmya-bh/aijobboard/blob/main/agent/guardrails.py"
click node_scorer "https://github.com/sowmya-bh/aijobboard/blob/main/scorer_service/app.py"
click node_ingest "https://github.com/sowmya-bh/aijobboard/blob/main/data/build_mongo.py"
click node_embeddings "https://github.com/sowmya-bh/aijobboard/blob/main/data/build_embeddings.py"
click node_skills "https://github.com/sowmya-bh/aijobboard/blob/main/data/build_canonical_skills.py"

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_server,node_auth,node_userstore,node_crypto toneBlue
class node_graph,node_nodes,node_state,node_search,node_vectors,node_ats,node_llmuser,node_llm,node_guardrails toneAmber
class node_ingest,node_embeddings,node_skills toneMint
class node_mongodb,node_qdrant,node_inference,node_scorer toneRose
```

## Components

### Main API

Lightweight FastAPI serving runtime.

- [FastAPI server](https://github.com/sowmya-bh/aijobboard/blob/main/server.py): API runtime · Auth-gated routes serve the vanilla client and invoke workflows. · `server.py`
- [JWT authentication](https://github.com/sowmya-bh/aijobboard/blob/main/agent/auth.py): identity module · `agent/auth.py`
- [User store](https://github.com/sowmya-bh/aijobboard/blob/main/agent/userstore.py): profile repository · Persists profiles, saved jobs, and encrypted user LLM keys. · `agent/userstore.py`
- [Fernet crypto](https://github.com/sowmya-bh/aijobboard/blob/main/agent/crypto.py): secret encryption · Decrypts user credentials only for graph execution. · `agent/crypto.py`

### Agent workflow

Checkpointed, interrupt-driven job application flow.

- [LangGraph workflow](https://github.com/sowmya-bh/aijobboard/blob/main/agent/graph.py): stateful orchestrator · Pauses for job selection and follow-up application actions. · `agent/graph.py`
- [Workflow nodes](https://github.com/sowmya-bh/aijobboard/blob/main/agent/nodes.py): agent actions · Runs parsing, scouting, matching, scoring, and generation actions. · `agent/nodes.py`
- [Session state](https://github.com/sowmya-bh/aijobboard/blob/main/agent/state.py): checkpointed state · Carries résumé, selected job, results, and per-session credentials. · `agent/state.py`
- [Search and matching](https://github.com/sowmya-bh/aijobboard/blob/main/agent/matcher.py): ranking boundary · Uses semantic ranking, with local skill-overlap fallback. · `agent/matcher.py`
- [Vector search](https://github.com/sowmya-bh/aijobboard/blob/main/agent/vectors.py): semantic retrieval · Queries Qdrant and Hugging Face embeddings. · `agent/vectors.py`
- [ATS scorer client](https://github.com/sowmya-bh/aijobboard/blob/main/agent/rq_tools.py): remote scorer adapter · Keeps heavyweight scoring outside the API process. · `agent/rq_tools.py`
- [User LLM adapter](https://github.com/sowmya-bh/aijobboard/blob/main/agent/llm_user.py): multi-provider generation · `agent/llm_user.py`
- [Gemini adapter](https://github.com/sowmya-bh/aijobboard/blob/main/agent/llm.py): server LLM · Provides résumé parsing and fallback chat. · `agent/llm.py`
- [Guardrails](https://github.com/sowmya-bh/aijobboard/blob/main/agent/guardrails.py): safety controls · Sanitizes input and redacts secrets. · `agent/guardrails.py`

### Offline data pipeline

Builds production search data outside the serving image.

- [Job ingestion](https://github.com/sowmya-bh/aijobboard/blob/main/data/build_mongo.py): offline loader · Loads job records into MongoDB. · `data/build_mongo.py`
- [Embedding build](https://github.com/sowmya-bh/aijobboard/blob/main/data/build_embeddings.py): offline vector loader · Generates vectors locally and upserts Qdrant. · `data/build_embeddings.py`
- [Skill enrichment](https://github.com/sowmya-bh/aijobboard/blob/main/data/build_canonical_skills.py): offline enrichment · Builds canonical skills with spaCy and Gensim. · `data/build_canonical_skills.py`

### Managed services

External inference, storage, and observability boundaries.

- **MongoDB Atlas**: primary datastore · Source of truth for jobs, analytics, users, and saved data.
- **Qdrant Cloud**: vector database
- **HF embedding endpoint**: embedding inference
- [ResumeHQ scorer](https://github.com/sowmya-bh/aijobboard/blob/main/scorer_service/app.py): scoring service · Separately deployable heavyweight ATS/HR scoring runtime. · `scorer_service/app.py`

## Connections

- FastAPI server → JWT authentication: authenticates
- FastAPI server → User store: profiles and saved jobs
- User store → Fernet crypto: encrypts stored keys
- FastAPI server → LangGraph workflow: starts session
- LangGraph workflow → Workflow nodes: executes
- LangGraph workflow → Session state: checkpoints
- Workflow nodes → Search and matching: finds jobs
- Search and matching → Vector search: semantic ranking
- Vector search → Qdrant Cloud: queries vectors
- Vector search → HF embedding endpoint: creates query embeddings
- Search and matching → MongoDB Atlas: jobs, filters, analytics
- Workflow nodes → ATS scorer client: requests ATS score
- ATS scorer client → ResumeHQ scorer: remote scoring
- Workflow nodes → User LLM adapter: generates user-requested materials
- Workflow nodes → Gemini adapter: parsing and fallback chat
- Workflow nodes → Guardrails: sanitizes and redacts
- Job ingestion → MongoDB Atlas: loads jobs
- Skill enrichment → Job ingestion: enriches skills
- Embedding build → Qdrant Cloud: upserts vectors
- Embedding build → HF embedding endpoint: separate from serving
