AI Engine
Gemini 2.0 Flash — Discovery, intelligence, verification
@google/genai SDK · Server-side only · Temperature: 0.3 for factual accuracyHostel Discovery Engine
The discovery engine combines Gemini 2.0 Flash with Google Search Retrieval to find real, verified hostels matching a nomad's skills and desired location. Every result undergoes a multi-stage verification pipeline before being presented to the user.
User Input AI Layer Verification Layer
────────── ──────── ──────────────────
Location: "Bali" → Gemini 2.0 Flash → verifyWebsite()
Skills: "Marketing" + Google Search HTTP HEAD each URL
Retrieval Tool HTTPS → HTTP fallback
│ │
▼ ▼
15-20 hostel results → scrapeContactEmails()
names, websites, Crawl /, /contact, /about
locations, match % Regex + mailto: extraction
│
▼
verifyEmailDomain()
DNS MX record lookup
per email address
│
▼
✅ Verified Results
Cached in SupabaseRequest / Response
{
"location": "Bali, Indonesia",
"skills": ["marketing", "SEO",
"content creation"],
"userId": "user_2x4k..."
}{
"name": "The Mad Monkey",
"location": "Ubud, Bali",
"website": "https://themadmonkey.com",
"websiteVerified": true,
"contactEmail": "info@themadmonkey.com",
"emailVerified": true,
"matchScore": 87,
"needs": ["social media", "SEO"]
}Dossier Generation
Generates a comprehensive market intelligence report for a specific hostel, personalized to the nomad's profile. Includes competitive analysis, needs assessment, strategic positioning, and an auto-generated pitch email ready to send.
Input Parameters
| Field | Type | Description |
|---|---|---|
| hostelName | string | Name of the hostel |
| hostelWebsite | string | Primary website URL |
| userName | string | Nomad's full name |
| userHeadline | string | Professional headline |
| userSkills | string[] | Skill list |
| userBio | string | Professional biography |
| userLocation | string | Current location |
Output Sections
Email Verification Pipeline
verifyWebsite(url)HTTP HEAD request to validate hostel URL. Tries HTTPS first, falls back to HTTP. Returns final resolved URL or null.
scrapeContactEmails(url)Fetches the hostel website's /, /contact, and /about pages. Extracts emails via regex patterns and mailto: link parsing.
verifyEmailDomain(email)DNS MX record lookup via Node.js dns.resolveMx(). Confirms the email domain has valid mail exchange servers.
verifyAndEnrichHostels(hostels)Orchestration function: verify website → scrape emails → MX-verify all emails. Returns only verified data.
Anti-Hallucination Measures
LLMs can fabricate URLs and email addresses. HostelHack implements a multi-layer verification pipeline to ensure every piece of data surfaced to users is real.
| Layer | Method | What it catches |
|---|---|---|
| Prompt Engineering | "ONLY include emails you actually find in search results. Do NOT guess." | Reduces generation of fake data |
| Website Verification | HTTP HEAD request to every URL | Catches hallucinated/dead URLs |
| Email Scraping | Real website crawling for contact emails | Replaces AI-guessed emails with real ones |
| DNS MX Validation | dns.resolveMx() per email domain | Confirms mail servers exist |
| Placeholder Stripping | Regex replaces "[Your Name]", etc. | Removes template artifacts from pitches |
| Cache Layer | Search results cached in Supabase | Prevents repeated unverified generations |