# menacehecker/huntai architecture

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

- Interactive diagram: https://gitdiagram.com/menacehecker/huntai
- Repository: https://github.com/menacehecker/huntai

## Overview

1. **What this repo is**
   - HuntAI is a daily job-opportunity pipeline, not a general app.
   - Its main purpose is to ingest jobs, rank them against a profile, pick a best option, and send a short email brief.

2. **Primary runtime boundary**
   - The documented production path is a **FastAPI backend** exposed locally and called by **n8n** on a schedule.
   - External services in the loop are **ngrok** for exposure and **Gmail** for delivery.

3. **Entry points**
   - `main.py` is likely the top-level launcher.
   - `api/app.py` is the API layer that serves the `/run-hunt` endpoint mentioned in the README.
   - That endpoint is the handoff point between the automation workflow and the internal job-evaluation pipeline.

4. **Workflow orchestration**
   - `workflows/pipeline.py` appears to coordinate the end-to-end run.
   - The pipeline likely pulls jobs, filters them, scores them, chooses a recommendation, and prepares the email payload.
   - This is the main “glue” layer separating request handling from business logic.

5. **Core business services**
   - `services/` holds the functional stages of the system:
     - `source_service.py` for collecting jobs from configured sources
     - `filter_service.py` for applying hard constraints
     - `dedupe_service.py` for removing repeats
     - `scoring_service.py` for ranking jobs
     - `tailoring_service.py` for generating role-specific framing
     - `profile_service.py` for reading the user profile
     - `job_service.py` for job-level orchestration
     - `notification_service.py` for email output
   - This is the main domain boundary in the repo.

6. **Data model and persistence**
   - `models/job.py` defines the job entity used across the pipeline.
   - Persistent state is split across a few lightweight stores:
     - `jobs.db` for structured job history/state
     - `seen_jobs.json` for duplicate suppression
     - `data/` JSON files for profile, sources, and experience knowledge
   - This suggests a small local-state architecture rather than a central database service.

7. **Configuration and knowledge inputs**
   - `data/profile.json` is the candidate profile used for matching.
   - `data/job_sources.json` defines where jobs are pulled from.
   - `data/experience_bank.json` likely powers tailoring and “how to position” output.
   - `.env.example` indicates secrets and runtime config are environment-driven.

8. **Output generation and email**
   - The final artifact is an “opportunity brief” email containing top jobs, one recommended role, score/verdict, and a tailored rationale.
   - `services/notification_service.py` is the boundary where internal results become an external email message.
   - The README indicates the workflow either sends a detailed brief or a no-match update.

9. **Agent-related layers**
   - `agents/` contains `discovery_agent.py` and `eligibility_agent.py`, which look like specialized reasoning components for finding and qualifying opportunities.
   - `adk_agents/huntai_team/` contains a more explicit multi-agent setup: coordinator, scout, fit, positioning, and action agents.
   - This looks like an advanced/experimental agent architecture alongside the simpler service pipeline.

10. **State and deduplication concerns**
   - The repository explicitly calls out duplicate jobs as a known limitation.
   - That lines up with `dedupe_service.py` and `seen_jobs.json`, which are likely the first-line controls for repeated listings.
   - There is no sign of a heavyweight job-tracking backend yet; state appears intentionally lightweight.

11. **System flow to diagram**
   - External scheduler in n8n triggers FastAPI.
   - API hands off to the workflow pipeline.
   - Pipeline consults profile/source data, fetches jobs, filters/dedupes/scores them, and optionally tailors the top pick.
   - Notification service sends the result to Gmail.
   - Local files and DBs persist profile, history, and seen-job state between runs.

12. **Architecture takeaway**
   - This is a compact, file-backed decision pipeline with a clear separation between orchestration, domain services, and notification output.
   - The main architectural boundary is between the **scheduled external workflow** and the **internal job-ranking engine**.

