# pr4vndevhubx/rolescout architecture

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

- Interactive diagram: https://gitdiagram.com/pr4vndevhubx/rolescout
- Repository: https://github.com/pr4vndevhubx/rolescout

## Overview

#### Purpose and entry points
rolescout is an agentic job-search assistant: it ingests job listings, compares them with a user resume, prepares truthful tailored materials, tracks applications, and sends daily digests. The backend starts as a FastAPI service at `app/main.py`; its REST surface is organized in `app/api/`. The React/Vite dashboard starts from `frontend/src/main.tsx` and composes the UI in `frontend/src/App.tsx`.

#### API, identity, and persistence boundary
Authenticated API routes expose resumes, jobs, matching, tailoring, preferences, applications, and assistant execution. JWT/password security, database initialization, middleware, and scheduling are centralized in `app/core/`, while persisted domain entities are defined in `app/models/db_models.py`. Alembic owns schema evolution under `alembic/versions/`, including ATS and job-experience fields. Postgres/Neon is the system of record; pgvector setup supports vector search.

#### Resume ingestion and user profile pipeline
Resume upload and processing are handled through `app/api/resumes.py`, backed by extraction, parsing, normalization, storage, and repository services. The pipeline accepts uploaded resume files, extracts text (with document-format handling), derives structured resume data through an LLM, builds canonical text, and generates embeddings. Relevant boundaries are `app/services/text_extraction.py`, `app/services/resume_parser.py`, and `app/services/embedding_service.py`; raw resume files are PII and are separated through `app/services/file_storage.py`.

#### Job scouting and canonical ingestion
The ingestion service searches registered external boards, normalizes source-specific payloads, extracts experience requirements, deduplicates listings, and persists/embed new jobs. Its primary coordinator is `app/services/job_ingestion.py`; source adapters are behind the source abstraction and registry at `app/services/job_sources/base.py` and `app/services/job_sources/registry.py`. Current integrations include Remotive, Arbeitnow, and optional Adzuna, implemented in `app/services/job_sources/remotive_source.py`, `app/services/job_sources/arbeitnow_source.py`, and `app/services/job_sources/adzuna_source.py`.

#### Matching, ranking, and gap analysis
Matching retrieves semantically close jobs through pgvector, applies user/job hard constraints, calculates skill overlap and blended ranking, then stores candidate match records. The matching stage is decomposed into retrieval (`app/services/matching/retrieval.py`), deterministic filters (`app/services/matching/hard_filters.py`), and ranking (`app/services/matching/ranker.py`). Job vectors are managed by `app/services/matching/job_vector_store.py`; skill extraction/gap analysis live in `app/services/matching/job_skill_extractor.py` and `app/services/matching/skill_gap.py`. ATS-oriented scoring is isolated in `app/services/ats/ats_scorer.py`.

#### AI provider and truthful tailoring boundary
All LLM work uses a provider-neutral router with fast/smart task tiers and provider failover. The abstraction and routing layer are `app/ai/llm/base.py`, `app/ai/llm/router.py`, and `app/ai/llm/registry.py`; OpenAI-compatible endpoints support configured providers/local models through `app/ai/llm/providers/openai_compatible.py`. Tailoring and cover-letter generation use `app/services/tailoring_service.py` and prompts in `app/ai/prompts/tailoring_prompts.py`; this is the key truthfulness boundary, intended to constrain output to resume-supported facts and identify unmet requirements as gaps.

#### Agent execution and daily control flow
The assistant has two paths over the same service layer: interactive chat and deterministic daily execution. The LangGraph-style orchestrator and tool wrappers are in `app/agent/orchestrator.py` and `app/agent/tools.py`; agent state/context is held in `app/agent/context.py`. The scheduled cycle in `app/agent/daily_cycle.py` performs scout → evaluate/classify → capped tailoring → application preparation → notification. Scheduler integration is centralized in `app/core/scheduler.py`, while email/digest delivery and deduplication are handled by `app/services/notification_service.py`. Agent runs/actions provide the shared audit trail for chat, cron, and manual runs.

