# paing-tech/nextoffer_job-search-intelligence-agent architecture

> Architecture diagram of the GitHub repository paing-tech/nextoffer_job-search-intelligence-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/paing-tech/nextoffer_job-search-intelligence-agent
- Repository: https://github.com/paing-tech/nextoffer_job-search-intelligence-agent

## Overview

NextOffer is a job-search intelligence agent: users analyze job links or pasted descriptions, track applications through chat and application views, and connect Google to scan Gmail updates and synchronize a Sheet. The browser-facing Next.js app proxies authenticated requests to FastAPI; backend workflows use an async PostgreSQL store and a Foundry-hosted LLM. The graph includes documented Gmail scanning and scheduled scans despite incomplete excerpts; unsampled UI and integration internals are represented conservatively.

Main entry points: [`backend/app/routers`](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/tree/main/backend/app/routers) (API routes), [`backend/app/services/scans.py`](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/scans.py) (Gmail scan pipeline), [`backend/app/services/applications.py`](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/applications.py) (Application tracking), [`backend/app/services/jobs.py`](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/jobs.py) (Job-link analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web experience"]
  node_webui["Next.js experience<br/>[chat.tsx]"]
  node_bff["Session proxy<br/>[route.ts]"]
end

subgraph group_api["API and agent"]
  node_apiapp["FastAPI app<br/>[main.py]"]
  node_auth["Token verification<br/>[deps.py]"]
  node_routers["API routes"]
  node_agent["Chat agent loop<br/>[loop.py]"]
  node_tools["Agent tools<br/>[tools.py]"]
  node_llm["Foundry client<br/>[client.py]"]
end

subgraph group_tracking["Job tracking"]
  node_jobanalysis["Job-link analysis<br/>[jobs.py]"]
  node_jobfetch["Posting fetcher<br/>[jobfetch.py]"]
  node_extraction["Structured extraction<br/>[extraction.py]"]
  node_applications["Application tracking<br/>[applications.py]"]
  node_formatting["Tracker formatting<br/>[formatting.py]"]
  node_database[("PostgreSQL data<br/>[models.py]")]
end

subgraph group_google["Google workflows"]
  node_scans["Gmail scan pipeline<br/>[scans.py]"]
  node_autoscan["Scheduled scans<br/>[auto_scan.py]"]
  node_gmail["Gmail integration<br/>[gmail.py]"]
  node_oauth["Google OAuth<br/>[google_oauth.py]"]
  node_sheetsync["Sheet synchronization<br/>[sheets_sync.py]"]
  node_sheets["Sheets integration<br/>[sheets.py]"]
end

node_jobseeker(("Job seeker"))
node_foundry{{"Microsoft Foundry"}}
node_googleapis{{"Google APIs"}}

node_jobseeker -->|"uses"| node_webui
node_webui -.->|"requests"| node_bff
node_bff -->|"proxies requests"| node_apiapp
node_bff -->|"mints bearer token"| node_auth
node_apiapp -->|"registers routes"| node_routers
node_routers -->|"verifies users"| node_auth
node_routers -->|"dispatches chat"| node_agent
node_agent -->|"requests completions"| node_llm
node_agent -->|"dispatches tool calls"| node_tools
node_tools -->|"analyzes links"| node_jobanalysis
node_tools -->|"tracks applications"| node_applications
node_jobanalysis -->|"fetches postings"| node_jobfetch
node_jobanalysis -->|"extracts details"| node_extraction
node_jobanalysis -->|"persists postings"| node_database
node_llm -->|"calls model"| node_foundry
node_routers -->|"serves tracking"| node_applications
node_applications -->|"formats requirements"| node_formatting
node_applications -->|"reads and writes"| node_database
node_apiapp -->|"starts poller"| node_autoscan
node_autoscan -->|"runs due scans"| node_scans
node_routers -->|"starts scans"| node_scans
node_scans -->|"reads messages"| node_gmail
node_scans -->|"gets access token"| node_oauth
node_scans -->|"records updates"| node_applications
node_scans -->|"records scan state"| node_database
node_routers -->|"handles consent"| node_oauth
node_routers -->|"triggers sync"| node_sheetsync
node_sheetsync -->|"writes tracker"| node_sheets
node_oauth -->|"exchanges tokens"| node_googleapis
node_gmail -.->|"reads email"| node_googleapis
node_sheets -.->|"updates Sheet"| node_googleapis
node_oauth -->|"stores credentials"| node_database
node_sheetsync -->|"syncs application"| node_applications

click node_webui "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/frontend/src/components/chat.tsx"
click node_bff "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts"
click node_apiapp "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/main.py"
click node_auth "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/auth/deps.py"
click node_routers "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/tree/main/backend/app/routers"
click node_agent "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/agent/loop.py"
click node_tools "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/agent/tools.py"
click node_llm "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/llm/client.py"
click node_jobanalysis "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/jobs.py"
click node_jobfetch "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/jobfetch.py"
click node_extraction "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/llm/extraction.py"
click node_applications "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/applications.py"
click node_formatting "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/formatting.py"
click node_scans "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/scans.py"
click node_autoscan "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/auto_scan.py"
click node_gmail "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/gmail.py"
click node_oauth "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/google_oauth.py"
click node_sheetsync "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/sheets_sync.py"
click node_sheets "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/sheets.py"
click node_database "https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/db/models.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_webui,node_bff toneBlue
class node_apiapp,node_auth,node_routers,node_agent,node_tools,node_llm toneAmber
class node_jobanalysis,node_jobfetch,node_extraction,node_applications,node_formatting,node_database,node_googleapis toneMint
class node_scans,node_autoscan,node_gmail,node_oauth,node_sheetsync,node_sheets toneRose
class node_jobseeker,node_foundry toneIndigo
```

## Components

### Web experience

- [Next.js experience](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/frontend/src/components/chat.tsx): `frontend/src/components/chat.tsx`
- [Session proxy](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts): `frontend/src/app/api/backend/[...path]/route.ts`

### API and agent

- [FastAPI app](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/main.py): `backend/app/main.py`
- [Token verification](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/auth/deps.py): `backend/app/auth/deps.py`
- [API routes](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/tree/main/backend/app/routers): `backend/app/routers`
- [Chat agent loop](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/agent/loop.py): `backend/app/agent/loop.py`
- [Agent tools](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/agent/tools.py): `backend/app/agent/tools.py`
- [Foundry client](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/llm/client.py): `backend/app/llm/client.py`

### Job tracking

- [Job-link analysis](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/jobs.py): `backend/app/services/jobs.py`
- [Posting fetcher](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/jobfetch.py): `backend/app/integrations/jobfetch.py`
- [Structured extraction](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/llm/extraction.py): `backend/app/llm/extraction.py`
- [Application tracking](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/applications.py): `backend/app/services/applications.py`
- [Tracker formatting](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/formatting.py): `backend/app/services/formatting.py`
- [PostgreSQL data](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/db/models.py): `backend/app/db/models.py`

### Google workflows

- [Gmail scan pipeline](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/scans.py): `backend/app/services/scans.py`
- [Scheduled scans](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/auto_scan.py): `backend/app/services/auto_scan.py`
- [Gmail integration](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/gmail.py): `backend/app/integrations/gmail.py`
- [Google OAuth](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/google_oauth.py): `backend/app/integrations/google_oauth.py`
- [Sheet synchronization](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/services/sheets_sync.py): `backend/app/services/sheets_sync.py`
- [Sheets integration](https://github.com/paing-tech/nextoffer_job-search-intelligence-agent/blob/main/backend/app/integrations/sheets.py): `backend/app/integrations/sheets.py`

### Other components

- **Job seeker**
- **Microsoft Foundry**
- **Google APIs**

## Connections

- Job seeker → Next.js experience: uses (evidence: `README.md`)
- Next.js experience → Session proxy: requests
- Session proxy → FastAPI app: proxies requests (evidence: `README.md`)
- Session proxy → Token verification: mints bearer token (evidence: `README.md`)
- FastAPI app → API routes: registers routes (evidence: `backend/app/main.py`)
- API routes → Token verification: verifies users (evidence: `backend/app/routers/chat.py`)
- API routes → Chat agent loop: dispatches chat (evidence: `backend/app/routers/chat.py`)
- Chat agent loop → Foundry client: requests completions (evidence: `backend/app/agent/loop.py`)
- Chat agent loop → Agent tools: dispatches tool calls (evidence: `backend/app/agent/loop.py`)
- Agent tools → Job-link analysis: analyzes links (evidence: `backend/app/agent/tools.py`)
- Agent tools → Application tracking: tracks applications (evidence: `backend/app/agent/tools.py`)
- Job-link analysis → Posting fetcher: fetches postings (evidence: `backend/app/services/jobs.py`)
- Job-link analysis → Structured extraction: extracts details (evidence: `backend/app/services/jobs.py`)
- Job-link analysis → PostgreSQL data: persists postings (evidence: `backend/app/services/jobs.py`)
- Foundry client → Microsoft Foundry: calls model (evidence: `backend/app/llm/client.py`)
- API routes → Application tracking: serves tracking (evidence: `backend/app/routers/applications.py`)
- Application tracking → Tracker formatting: formats requirements (evidence: `backend/app/services/applications.py`)
- Application tracking → PostgreSQL data: reads and writes (evidence: `backend/app/services/applications.py`)
- FastAPI app → Scheduled scans: starts poller (evidence: `backend/app/main.py`)
- Scheduled scans → Gmail scan pipeline: runs due scans (evidence: `backend/app/services/auto_scan.py`)
- API routes → Gmail scan pipeline: starts scans (evidence: `backend/app/routers/scans.py`)
- Gmail scan pipeline → Gmail integration: reads messages (evidence: `backend/app/services/scans.py`)
- Gmail scan pipeline → Google OAuth: gets access token (evidence: `backend/app/services/scans.py`)
- Gmail scan pipeline → Application tracking: records updates (evidence: `backend/app/services/scans.py`)
- Gmail scan pipeline → PostgreSQL data: records scan state (evidence: `backend/app/services/scans.py`)
- API routes → Google OAuth: handles consent (evidence: `backend/app/routers/google.py`)
- API routes → Sheet synchronization: triggers sync (evidence: `backend/app/routers/google.py`)
- Sheet synchronization → Sheets integration: writes tracker (evidence: `backend/app/services/sheets_sync.py`)
- Google OAuth → Google APIs: exchanges tokens (evidence: `backend/app/integrations/google_oauth.py`)
- Gmail integration → Google APIs: reads email
- Sheets integration → Google APIs: updates Sheet
- Google OAuth → PostgreSQL data: stores credentials (evidence: `backend/app/integrations/google_oauth.py`)
- Sheet synchronization → Application tracking: syncs application (evidence: `backend/app/services/sheets_sync.py`)
