# xiaolang-d3/careerloop architecture

> Architecture diagram of the GitHub repository xiaolang-d3/careerloop, 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/xiaolang-d3/careerloop
- Repository: https://github.com/xiaolang-d3/careerloop

## Overview

#### Purpose and Runtime

CareerLoop is a local-first job-search assistant: it manages candidate materials, evaluates opportunities, generates tailored resume content, and prepares interviews. It runs a React/Vite frontend against a Python 3.11+ FastAPI backend, using SQLite with sqlite-vec and local attachment storage. Model calls use the OpenAI Python SDK through configurable providers. Entry points are `backend/app/main.py` and `frontend/src/main.tsx`; local orchestration is `scripts/dev.sh`.

#### Frontend Application Shell

The React 19 SPA owns navigation, authentication gating, API access, and workspace composition. `frontend/src/AppStyles.tsx` and `frontend/src/components/WorkspaceViews.tsx` establish the primary shell/views; `frontend/src/api/client.ts` is the backend boundary. Major user flows are rendered as dedicated feature workspaces:
- Job evaluation: `frontend/src/features/jobs/JobEvaluationPage.tsx`
- Opportunity discovery: `frontend/src/features/opportunities/OpportunityDiscoveryPage.tsx`
- Interview preparation: `frontend/src/features/interview/InterviewPreparationPage.tsx`
- Agent/model/profile operations: `frontend/src/features/settings/SettingsWorkspace.tsx`

#### HTTP API, Identity, and Persistence Boundary

FastAPI exposes resource endpoints and request/response schemas through `backend/app/api/resources.py` and `backend/app/api/schemas.py`; dependency wiring is in `backend/app/api/dependencies.py`. Local administrator authentication is implemented in `backend/app/auth.py`. Database initialization/lifecycle is separated from domain behavior in `backend/app/database_lifecycle.py` and `backend/app/db.py`. Persistent local data includes SQLite records, vector-backed retrieval, and attachments; attachments are mediated rather than exposed directly via `backend/app/attachments/service.py`.

#### Agent Runtime and Model Integration

The agent subsystem turns user tasks into controlled model/tool executions. `backend/app/agent/runtime.py` owns runtime behavior, `backend/app/agent/orchestration.py` coordinates execution, and `backend/app/agent/operations.py` supports operational visibility/control. Model provider configuration and OpenAI-compatible adaptation sit in `backend/app/agent/settings.py` and `backend/app/models/openai_compatible.py`. Tool invocations and model behavior have explicit observability boundaries in `backend/app/observability/tool_call_audit.py` and `backend/app/observability/model_monitor.py`.

#### Candidate Knowledge and Conversation Context

Candidate information is maintained as structured profile, document, and memory data, providing the grounding layer for later analyses. Core profile service and durable candidate state are in `backend/app/profile/service.py`, `backend/app/profile/candidate_core.py`, and `backend/app/profile/candidate_memory.py`. Resume parsing/versioning are isolated in `backend/app/resume/parser.py` and `backend/app/resume/versions.py`. Chat sessions are persisted and streamed through `backend/app/chat/conversations.py` and `backend/app/chat/service.py`.

#### Opportunity Processing and Workflows

Job inputs enter through import and page-analysis jobs, then become evaluable opportunities and reusable runs. Ingestion stages live in `backend/app/jobs/imports.py`, `backend/app/jobs/import_agent.py`, and `backend/app/jobs/page_ai.py`; matching/evaluation is in `backend/app/jobs/quick_match.py` and `backend/app/jobs/evaluations.py`. Opportunity state and executions are managed by `backend/app/opportunities/service.py` and `backend/app/opportunities/runs.py`. Cross-step work is represented by the workflow engine and stages in `backend/app/workflow/engine.py` and `backend/app/workflow/stages.py`.

#### Grounded AI Capabilities and External Research

The agent accesses focused tools instead of embedding all domain behavior in prompts. Resume-vs-job analysis, tailored content, and interview advice are implemented in `backend/app/tools/analyze_resume_against_jd.py`, `backend/app/tools/generate_tailored_resume_content.py`, and `backend/app/tools/generate_interview_advice.py`. Local retrieval uses `backend/app/tools/search_resume_evidence.py`; public-web/company research crosses the network boundary through `backend/app/research/web.py` and `backend/app/research/company_cache.py`. Privacy operations are centralized in `backend/app/privacy/service.py`.

Main entry points: [`frontend/src/AppStyles.tsx`](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/AppStyles.tsx) (SPA shell), [`backend/app/api/resources.py`](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/api/resources.py) (Resource API), [`backend/app/profile/service.py`](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/profile/service.py) (Candidate knowledge), [`backend/app/agent/runtime.py`](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/agent/runtime.py) (Agent runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_spa_shell["SPA shell<br/>React application<br/>[AppStyles.tsx]"]
  node_api_client["API client<br/>HTTP client<br/>[client.ts]"]
  node_job_ui["Job evaluation<br/>workspace"]
  node_opportunity_ui["Opportunity discovery<br/>workspace"]
  node_interview_ui["Interview preparation<br/>workspace"]
  node_settings_ui["Settings workspace"]
end

subgraph group_api["FastAPI Boundary"]
  node_fastapi{{"FastAPI application<br/>backend entry point<br/>[main.py]"}}
  node_resources["Resource API<br/>routes and schemas<br/>[resources.py]"]
  node_local_auth["Local admin auth<br/>identity service<br/>[auth.py]"]
end

subgraph group_agent["Agent &amp; AI Runtime"]
  node_agent_runtime{{"Agent runtime<br/>execution runtime<br/>[runtime.py]"}}
  node_agent_orchestration["Agent orchestration<br/>execution coordinator<br/>[orchestration.py]"]
  node_model_adapter["OpenAI-compatible models<br/>provider adapter"]
  node_observability["Model and tool audit<br/>observability<br/>[tool_call_audit.py]"]
  node_grounded_tools["Grounded career tools<br/>tool suite"]
end

subgraph group_domain["Candidate &amp; Opportunity Domain"]
  node_candidate_knowledge["Candidate knowledge<br/>profile and memory service<br/>[service.py]"]
  node_resume_pipeline["Resume parsing &amp; versions<br/>resume service<br/>[parser.py]"]
  node_chat["Conversation service<br/>streaming chat<br/>[service.py]"]
  node_opportunity_workflow{{"Opportunity workflows<br/>workflow engine<br/>[engine.py]"}}
  node_job_ingestion["Job ingestion &amp; evaluation<br/>job processing<br/>[imports.py]"]
end

subgraph group_storage["Local Persistence"]
  node_sqlite[("SQLite + vector retrieval<br/>local database<br/>[db.py]")]
  node_attachments["Attachment service<br/>local file storage<br/>[service.py]"]
end

node_dev["Local dev launcher<br/>shell script<br/>[dev.sh]"]

node_dev -->|"starts"| node_spa_shell
node_dev -->|"starts"| node_fastapi
node_spa_shell -->|"uses"| node_api_client
node_spa_shell -->|"renders"| node_job_ui
node_spa_shell -->|"renders"| node_opportunity_ui
node_spa_shell -->|"renders"| node_interview_ui
node_spa_shell -->|"renders"| node_settings_ui
node_api_client -->|"HTTP"| node_fastapi
node_fastapi -->|"routes requests"| node_resources
node_resources -->|"authenticates"| node_local_auth
node_resources -->|"manages"| node_candidate_knowledge
node_resources -->|"serves"| node_chat
node_resources -->|"starts and reads"| node_opportunity_workflow
node_opportunity_workflow -->|"runs stages"| node_job_ingestion
node_opportunity_workflow -->|"delegates AI work"| node_agent_orchestration
node_agent_orchestration -->|"coordinates"| node_agent_runtime
node_agent_runtime -->|"calls models"| node_model_adapter
node_agent_runtime -->|"invokes tools"| node_grounded_tools
node_agent_runtime -->|"audits"| node_observability
node_grounded_tools -->|"grounds on"| node_candidate_knowledge
node_candidate_knowledge -->|"uses resumes"| node_resume_pipeline
node_candidate_knowledge -->|"persists"| node_sqlite
node_job_ingestion -->|"persists opportunities"| node_sqlite
node_chat -->|"persists sessions"| node_sqlite
node_attachments -->|"associates metadata"| node_sqlite
node_candidate_knowledge -->|"accesses documents"| node_attachments

click node_dev "https://github.com/xiaolang-d3/careerloop/blob/main/scripts/dev.sh"
click node_spa_shell "https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/AppStyles.tsx"
click node_api_client "https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/api/client.ts"
click node_job_ui "https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/jobs/JobEvaluationPage.tsx"
click node_opportunity_ui "https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/opportunities/OpportunityDiscoveryPage.tsx"
click node_interview_ui "https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/interview/InterviewPreparationPage.tsx"
click node_settings_ui "https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/settings/SettingsWorkspace.tsx"
click node_fastapi "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/main.py"
click node_resources "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/api/resources.py"
click node_local_auth "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/auth.py"
click node_agent_runtime "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/agent/runtime.py"
click node_agent_orchestration "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/agent/orchestration.py"
click node_model_adapter "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/models/openai_compatible.py"
click node_observability "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/observability/tool_call_audit.py"
click node_candidate_knowledge "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/profile/service.py"
click node_resume_pipeline "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/resume/parser.py"
click node_chat "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/chat/service.py"
click node_opportunity_workflow "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/workflow/engine.py"
click node_job_ingestion "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/jobs/imports.py"
click node_grounded_tools "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/tools/analyze_resume_against_jd.py"
click node_sqlite "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/db.py"
click node_attachments "https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/attachments/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_spa_shell,node_api_client,node_job_ui,node_opportunity_ui,node_interview_ui,node_settings_ui toneBlue
class node_fastapi,node_resources,node_local_auth toneAmber
class node_agent_runtime,node_agent_orchestration,node_model_adapter,node_observability,node_grounded_tools toneMint
class node_candidate_knowledge,node_resume_pipeline,node_chat,node_opportunity_workflow,node_job_ingestion toneRose
class node_sqlite,node_attachments toneIndigo
class node_dev toneNeutral
```

## Components

### React SPA

- [SPA shell](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/AppStyles.tsx): React application · Navigation, auth gating, and workspace composition. · `frontend/src/AppStyles.tsx`
- [API client](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/api/client.ts): HTTP client · `frontend/src/api/client.ts`
- [Job evaluation](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/jobs/JobEvaluationPage.tsx): workspace · `frontend/src/features/jobs/JobEvaluationPage.tsx`
- [Opportunity discovery](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/opportunities/OpportunityDiscoveryPage.tsx): workspace · `frontend/src/features/opportunities/OpportunityDiscoveryPage.tsx`
- [Interview preparation](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/interview/InterviewPreparationPage.tsx): workspace · `frontend/src/features/interview/InterviewPreparationPage.tsx`
- [Settings workspace](https://github.com/xiaolang-d3/careerloop/blob/main/frontend/src/features/settings/SettingsWorkspace.tsx): workspace · `frontend/src/features/settings/SettingsWorkspace.tsx`

### FastAPI Boundary

- [FastAPI application](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/main.py): backend entry point · `backend/app/main.py`
- [Resource API](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/api/resources.py): routes and schemas · Exposes resource endpoints through injected dependencies. · `backend/app/api/resources.py`
- [Local admin auth](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/auth.py): identity service · `backend/app/auth.py`

### Agent & AI Runtime

- [Agent runtime](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/agent/runtime.py): execution runtime · Runs controlled model and tool executions. · `backend/app/agent/runtime.py`
- [Agent orchestration](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/agent/orchestration.py): execution coordinator · `backend/app/agent/orchestration.py`
- [OpenAI-compatible models](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/models/openai_compatible.py): provider adapter · Configurable model-provider boundary using the OpenAI SDK. · `backend/app/models/openai_compatible.py`
- [Model and tool audit](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/observability/tool_call_audit.py): observability · `backend/app/observability/tool_call_audit.py`
- [Grounded career tools](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/tools/analyze_resume_against_jd.py): tool suite · Analysis, tailoring, interview advice, retrieval, and web research. · `backend/app/tools/analyze_resume_against_jd.py`

### Candidate & Opportunity Domain

- [Candidate knowledge](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/profile/service.py): profile and memory service · Structured candidate profile, documents, and durable memory. · `backend/app/profile/service.py`
- [Resume parsing & versions](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/resume/parser.py): resume service · `backend/app/resume/parser.py`
- [Conversation service](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/chat/service.py): streaming chat · Persists and streams chat sessions. · `backend/app/chat/service.py`
- [Opportunity workflows](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/workflow/engine.py): workflow engine · Coordinates reusable cross-step opportunity runs. · `backend/app/workflow/engine.py`
- [Job ingestion & evaluation](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/jobs/imports.py): job processing · Imports, analyzes pages, matches candidates, and evaluates jobs. · `backend/app/jobs/imports.py`

### Local Persistence

- [SQLite + vector retrieval](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/db.py): local database · Durable records and vector-backed retrieval. · `backend/app/db.py`
- [Attachment service](https://github.com/xiaolang-d3/careerloop/blob/main/backend/app/attachments/service.py): local file storage · Mediates access to local attachments. · `backend/app/attachments/service.py`

### Other components

- [Local dev launcher](https://github.com/xiaolang-d3/careerloop/blob/main/scripts/dev.sh): shell script · Starts the local frontend and backend stack. · `scripts/dev.sh`

## Connections

- Local dev launcher → SPA shell: starts
- Local dev launcher → FastAPI application: starts
- SPA shell → API client: uses
- SPA shell → Job evaluation: renders
- SPA shell → Opportunity discovery: renders
- SPA shell → Interview preparation: renders
- SPA shell → Settings workspace: renders
- API client → FastAPI application: HTTP
- FastAPI application → Resource API: routes requests
- Resource API → Local admin auth: authenticates
- Resource API → Candidate knowledge: manages
- Resource API → Conversation service: serves
- Resource API → Opportunity workflows: starts and reads
- Opportunity workflows → Job ingestion & evaluation: runs stages
- Opportunity workflows → Agent orchestration: delegates AI work
- Agent orchestration → Agent runtime: coordinates
- Agent runtime → OpenAI-compatible models: calls models
- Agent runtime → Grounded career tools: invokes tools
- Agent runtime → Model and tool audit: audits
- Grounded career tools → Candidate knowledge: grounds on
- Candidate knowledge → Resume parsing & versions: uses resumes
- Candidate knowledge → SQLite + vector retrieval: persists
- Job ingestion & evaluation → SQLite + vector retrieval: persists opportunities
- Conversation service → SQLite + vector retrieval: persists sessions
- Attachment service → SQLite + vector retrieval: associates metadata
- Candidate knowledge → Attachment service: accesses documents