#### Dashboard and external infrastructure
The frontend is a client for the authenticated API, with feature panels for jobs, matches, uploads, preferences, and assistant activity under `frontend/src/components/`. It communicates through `frontend/src/api.ts`. Material external dependencies are Neon/Postgres with pgvector, local `sentence-transformers` embeddings, configurable LLM providers (including Ollama), job-board APIs, optional SMTP, and optional Tesseract OCR.

Main entry points: [`app/agent/daily_cycle.py`](https://github.com/pr4vndevhubx/rolescout/blob/main/app/agent/daily_cycle.py) (Daily execution cycle), [`app/api/resumes.py`](https://github.com/pr4vndevhubx/rolescout/blob/main/app/api/resumes.py) (Resume processing), [`app/services/job_ingestion.py`](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/job_ingestion.py) (Job ingestion), [`app/services/matching/retrieval.py`](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/matching/retrieval.py) (Match pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Dashboard"]
  node_dashboard["React dashboard<br/>Vite client<br/>[App.tsx]"]
  node_api_client["Authenticated API client<br/>frontend transport<br/>[api.ts]"]
end

subgraph group_api["API &amp; Core"]
  node_fastapi["FastAPI service<br/>backend entry point<br/>[main.py]"]
  node_routes["REST route surface<br/>API routes"]
  node_security_scheduler["Identity &amp; scheduler<br/>core services"]
  node_domain_models["Domain models<br/>persistence model<br/>[db_models.py]"]
end

subgraph group_pipeline["Job &amp; Resume Intelligence"]
  node_resume_pipeline["Resume processing<br/>ingestion pipeline<br/>[resumes.py]"]
  node_resume_parser["Resume parser<br/>LLM structuring<br/>[resume_parser.py]"]
  node_file_storage[("PII file storage<br/>raw file boundary<br/>[file_storage.py]")]
  node_job_ingestion["Job ingestion<br/>scouting coordinator<br/>[job_ingestion.py]"]
  node_source_registry["Job source registry<br/>adapter boundary<br/>[registry.py]"]
  node_matching["Match pipeline<br/>retrieval and ranking<br/>[retrieval.py]"]
  node_ranker["Ranking &amp; skill gaps<br/>match evaluation<br/>[ranker.py]"]
end

subgraph group_ai["AI &amp; Agent"]
  node_llm_router["LLM router<br/>provider-neutral AI<br/>[router.py]"]
  node_tailoring["Truthful tailoring<br/>generation boundary"]
  node_orchestrator["Assistant orchestrator<br/>agent workflow<br/>[orchestrator.py]"]
  node_daily_cycle["Daily execution cycle<br/>deterministic workflow<br/>[daily_cycle.py]"]
end

subgraph group_data["Data &amp; External Systems"]
  node_postgres[("Neon Postgres + pgvector<br/>system of record")]
  node_job_boards{{"Job-board APIs<br/>external sources"}}
  node_llm_providers{{"LLM providers<br/>external AI"}}
  node_notifications["Digest delivery<br/>notification service"]
end

node_dashboard -->|"uses"| node_api_client
node_api_client -->|"authenticated requests"| node_fastapi
node_fastapi -->|"mounts"| node_routes
node_fastapi -->|"initializes"| node_security_scheduler
node_routes -->|"resume uploads"| node_resume_pipeline
node_routes -->|"job operations"| node_job_ingestion
node_routes -->|"match requests"| node_matching
node_routes -->|"tailoring requests"| node_tailoring
node_routes -->|"assistant execution"| node_orchestrator
node_resume_pipeline -->|"stores raw files"| node_file_storage
node_resume_pipeline -->|"structures extracted text"| node_resume_parser
node_resume_parser -->|"structured extraction"| node_llm_router
node_resume_pipeline -->|"stores profile and vectors"| node_postgres
node_job_ingestion -->|"selects adapters"| node_source_registry
node_source_registry -->|"fetches listings"| node_job_boards
node_job_ingestion -->|"persists jobs and embeddings"| node_postgres
node_matching -->|"pgvector retrieval and match records"| node_postgres
node_matching -->|"candidate evaluation"| node_ranker
node_tailoring -->|"constrained generation"| node_llm_router
node_llm_router -->|"routes requests"| node_llm_providers
node_security_scheduler -->|"scheduled trigger"| node_daily_cycle
node_daily_cycle -->|"scout"| node_job_ingestion
node_daily_cycle -->|"evaluate"| node_matching
node_daily_cycle -->|"capped tailoring"| node_tailoring
node_daily_cycle -->|"send digest"| node_notifications
node_orchestrator -->|"run and action audit trail"| node_postgres
node_notifications -->|"delivery deduplication"| node_postgres

click node_dashboard "https://github.com/pr4vndevhubx/rolescout/blob/main/frontend/src/App.tsx"
click node_api_client "https://github.com/pr4vndevhubx/rolescout/blob/main/frontend/src/api.ts"
click node_fastapi "https://github.com/pr4vndevhubx/rolescout/blob/main/app/main.py"
click node_domain_models "https://github.com/pr4vndevhubx/rolescout/blob/main/app/models/db_models.py"
click node_resume_pipeline "https://github.com/pr4vndevhubx/rolescout/blob/main/app/api/resumes.py"
click node_resume_parser "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/resume_parser.py"
click node_file_storage "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/file_storage.py"
click node_job_ingestion "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/job_ingestion.py"
click node_source_registry "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/job_sources/registry.py"
click node_matching "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/matching/retrieval.py"
click node_ranker "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/matching/ranker.py"
click node_llm_router "https://github.com/pr4vndevhubx/rolescout/blob/main/app/ai/llm/router.py"
click node_tailoring "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/tailoring_service.py"
click node_orchestrator "https://github.com/pr4vndevhubx/rolescout/blob/main/app/agent/orchestrator.py"
click node_daily_cycle "https://github.com/pr4vndevhubx/rolescout/blob/main/app/agent/daily_cycle.py"
click node_llm_providers "https://github.com/pr4vndevhubx/rolescout/blob/main/app/ai/llm/providers/openai_compatible.py"
click node_notifications "https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/notification_service.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_dashboard,node_api_client toneBlue
class node_fastapi,node_routes,node_security_scheduler,node_domain_models toneAmber
class node_resume_pipeline,node_resume_parser,node_file_storage,node_job_ingestion,node_source_registry,node_matching,node_ranker toneMint
class node_llm_router,node_tailoring,node_orchestrator,node_daily_cycle toneRose
class node_postgres,node_job_boards,node_llm_providers,node_notifications toneIndigo
```

## Components

### Dashboard

- [React dashboard](https://github.com/pr4vndevhubx/rolescout/blob/main/frontend/src/App.tsx): Vite client · `frontend/src/App.tsx`
- [Authenticated API client](https://github.com/pr4vndevhubx/rolescout/blob/main/frontend/src/api.ts): frontend transport · `frontend/src/api.ts`

### API & Core

- [FastAPI service](https://github.com/pr4vndevhubx/rolescout/blob/main/app/main.py): backend entry point · `app/main.py`
- **REST route surface**: API routes · Resumes, jobs, matches, tailoring, preferences, applications, and assistant execution.
- **Identity & scheduler**: core services · Centralizes JWT/password security, database setup, middleware, and scheduled execution.
- [Domain models](https://github.com/pr4vndevhubx/rolescout/blob/main/app/models/db_models.py): persistence model · `app/models/db_models.py`

### Job & Resume Intelligence

- [Resume processing](https://github.com/pr4vndevhubx/rolescout/blob/main/app/api/resumes.py): ingestion pipeline · Extracts, parses, normalizes, stores, and embeds uploaded resumes. · `app/api/resumes.py`
- [Resume parser](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/resume_parser.py): LLM structuring · `app/services/resume_parser.py`
- [PII file storage](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/file_storage.py): raw file boundary · Separates raw uploaded resume files from domain data. · `app/services/file_storage.py`
- [Job ingestion](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/job_ingestion.py): scouting coordinator · Normalizes, deduplicates, persists, and embeds external listings. · `app/services/job_ingestion.py`
- [Job source registry](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/job_sources/registry.py): adapter boundary · Registers Remotive, Arbeitnow, and optional Adzuna sources. · `app/services/job_sources/registry.py`
- [Match pipeline](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/matching/retrieval.py): retrieval and ranking · Retrieves vector candidates, applies hard constraints, ranks, and stores matches. · `app/services/matching/retrieval.py`
- [Ranking & skill gaps](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/matching/ranker.py): match evaluation · Combines deterministic ranking, skill overlap, gaps, and ATS scoring. · `app/services/matching/ranker.py`

### AI & Agent

- [LLM router](https://github.com/pr4vndevhubx/rolescout/blob/main/app/ai/llm/router.py): provider-neutral AI · Selects fast/smart tiers and fails over across configured providers. · `app/ai/llm/router.py`
- [Truthful tailoring](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/tailoring_service.py): generation boundary · Produces resume-supported tailored materials and flags unmet requirements. · `app/services/tailoring_service.py`
- [Assistant orchestrator](https://github.com/pr4vndevhubx/rolescout/blob/main/app/agent/orchestrator.py): agent workflow · Interactive agent path over shared tools and services. · `app/agent/orchestrator.py`
- [Daily execution cycle](https://github.com/pr4vndevhubx/rolescout/blob/main/app/agent/daily_cycle.py): deterministic workflow · Scouts, evaluates, tailors, prepares applications, and notifies. · `app/agent/daily_cycle.py`

### Data & External Systems

- **Neon Postgres + pgvector**: system of record · Stores domain entities, audit records, and vector-search data.
- **Job-board APIs**: external sources
- [LLM providers](https://github.com/pr4vndevhubx/rolescout/blob/main/app/ai/llm/providers/openai_compatible.py): external AI · OpenAI-compatible providers and local models such as Ollama. · `app/ai/llm/providers/openai_compatible.py`
- [Digest delivery](https://github.com/pr4vndevhubx/rolescout/blob/main/app/services/notification_service.py): notification service · Delivers and deduplicates email digests through optional SMTP. · `app/services/notification_service.py`

## Connections

- React dashboard → Authenticated API client: uses
- Authenticated API client → FastAPI service: authenticated requests
- FastAPI service → REST route surface: mounts
- FastAPI service → Identity & scheduler: initializes
- REST route surface → Resume processing: resume uploads
- REST route surface → Job ingestion: job operations
- REST route surface → Match pipeline: match requests
- REST route surface → Truthful tailoring: tailoring requests
- REST route surface → Assistant orchestrator: assistant execution
- Resume processing → PII file storage: stores raw files
- Resume processing → Resume parser: structures extracted text
- Resume parser → LLM router: structured extraction
- Resume processing → Neon Postgres + pgvector: stores profile and vectors
- Job ingestion → Job source registry: selects adapters
- Job source registry → Job-board APIs: fetches listings
- Job ingestion → Neon Postgres + pgvector: persists jobs and embeddings
- Match pipeline → Neon Postgres + pgvector: pgvector retrieval and match records
- Match pipeline → Ranking & skill gaps: candidate evaluation
- Truthful tailoring → LLM router: constrained generation
- LLM router → LLM providers: routes requests
- Identity & scheduler → Daily execution cycle: scheduled trigger
- Daily execution cycle → Job ingestion: scout
- Daily execution cycle → Match pipeline: evaluate
- Daily execution cycle → Truthful tailoring: capped tailoring
- Daily execution cycle → Digest delivery: send digest
- Assistant orchestrator → Neon Postgres + pgvector: run and action audit trail
- Digest delivery → Neon Postgres + pgvector: delivery deduplication
