Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions job-hunting/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
144 changes: 144 additions & 0 deletions job-hunting/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# Job Hunter - AI-Powered Job Search Automation

## Demo

![job-hunting Demo](./assets/1e173e48-3235-4016-9a14-2d985b781134.jpg)

**Live Demo:** https://job-huntboard.vercel.app

Job Hunter is a comprehensive platform that automates the job search process using Mino's browser automation API and OpenRouter's AI models. It handles everything from resume parsing and optimized job board search generation to parallel scraping and intelligent job matching.

---

---

## Demo

*[Demo video/screenshot to be added]*

---

## How Mino API is Used

The Mino API powers browser automation for this use case. See the code snippet below for implementation details.

### Code Snippet

```bash
curl -N -X POST "https://mino.ai/v1/automation/run-sse" \
-H "X-API-Key: $MINO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://sg.indeed.com/jobs?q=frontend+developer",
"goal": "I am looking for: frontend developer. Extract ONLY the 6-7 most relevant job listings...",
"browser_profile": "stealth"
}'
```

---

## How to Run

### Prerequisites

- Node.js 18+
- Mino API key (get from [mino.ai](https://mino.ai))

### Setup

1. Clone the repository:
```bash
git clone https://github.com/tinyfish-io/TinyFish-cookbook
cd TinyFish-cookbook/job-hunting
```

2. Install dependencies:
```bash
npm install
```

3. Create `.env.local` file:
```bash
# Add your environment variables here
MINO_API_KEY=sk-mino-...
```

4. Run the development server:
```bash
npm run dev
```

5. Open [http://localhost:3000](http://localhost:3000) in your browser

---

## Architecture Diagram

```mermaid
graph TD
subgraph Frontend [Next.js Client]
UI[User Interface - React/Tailwind]
State[State Management - Custom Hooks]
LS[(Local Storage)]
end

subgraph Backend [Next.js API Routes]
Parse[/api/ai/parse-resume]
GenURLs[/api/ai/generate-urls]
Scrape[/api/scrape]
Match[/api/ai/match-jobs]
Letter[/api/ai/cover-letter]
end

subgraph External_APIs [External Services]
Mino[Mino API - Browser Automation]
OpenRouter[OpenRouter AI - Minimax M2.1]
end

%% User Interactions
UI -->|Resume Text| State
UI -->|Search Criteria| State

%% Internal Orchestration
State <-->|Read/Write Profile & Jobs| LS
State -->|Trigger| Parse
State -->|Trigger| GenURLs
State -->|Trigger Parallel| Scrape
State -->|Trigger| Match
State -->|Trigger| Letter

%% External Service Calls
Parse -->|Extract JSON| OpenRouter
GenURLs -->|Generate Search URLs| OpenRouter
Match -->|Analyze Fit| OpenRouter
Letter -->|Personalize Content| OpenRouter

Scrape -->|Orchestrate Agents| Mino
Mino --.->|SSE Stream: Progress + Live Preview| UI
Mino --.->|JSON Result| Scrape
Scrape -->|Job Objects| State
```

```mermaid
sequenceDiagram
participant U as User
participant D as Dashboard
participant S as API Route (/api/scrape)
participant M as Mino (Stealth Browser)

U->>D: Click "Find Jobs"
D->>D: Load Search URLs from State

par For Each Job Board (LinkedIn, Indeed, etc.)
D->>S: POST /api/scrape (Board URL)
S->>M: POST /v1/automation/run-sse (Goal + Stealth)
M-->>D: Event: streamingUrl (Live Preview)
M-->>D: Event: STEP (Navigating/Scanning)
M-->>D: Event: COMPLETE (JSON Result)
D->>D: Parse & Deduplicate Jobs
end

D->>U: Update Feed with New Listings
```


72 changes: 72 additions & 0 deletions job-hunting/app/api/ai/cover-letter/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { NextRequest, NextResponse } from "next/server";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";

export async function POST(request: NextRequest) {
try {
const { job, profile } = await request.json();

if (!job || !profile) {
return NextResponse.json(
{ error: "Job and profile are required" },
{ status: 400 }
);
}

const apiKey = process.env.OPENROUTER_API_KEY;
if (!apiKey) {
return NextResponse.json(
{ error: "OpenRouter API key not configured" },
{ status: 500 }
);
}

const openrouter = createOpenAICompatible({
name: "openrouter",
baseURL: "https://openrouter.ai/api/v1",
headers: {
Authorization: `Bearer ${apiKey}`,
"HTTP-Referer": "https://jobhunter.app",
"X-Title": "Job Hunter Dashboard",
},
});

const model = openrouter.chatModel("minimax/minimax-m2.1");

const { text } = await generateText({
model,
system: `You are an expert cover letter writer who creates compelling, personalized letters.
Write naturally and professionally, avoiding generic phrases.
Be specific about why this candidate is a great fit for this role.
Never use placeholder text - use actual company and candidate names.`,
prompt: `Write a compelling cover letter for this job application:

JOB DETAILS:
- Company: ${job.company}
- Title: ${job.title}
- Location: ${job.location}
- Description: ${job.description}
${job.requirements ? `- Requirements: ${job.requirements.join(", ")}` : ""}

CANDIDATE PROFILE:
- Name: ${profile.fullName}
- Current title: ${profile.currentTitle}
- Years of experience: ${profile.yearsExperience}
- Key skills: ${profile.skills?.slice(0, 8).join(", ") || ""}
- Summary: ${profile.summary}
Comment on lines +36 to +56
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

minimax/minimax-m2.1 context length limit OpenRouter

💡 Result:

On OpenRouter, minimax/minimax-m2.1 has a context length limit of 196,608 tokens (i.e., the maximum total tokens the model can handle in a single request/conversation window on OpenRouter). [1][2]

For comparison, MiniMax’s own API docs list 204,800 tokens for MiniMax-M2.1, so OpenRouter’s routed offering appears slightly lower. [3]

Sources: OpenRouter model page / API quickstart [1][2], MiniMax docs [3].


🏁 Script executed:

# Find the full route file to understand context and data types
find . -type f -name "route.ts" | grep -i "cover-letter"

Repository: tinyfish-io/TinyFish-cookbook

Length of output: 119


🏁 Script executed:

# Search for where the model is defined
rg -i "minimax|model" --type ts --type tsx -B 3 -A 3 | head -100

Repository: tinyfish-io/TinyFish-cookbook

Length of output: 100


🏁 Script executed:

# Check the job and profile type definitions
rg -i "interface|type.*job|type.*profile" --type ts --type tsx -B 2 -A 8 | head -150

Repository: tinyfish-io/TinyFish-cookbook

Length of output: 100


🏁 Script executed:

cat -n ./job-hunting/app/api/ai/cover-letter/route.ts

Repository: tinyfish-io/TinyFish-cookbook

Length of output: 2855


🏁 Script executed:

# Search for job and profile interface/type definitions
rg "interface.*job|type.*job|interface.*profile|type.*profile" --type ts -B 2 -A 10

Repository: tinyfish-io/TinyFish-cookbook

Length of output: 5645


🏁 Script executed:

# Check how job and profile objects are passed in
rg "job\.|profile\." ./job-hunting/app/api/ai/cover-letter/route.ts -B 2 -A 2

Repository: tinyfish-io/TinyFish-cookbook

Length of output: 545


Guard prompt inputs: validate job.requirements is an array and cap job description length.

The code assumes job.requirements is an array and calls .join() without type checking—this will throw if the field is a string or other non-array type from the external job API. Additionally, unbounded job descriptions from external sources can inflate token usage and model latency. Validate and bound both inputs before constructing the prompt.

🔧 Proposed fix
-    const { text } = await generateText({
+    const description =
+      typeof job.description === "string"
+        ? job.description.slice(0, 1500)
+        : "not provided";
+    const requirements = Array.isArray(job.requirements)
+      ? job.requirements.join(", ")
+      : "";
+
+    const { text } = await generateText({
       model,
       system: `You are an expert cover letter writer who creates compelling, personalized letters.
 Write naturally and professionally, avoiding generic phrases.
 Be specific about why this candidate is a great fit for this role.
 Never use placeholder text - use actual company and candidate names.`,
       prompt: `Write a compelling cover letter for this job application:
 
 JOB DETAILS:
 - Company: ${job.company}
 - Title: ${job.title}
 - Location: ${job.location}
- - Description: ${job.description}
-${job.requirements ? `- Requirements: ${job.requirements.join(", ")}` : ""}
+ - Description: ${description}
+${requirements ? `- Requirements: ${requirements}` : ""}
🤖 Prompt for AI Agents
In `@job-hunting/app/api/ai/cover-letter/route.ts` around lines 36 - 56, Validate
and sanitize the job inputs before building the prompt passed to generateText:
ensure job.requirements is an array (use Array.isArray(job.requirements) and
coerce non-array values into an array or ignore them) before calling .join, and
truncate/limit job.description to a safe max length (e.g., slice to a fixed
character/token limit) to avoid unbounded prompt size; apply these checks where
the prompt string is constructed (reference the generateText call and the
variables job.requirements and job.description) so the prompt interpolation uses
the validated/trimmed values.


Write a 3-4 paragraph cover letter that:
- Opens with a strong hook relevant to the company/role
- Highlights 2-3 specific qualifications that match the job requirements
- Shows enthusiasm for the company and role
- Ends with a clear call to action`,
});

return NextResponse.json({ data: text });
} catch (error) {
return NextResponse.json(
{ error: "Failed to generate cover letter" },
{ status: 500 }
);
}
}
119 changes: 119 additions & 0 deletions job-hunting/app/api/ai/generate-urls/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { NextRequest, NextResponse } from "next/server";
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText } from "ai";
import { z } from "zod";

const searchUrlsSchema = z.object({
urls: z.array(
z.object({
boardName: z.string(),
searchUrl: z.string(),
})
),
});

function extractJSON(text: string): string {
// Remove markdown code blocks if present
const codeBlockMatch = text.match(/```(?:json)?\s*([\s\S]*?)```/);
if (codeBlockMatch) {
return codeBlockMatch[1].trim();
}
// Try to find JSON object directly
const jsonMatch = text.match(/\{[\s\S]*\}/);
if (jsonMatch) {
return jsonMatch[0];
}
return text;
}

export async function POST(request: NextRequest) {
try {
const { profile, searchConfig } = await request.json();

if (!profile) {
return NextResponse.json(
{ error: "Profile is required" },
{ status: 400 }
);
}

const apiKey = process.env.OPENROUTER_API_KEY;
if (!apiKey) {
return NextResponse.json(
{ error: "OpenRouter API key not configured" },
{ status: 500 }
);
}

const openrouter = createOpenAICompatible({
name: "openrouter",
baseURL: "https://openrouter.ai/api/v1",
headers: {
Authorization: `Bearer ${apiKey}`,
"HTTP-Referer": "https://jobhunter.app",
"X-Title": "Job Hunter Dashboard",
},
});

const model = openrouter.chatModel("minimax/minimax-m2.1");

const locationStr =
searchConfig?.locations?.length > 0
? searchConfig.locations.join(", ")
: profile.location;

const remoteNote =
searchConfig?.remotePreference === "remote-only"
? "Focus on remote positions only."
: searchConfig?.remotePreference === "hybrid-ok"
? "Include remote and hybrid positions."
: "";

const jobSearchPrompt = searchConfig?.jobSearchPrompt || "";

const { text } = await generateText({
model,
system: `You are an expert at finding jobs on the internet. You know all the best job boards for different regions, industries, and job types. You create working search URLs with proper parameters. Always respond with valid JSON only.`,
prompt: `Generate the BEST job board search URLs for this job search:

=== JOB SEARCH REQUEST ===
${jobSearchPrompt || `Looking for ${profile.preferredTitles?.join(" or ") || profile.currentTitle} positions`}

=== LOCATION ===
${locationStr}

=== CONTEXT ===
- Experience level: ${profile.seniorityLevel}
${remoteNote ? `- Remote preference: ${remoteNote}` : ""}
${searchConfig?.salaryMinimum ? `- Minimum salary: $${searchConfig.salaryMinimum}` : ""}

=== INSTRUCTIONS ===
1. Choose the BEST 10-15 job boards for this search based on the LOCATION and JOB TYPE
2. For each region, include LOCAL job boards (e.g., for Singapore: JobsCentral, JobStreet, TechInAsia; for UK: Reed, TotalJobs; for India: Naukri, etc.)
3. Include global boards like LinkedIn, Indeed (use regional domains like indeed.sg, indeed.co.uk, etc.)
4. Include industry-specific boards if relevant (tech: AngelList, Dice, HackerNews; startups: Y Combinator, etc.)
5. Create working search URLs with the job keywords and location pre-filled
6. Use proper URL encoding (spaces become %20 or +)

Return ONLY a JSON object:
{
"urls": [
{ "boardName": "LinkedIn", "searchUrl": "https://www.linkedin.com/jobs/search/?keywords=..." },
{ "boardName": "Indeed Singapore", "searchUrl": "https://sg.indeed.com/jobs?q=..." },
...
]
}`,
});

const jsonStr = extractJSON(text);
const parsed = JSON.parse(jsonStr);
const validated = searchUrlsSchema.parse(parsed);

return NextResponse.json({ data: validated.urls });
} catch (error) {
return NextResponse.json(
{ error: "Failed to generate search URLs" },
{ status: 500 }
);
}
}
Loading