AI Engine

Gemini 2.0 Flash — Discovery, intelligence, verification

Model: Gemini 2.0 Flash via @google/genai SDK · Server-side only · Temperature: 0.3 for factual accuracy

Hostel Discovery Engine

POST /api/hostels/search

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 Supabase

Request / Response

Request Body
{
  "location": "Bali, Indonesia",
  "skills": ["marketing", "SEO",
             "content creation"],
  "userId": "user_2x4k..."
}
Response (per hostel)
{
  "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

POST /api/hostels/dossier

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

FieldTypeDescription
hostelNamestringName of the hostel
hostelWebsitestringPrimary website URL
userNamestringNomad's full name
userHeadlinestringProfessional headline
userSkillsstring[]Skill list
userBiostringProfessional biography
userLocationstringCurrent location

Output Sections

Market Snapshot
Competitive positioning, local market analysis, hostel's digital presence assessment
Needs Analysis
Identified hostel needs that match the nomad's specific skillset
Value Proposition
Why this specific nomad is uniquely positioned for this hostel
Deal Structure
Suggested duration, deliverables, accommodation type
Personalized Pitch
Auto-generated email ready to send — personalized to both parties
Verified Contacts
Scraped + MX-verified email addresses from the hostel's website

Email Verification Pipeline

lib/email-verify.ts
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.

LayerMethodWhat it catches
Prompt Engineering"ONLY include emails you actually find in search results. Do NOT guess."Reduces generation of fake data
Website VerificationHTTP HEAD request to every URLCatches hallucinated/dead URLs
Email ScrapingReal website crawling for contact emailsReplaces AI-guessed emails with real ones
DNS MX Validationdns.resolveMx() per email domainConfirms mail servers exist
Placeholder StrippingRegex replaces "[Your Name]", etc.Removes template artifacts from pitches
Cache LayerSearch results cached in SupabasePrevents repeated unverified generations
Result: Users only see hostel URLs that respond to HTTP requests and email addresses whose domains have valid MX records. This dramatically reduces bounce rates and ensures proposals reach real inboxes.
HostelHack Documentation · March 2026
Built with Next.js 15 · Gemini 2.0 · Supabase