Main entry points: [`services/job_service.py`](https://github.com/menacehecker/huntai/blob/main/services/job_service.py) (Job service), [`adk_agents/huntai_team/coordinator_agent.py`](https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/coordinator_agent.py) (Coordinator), [`services/source_service.py`](https://github.com/menacehecker/huntai/blob/main/services/source_service.py) (Sources), [`api/app.py`](https://github.com/menacehecker/huntai/blob/main/api/app.py) (API app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime & entrypoints"]
  node_main_py["Main<br/>launcher<br/>[main.py]"]
  node_api_app["API app<br/>fastapi<br/>[app.py]"]
  node_n8n(("n8n<br/>scheduler"))
  node_ngrok(("ngrok<br/>tunnel"))
end

subgraph group_orchestration["Orchestration"]
  node_pipeline["Pipeline<br/>orchestrator<br/>[pipeline.py]"]
end

subgraph group_domain["Domain services"]
  node_job_service["Job service<br/>domain orchestration<br/>[job_service.py]"]
  node_source_service["Sources<br/>ingestion<br/>[source_service.py]"]
  node_filter_service["Filter<br/>constraints<br/>[filter_service.py]"]
  node_dedupe_service["Dedupe<br/>stateful filter<br/>[dedupe_service.py]"]
  node_scoring_service["Scoring<br/>ranking<br/>[scoring_service.py]"]
  node_tailoring_service["Tailoring<br/>positioning"]
  node_profile_service["Profile<br/>[profile_service.py]"]
  node_notification_service["Notify<br/>email output"]
  node_job_model["Job model<br/>data model<br/>[job.py]"]
end

subgraph group_state["State & data"]
  node_db[("Jobs DB<br/>local persistence<br/>[jobs.db]")]
  node_seen_jobs["Seen jobs<br/>dedupe state<br/>[seen_jobs.json]"]
  node_profile_json["Profile data<br/>json knowledge<br/>[profile.json]"]
  node_sources_json["Sources data<br/>json config<br/>[job_sources.json]"]
  node_experience_bank["Experience bank<br/>json knowledge"]
end

subgraph group_agents["Agent systems"]
  node_discovery_agent["Discovery agent<br/>[discovery_agent.py]"]
  node_eligibility_agent["Eligibility agent"]
  node_team_coordinator["Coordinator"]
  node_team_scout["Scout<br/>[scout_agent.py]"]
  node_team_fit["Fit<br/>multi-agent judge<br/>[fit_agent.py]"]
  node_team_positioning["Positioning<br/>multi-agent framing"]
  node_team_action["Action<br/>multi-agent executor<br/>[action_agent.py]"]
end

node_n8n -->|"calls exposed API"| node_ngrok
node_ngrok -->|"routes requests"| node_api_app
node_main_py -->|"starts app"| node_api_app
node_api_app -->|"run-hunt"| node_pipeline
node_pipeline -->|"orchestrates"| node_job_service
node_job_service -->|"loads profile"| node_profile_service
node_profile_service -->|"reads"| node_profile_json
node_job_service -->|"fetches jobs"| node_source_service
node_source_service -->|"reads"| node_sources_json
node_source_service -->|"creates jobs"| node_job_model
node_job_service -->|"applies filters"| node_filter_service
node_job_service -->|"dedupes"| node_dedupe_service
node_dedupe_service -->|"reads/writes"| node_seen_jobs
node_job_service -->|"scores"| node_scoring_service
node_scoring_service -->|"evaluates"| node_job_model
node_job_service -->|"tailors brief"| node_tailoring_service
node_tailoring_service -->|"reads"| node_experience_bank
node_job_service -->|"sends brief"| node_notification_service
node_notification_service -->|"stores history"| node_db
node_job_service -->|"updates state"| node_db
node_job_service -.->|"optional discovery"| node_discovery_agent
node_job_service -.->|"optional qualification"| node_eligibility_agent
node_team_coordinator -->|"coordinates"| node_team_scout
node_team_coordinator -->|"coordinates"| node_team_fit
node_team_coordinator -->|"coordinates"| node_team_positioning
node_team_coordinator -->|"coordinates"| node_team_action

click node_main_py "https://github.com/menacehecker/huntai/blob/main/main.py"
click node_api_app "https://github.com/menacehecker/huntai/blob/main/api/app.py"
click node_pipeline "https://github.com/menacehecker/huntai/blob/main/workflows/pipeline.py"
click node_job_service "https://github.com/menacehecker/huntai/blob/main/services/job_service.py"
click node_source_service "https://github.com/menacehecker/huntai/blob/main/services/source_service.py"
click node_filter_service "https://github.com/menacehecker/huntai/blob/main/services/filter_service.py"
click node_dedupe_service "https://github.com/menacehecker/huntai/blob/main/services/dedupe_service.py"
click node_scoring_service "https://github.com/menacehecker/huntai/blob/main/services/scoring_service.py"
click node_tailoring_service "https://github.com/menacehecker/huntai/blob/main/services/tailoring_service.py"
click node_profile_service "https://github.com/menacehecker/huntai/blob/main/services/profile_service.py"
click node_notification_service "https://github.com/menacehecker/huntai/blob/main/services/notification_service.py"
click node_job_model "https://github.com/menacehecker/huntai/blob/main/models/job.py"
click node_db "https://github.com/menacehecker/huntai/blob/main/jobs.db"
click node_seen_jobs "https://github.com/menacehecker/huntai/blob/main/seen_jobs.json"
click node_profile_json "https://github.com/menacehecker/huntai/blob/main/data/profile.json"
click node_sources_json "https://github.com/menacehecker/huntai/blob/main/data/job_sources.json"
click node_experience_bank "https://github.com/menacehecker/huntai/blob/main/data/experience_bank.json"
click node_discovery_agent "https://github.com/menacehecker/huntai/blob/main/agents/discovery_agent.py"
click node_eligibility_agent "https://github.com/menacehecker/huntai/blob/main/agents/eligibility_agent.py"
click node_team_coordinator "https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/coordinator_agent.py"
click node_team_scout "https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/scout_agent.py"
click node_team_fit "https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/fit_agent.py"
click node_team_positioning "https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/positioning_agent.py"
click node_team_action "https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/action_agent.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_main_py,node_api_app,node_n8n,node_ngrok toneBlue
class node_pipeline toneAmber
class node_job_service,node_source_service,node_filter_service,node_dedupe_service,node_scoring_service,node_tailoring_service,node_profile_service,node_notification_service,node_job_model toneMint
class node_db,node_seen_jobs,node_profile_json,node_sources_json,node_experience_bank toneRose
class node_discovery_agent,node_eligibility_agent,node_team_coordinator,node_team_scout,node_team_fit,node_team_positioning,node_team_action toneIndigo
```

## Components

### Runtime & entrypoints

External scheduler and API entry layer for launching the hunt pipeline.

- [Main](https://github.com/menacehecker/huntai/blob/main/main.py): launcher · Top-level process launcher for the application. · `main.py`
- [API app](https://github.com/menacehecker/huntai/blob/main/api/app.py): fastapi · HTTP layer exposing the run endpoint used by automation. · `api/app.py`
- **n8n**: scheduler · External scheduled workflow that triggers the daily hunt run.
- **ngrok**: tunnel · Local exposure layer for making the API reachable externally.

### Orchestration

End-to-end pipeline coordination and job-level control flow.

- [Pipeline](https://github.com/menacehecker/huntai/blob/main/workflows/pipeline.py): orchestrator · Coordinates the end-to-end job hunt run. · `workflows/pipeline.py`

### Domain services

Core job ingestion, filtering, scoring, tailoring, and notification logic.

- [Job service](https://github.com/menacehecker/huntai/blob/main/services/job_service.py): domain orchestration · Higher-level job workflow coordination across the service stages. · `services/job_service.py`
- [Sources](https://github.com/menacehecker/huntai/blob/main/services/source_service.py): ingestion · Collects jobs from configured sources. · `services/source_service.py`
- [Filter](https://github.com/menacehecker/huntai/blob/main/services/filter_service.py): constraints · Applies hard eligibility constraints to candidate jobs. · `services/filter_service.py`
- [Dedupe](https://github.com/menacehecker/huntai/blob/main/services/dedupe_service.py): stateful filter · Removes repeated jobs using local seen-job state. · `services/dedupe_service.py`
- [Scoring](https://github.com/menacehecker/huntai/blob/main/services/scoring_service.py): ranking · Ranks jobs against the candidate profile and preferences. · `services/scoring_service.py`
- [Tailoring](https://github.com/menacehecker/huntai/blob/main/services/tailoring_service.py): positioning · Generates role-specific framing and rationale for the best match. · `services/tailoring_service.py`
- [Profile](https://github.com/menacehecker/huntai/blob/main/services/profile_service.py): profile access · Loads the candidate profile used for matching and tailoring. · `services/profile_service.py`
- [Notify](https://github.com/menacehecker/huntai/blob/main/services/notification_service.py): email output · Formats and sends the opportunity brief via email. · `services/notification_service.py`
- [Job model](https://github.com/menacehecker/huntai/blob/main/models/job.py): data model · Shared job entity used across the pipeline. · `models/job.py`

### State & data

Local persistence and JSON-backed knowledge inputs.

- [Jobs DB](https://github.com/menacehecker/huntai/blob/main/jobs.db): local persistence · Structured local store for job history and state. · `jobs.db`
- [Seen jobs](https://github.com/menacehecker/huntai/blob/main/seen_jobs.json): dedupe state · JSON record of previously processed jobs. · `seen_jobs.json`
- [Profile data](https://github.com/menacehecker/huntai/blob/main/data/profile.json): json knowledge · Candidate profile used for ranking and tailoring. · `data/profile.json`
- [Sources data](https://github.com/menacehecker/huntai/blob/main/data/job_sources.json): json config · Job source definitions for ingestion. · `data/job_sources.json`
- [Experience bank](https://github.com/menacehecker/huntai/blob/main/data/experience_bank.json): json knowledge · Reference material used to tailor role positioning. · `data/experience_bank.json`

### Agent systems

Alternative agent-based components and multi-agent team setup.

- [Discovery agent](https://github.com/menacehecker/huntai/blob/main/agents/discovery_agent.py): agent · Specialized agent for finding opportunities. · `agents/discovery_agent.py`
- [Eligibility agent](https://github.com/menacehecker/huntai/blob/main/agents/eligibility_agent.py): agent · Specialized agent for qualifying opportunities. · `agents/eligibility_agent.py`
- [Coordinator](https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/coordinator_agent.py): multi-agent coordinator · Coordinates the huntai team agent workflow. · `adk_agents/huntai_team/coordinator_agent.py`
- [Scout](https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/scout_agent.py): multi-agent scout · Finds candidate opportunities in the team setup. · `adk_agents/huntai_team/scout_agent.py`
- [Fit](https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/fit_agent.py): multi-agent judge · Evaluates role fit in the team setup. · `adk_agents/huntai_team/fit_agent.py`
- [Positioning](https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/positioning_agent.py): multi-agent framing · Shapes how the candidate should be positioned. · `adk_agents/huntai_team/positioning_agent.py`
- [Action](https://github.com/menacehecker/huntai/blob/main/adk_agents/huntai_team/action_agent.py): multi-agent executor · Turns the decision into a concrete next action. · `adk_agents/huntai_team/action_agent.py`

## Connections

- n8n → ngrok: calls exposed API · Scheduled automation reaches the locally exposed service.
- ngrok → API app: routes requests · Tunnel forwards traffic to the FastAPI app.
- Main → API app: starts app · Launcher initializes the API runtime.
- API app → Pipeline: run-hunt · API hands off the request to the workflow pipeline.
- Pipeline → Job service: orchestrates · Pipeline delegates the main job hunt flow.
- Job service → Profile: loads profile · Job workflow retrieves candidate context.
- Profile → Profile data: reads · Profile service consumes the profile JSON.
- Job service → Sources: fetches jobs · Job workflow requests candidate opportunities.
- Sources → Sources data: reads · Source definitions drive ingestion.
- Sources → Job model: creates jobs · Ingested records are normalized into job entities.
- Job service → Filter: applies filters · Hard constraints are applied before ranking.
- Job service → Dedupe: dedupes · Repeated listings are removed using seen-job state.
- Dedupe → Seen jobs: reads/writes · Duplicate suppression depends on local JSON state.
- Job service → Scoring: scores · Remaining jobs are ranked against the profile.
- Scoring → Job model: evaluates · Scoring operates on normalized job entities.
- Job service → Tailoring: tailors brief · Top pick is framed for a concise opportunity brief.
- Tailoring → Experience bank: reads · Tailoring uses experience knowledge for positioning.
- Job service → Notify: sends brief · Final result is rendered into an email update.
- Notify → Jobs DB: stores history · Notification flow can persist run outcomes and history.
- Job service → Jobs DB: updates state · Pipeline state is tracked in the local job database.
- Job service → Discovery agent: optional discovery · Alternative agent path for opportunity finding.
- Job service → Eligibility agent: optional qualification · Alternative agent path for eligibility reasoning.
- Coordinator → Scout: coordinates · Coordinator delegates search work to scout.
- Coordinator → Fit: coordinates · Coordinator delegates fit evaluation.
- Coordinator → Positioning: coordinates · Coordinator delegates positioning work.
- Coordinator → Action: coordinates · Coordinator delegates action selection.
