How cgmafia/ai-research-agent works
Purpose and Topology
This is a local Python research/lead-enrichment application. It accepts company website URLs, researches public website and LinkedIn information, and produces structured company/contact results. The system is split into a REST backend and a separate Streamlit user interface.
Paths: backend/main.py, frontend/app.py, data/input.csv.
Runtime Entry Points
• Start the API with Uvicorn targeting the FastAPI application in backend/main.py.
• Start the UI with Streamlit targeting frontend/app.py.
• The frontend is expected to act as the interactive client for backend research operations; the backend is also intended for programmatic API consumers.
Paths: backend/main.py, frontend/app.py.
Input and Job Boundary
The primary batch input is a CSV containing a website column. data/input.csv is the repository-provided input location/sample. Each website is an independent research target, allowing future parallelization or scheduling without changing the conceptual job model.
Paths: data/input.csv, backend/main.py.
Research and Extraction Pipeline
The backend is the orchestration boundary for the stated workflow:
1. Receive one or more website targets.
2. Crawl internal website pages.
3. Parse page content to identify public emails and phone numbers.
4. Discover/scrape relevant public LinkedIn profiles.
5. Enrich company attributes such as industry, size, and revenue.
6. Return or export normalized company-contact records.
The implementation is concentrated in backend/main.py; no separate crawler, persistence, or domain-module directories are present.
UI and Result Delivery
The Streamlit layer supplies the browser-facing workflow: submit/upload target data, invoke research, present structured results, and support CSV download/export. It should remain a consumer of API contracts rather than duplicate crawling or enrichment logic.
Paths: frontend/app.py, backend/main.py, data/input.csv.
External Services and Material Dependencies
The architecture depends on:
• Target company websites as crawl sources.
• Public LinkedIn-accessible data for profile discovery.
• Hunter.io for company enrichment.
• Google search capability for discovery, per declared dependencies.
• Playwright with Chromium for browser-based scraping where static HTTP parsing is insufficient.
FastAPI/Uvicorn provide API serving; Streamlit provides the local UI. Parsing/data processing dependencies include Requests, BeautifulSoup, lxml, Pandas, aiohttp, and tldextract. Dependencies are declared in requirements.txt.
Paths: requirements.txt, backend/main.py, frontend/app.py.
Operational Constraints
This is a local, two-process deployment with no container, database, queue, scheduler, or deployment infrastructure represented in the repository. Results are therefore expected to be request/batch-scoped or file-exported rather than durably persisted. Website anti-scraping behavior, robots policies, privacy law, LinkedIn terms, and Hunter.io credentials/rate limits are key external control boundaries.
Paths: backend/main.py, frontend/app.py, requirements.txt.
Main entry points: main.py FastAPI application · app.py Streamlit UI · input.csv Website input CSV · requirements.txt Dependency manifest
Components 15
Local processes
Run separately on a developer machine.
- Website input CSV · Contains the website column for independent research targets.
data/input.csv - Streamlit UI · Submits targets, displays results, and exports CSV.
frontend/app.py - Dependency manifest · Declares FastAPI, Streamlit, parsing, HTTP, and browser tooling.
requirements.txt
Research API pipeline
Workflow implementation is concentrated in backend/main.py.
- FastAPI application · Uvicorn-served boundary for UI and programmatic consumers.
backend/main.py - Research targets · One or more website URLs per request or batch.
backend/main.py - Internal page crawler · Collects relevant pages from each target website.
backend/main.py - Contact extractor · Finds public emails and phone numbers in page content.
backend/main.py - LinkedIn discovery · Finds and scrapes relevant public profiles.
backend/main.py - Company enrichment · Adds industry, size, revenue, and related attributes.
backend/main.py - Company-contact records · Normalized request-scoped research output.
backend/main.py
External sources and services
Public-data access and third-party limits are external boundaries.
- Company websites
- Public LinkedIn data · Subject to platform access constraints.
- Hunter.io · Credentials and rate limits govern access.
- Google search
- Playwright + Chromium · Used where static HTTP parsing is insufficient.
requirements.txt
Connections 20
- Website input CSV → Streamlit UI: upload/select
- Website input CSV → FastAPI application: batch targets
- Streamlit UI → FastAPI application: research requests
- FastAPI application → Research targets: creates
- Research targets → Internal page crawler: website URLs
- Internal page crawler → Company websites: crawl pages
- Internal page crawler → Playwright + Chromium: dynamic pages
- Internal page crawler → Contact extractor: page content
- Research targets → LinkedIn discovery: company context
- LinkedIn discovery → Public LinkedIn data: discover profiles
- LinkedIn discovery → Google search: search discovery
- Research targets → Company enrichment: company identity
- Company enrichment → Hunter.io: lookup
- Contact extractor → Company-contact records: contacts
- LinkedIn discovery → Company-contact records: profiles
- Company enrichment → Company-contact records: company attributes
- Company-contact records → FastAPI application: response payload
- FastAPI application → Streamlit UI: structured results
- Dependency manifest → FastAPI application: runtime libraries
- Dependency manifest → Streamlit UI: UI runtime