# kb-dhanush/smartleadgen architecture

> Architecture diagram of the GitHub repository kb-dhanush/smartleadgen, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kb-dhanush/smartleadgen
- Repository: https://github.com/kb-dhanush/smartleadgen

## Overview

SmartLeadGen is a Streamlit app that takes a user’s industry or topic, generates business leads with Gemini, enriches leads with website contact details from FireCrawl, and presents the results for viewing or CSV download. The main workflow is documented and visible in the sampled source. The graph separates generation, response parsing, enrichment, and presentation; several responsibilities share a source file. External services are shown only where the code calls them.

Main entry points: [`main.py`](https://github.com/kb-dhanush/smartleadgen/blob/main/main.py) (Lead workflow), [`streamlit_app.py`](https://github.com/kb-dhanush/smartleadgen/blob/main/streamlit_app.py) (Streamlit interface), [`firecrawler.py`](https://github.com/kb-dhanush/smartleadgen/blob/main/firecrawler.py) (Website scraping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interface"]
  node_app["Streamlit interface<br/>[streamlit_app.py]"]
  node_results["Results and CSV<br/>[streamlit_app.py]"]
end

subgraph group_workflow["Lead workflow"]
  node_orchestrator["Lead workflow<br/>[main.py]"]
  node_generator["Lead generation<br/>[main.py]"]
  node_parser["Response parsing<br/>[main.py]"]
  node_enrichment["Lead enrichment<br/>[main.py]"]
  node_scraper["Website scraping<br/>[firecrawler.py]"]
end

subgraph group_integrations["External services"]
  node_gemini["Gemini"]
  node_firecrawl["FireCrawl API"]
end

node_user(("Lead requester"))

node_user -->|"enters interest"| node_app
node_app -->|"requests leads"| node_orchestrator
node_orchestrator -->|"generates leads"| node_generator
node_generator -->|"invokes model"| node_gemini
node_gemini -->|"returns text"| node_parser
node_parser -->|"returns leads"| node_orchestrator
node_orchestrator -->|"enriches leads"| node_enrichment
node_enrichment -->|"scrapes websites"| node_scraper
node_scraper -->|"sends scrape request"| node_firecrawl
node_firecrawl -->|"returns page data"| node_scraper
node_enrichment -->|"returns enriched leads"| node_orchestrator
node_orchestrator -->|"returns leads"| node_app
node_app -->|"displays and exports"| node_results

click node_app "https://github.com/kb-dhanush/smartleadgen/blob/main/streamlit_app.py"
click node_orchestrator "https://github.com/kb-dhanush/smartleadgen/blob/main/main.py"
click node_generator "https://github.com/kb-dhanush/smartleadgen/blob/main/main.py"
click node_parser "https://github.com/kb-dhanush/smartleadgen/blob/main/main.py"
click node_enrichment "https://github.com/kb-dhanush/smartleadgen/blob/main/main.py"
click node_scraper "https://github.com/kb-dhanush/smartleadgen/blob/main/firecrawler.py"
click node_results "https://github.com/kb-dhanush/smartleadgen/blob/main/streamlit_app.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_results toneBlue
class node_orchestrator,node_generator,node_parser,node_enrichment,node_scraper toneAmber
class node_gemini,node_firecrawl,node_user toneMint
```

## Components

### User interface

- [Streamlit interface](https://github.com/kb-dhanush/smartleadgen/blob/main/streamlit_app.py): `streamlit_app.py`
- [Results and CSV](https://github.com/kb-dhanush/smartleadgen/blob/main/streamlit_app.py): `streamlit_app.py`

### Lead workflow

- [Lead workflow](https://github.com/kb-dhanush/smartleadgen/blob/main/main.py): `main.py`
- [Lead generation](https://github.com/kb-dhanush/smartleadgen/blob/main/main.py): `main.py`
- [Response parsing](https://github.com/kb-dhanush/smartleadgen/blob/main/main.py): `main.py`
- [Lead enrichment](https://github.com/kb-dhanush/smartleadgen/blob/main/main.py): `main.py`
- [Website scraping](https://github.com/kb-dhanush/smartleadgen/blob/main/firecrawler.py): `firecrawler.py`

### External services

- **Gemini**
- **FireCrawl API**

### Other components

- **Lead requester**

## Connections

- Lead requester → Streamlit interface: enters interest
- Streamlit interface → Lead workflow: requests leads
- Lead workflow → Lead generation: generates leads
- Lead generation → Gemini: invokes model
- Gemini → Response parsing: returns text
- Response parsing → Lead workflow: returns leads
- Lead workflow → Lead enrichment: enriches leads
- Lead enrichment → Website scraping: scrapes websites
- Website scraping → FireCrawl API: sends scrape request
- FireCrawl API → Website scraping: returns page data
- Lead enrichment → Lead workflow: returns enriched leads
- Lead workflow → Streamlit interface: returns leads
- Streamlit interface → Results and CSV: displays and exports
