Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

SimplifIQ — Lead Automation System

Assessment submission by Yash Vardhan Malik

A full-stack automated lead qualification and report delivery system. A prospect submits a form → the system researches their company, generates a personalized AI business intelligence report, and emails it as a PDF — zero human intervention.


Live Pipeline Flow

Prospect submits form
        ↓
  [Validate Input]       — Pydantic + Zod (frontend + backend)
        ↓
  [Data Enrichment]      — Website scraping + Web search + Clearbit API
        ↓
  [AI Report Generation] — Groq Llama 3.1-70B with engineered prompt
        ↓
  [PDF Generation]       — WeasyPrint renders a 4-page branded PDF
        ↓
  [Email Delivery]       — Resend API sends PDF to prospect
        ↓
  [Sheets Logging]       — BONUS: row appended to Google Sheet
        ↓
  [Drive Archive]        — BONUS: PDF saved to Google Drive folder

Tech Stack

Layer Technology
Frontend Next.js 15, TypeScript, Tailwind CSS, react-hook-form, Zod
Backend API FastAPI, Python 3.11, Pydantic v2, uvicorn
Enrichment httpx, BeautifulSoup4, Tavily / SerpAPI, Clearbit
AI Groq SDK — Llama 3.1-70B Versatile
PDF WeasyPrint + Jinja2
Email Resend Python SDK
Bonus gspread (Google Sheets), Google Drive API v3

Project Structure

LeadAutomation/
├── backend/
│   ├── main.py                  # FastAPI app, routes, rate limiting
│   ├── config.py                # Pydantic-settings typed config
│   ├── models/
│   │   └── lead.py              # LeadInput, EnrichedData, PipelineResult
│   ├── pipeline/
│   │   ├── orchestrator.py      # Master pipeline controller
│   │   ├── enrichment.py        # Scraping + search + Clearbit
│   │   ├── ai_generator.py      # Groq report generation
│   │   ├── pdf_generator.py     # WeasyPrint PDF renderer
│   │   └── email_sender.py      # Resend email delivery
│   ├── services/
│   │   ├── sheets.py            # Google Sheets logging (bonus)
│   │   └── drive.py             # Google Drive archiving (bonus)
│   ├── templates/
│   │   └── report.html          # Jinja2 report template (4 pages)
│   ├── utils/
│   │   ├── logger.py            # Pipeline step logger
│   │   └── validators.py        # Input sanitization helpers
│   ├── generated_pdfs/          # PDF output directory (git-ignored)
│   ├── requirements.txt
│   └── .env.example
└── frontend/
    ├── app/
    │   ├── page.tsx             # Homepage with lead form
    │   └── layout.tsx           # App layout + metadata
    ├── components/
    │   ├── LeadForm.tsx         # Main form (react-hook-form + Zod)
    │   ├── FormField.tsx        # Reusable labeled field wrapper
    │   └── SuccessScreen.tsx    # Post-submission success state
    ├── lib/
    │   └── schema.ts            # Zod validation schema
    └── .env.local.example

Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • A Groq API key (free)
  • A Resend API key (free, 100 emails/day)
  • At least one search API: Tavily (recommended) or SerpAPI

1. Clone & set up backend

cd backend
cp .env.example .env
# Fill in your API keys in .env
pip install -r requirements.txt
uvicorn main:app --reload --port 8000

2. Set up frontend

cd frontend
cp .env.local.example .env.local
# NEXT_PUBLIC_API_URL=http://localhost:8000
npm install
npm run dev

3. Open the app

Visit http://localhost:3000, fill in the lead form, and check the email inbox.


Environment Variables

See backend/.env.example for full documentation. Minimum required:

GROQ_API_KEY=...       # Required — AI report generation
RESEND_API_KEY=...     # Required — email delivery
TAVILY_API_KEY=...     # Recommended — web search enrichment

Optional (enrichment quality):

SERPAPI_KEY=...        # Alternative to Tavily
CLEARBIT_API_KEY=...   # Company metadata, logo, size
HUNTER_API_KEY=...     # Email/company data

Bonus (Google integration):

GOOGLE_SERVICE_ACCOUNT_JSON=path/to/key.json
GOOGLE_SHEET_ID=...
GOOGLE_DRIVE_FOLDER_ID=...

API Reference

Method Endpoint Description
GET / Health ping
GET /health Detailed integration status
POST /submit-lead Submit lead → triggers pipeline (202 async)
GET /docs Swagger UI

POST /submit-lead

{
  "name": "Arjun Mehta",
  "email": "arjun@finflow.io",
  "company_name": "FinFlow Technologies",
  "industry": "FinTech / Finance",
  "company_description": "We automate accounts payable for mid-market CFOs.",
  "website": "https://finflow.io",
  "role": "Founder",
  "city": "Mumbai",
  "company_size": "11-50"
}

Returns 202 Accepted immediately. The pipeline runs in the background.


Design Decisions & Tradeoffs

Async-first pipeline — every enrichment layer (scraping, search, Clearbit) runs concurrently via asyncio.gather. Total enrichment time is bounded by the slowest layer, not their sum.

Graceful degradation — each pipeline step has its own try/except. If scraping fails (bot detection, timeout), search still runs. If search fails, the AI uses form data only. The email always goes out.

Quality-aware AI prompting — the Groq prompt explicitly tells the model what data quality level it's working with (HIGH/MEDIUM/LOW) and adjusts instructions accordingly. LOW quality prompts the model to lean on industry expertise rather than fake specificity.

WeasyPrint over reportlab/fpdf — WeasyPrint takes HTML+CSS → PDF, which means the template is maintainable by anyone who knows HTML. No low-level coordinate math. The tradeoff is WeasyPrint needs system fonts and is slightly slower (~1-2s).

Resend over SMTP — zero configuration, no DNS setup beyond domain verification, and built-in deliverability optimization. The free tier covers the assessment use case entirely.

Background tasks over Celery — FastAPI's BackgroundTasks is sufficient for a single-server prototype. In production with horizontal scaling, this would move to Celery + Redis.


Limitations

  • Rate limited to 1 submission per IP per 60 seconds (configurable)
  • Website scraping may be blocked by Cloudflare/anti-bot on some company sites
  • Clearbit has a limited free tier — enrichment falls back gracefully
  • WeasyPrint requires system libraries (libpango, libcairo) — see WeasyPrint docs for OS-specific install

Bonus Features

  • ✅ Google Sheets logging — every lead appended as a row with status
  • ✅ Google Drive archiving — PDF saved to a configured Drive folder
  • ✅ Rate limiting — per-IP in-memory limiter (production: replace with Redis)
  • ✅ Multi-layer enrichment — scraping + search + API, concurrent
  • ✅ Quality-adaptive AI — prompt adapts to available data depth
  • ✅ 4-page branded PDF — cover + 3 content pages with WeasyPrint

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages