Architecture
The generate-all endpoint is a thin orchestrator that coordinates internal services. It returns immediately and runs all tasks in the background.
Execution Groups
| Group | Services | Waits For | Purpose |
|---|
| 1a | Scrape Website | Nothing | Get pages for GROUP 2 services |
| 1b | Discover Competitors | Nothing | Fire-and-forget, doesnβt block |
| 1c | Exa Prompts | Nothing | Fire-and-forget, doesnβt block |
| 1d | Fetch Favicon | Nothing | Fire-and-forget, doesnβt block |
| 1e | Materialize Score | Nothing | Fire-and-forget, doesnβt block |
| 1f | Setup CloudFront | Nothing | Fire-and-forget, doesnβt block |
| 2a | AI Website, Business Prompts | Group 1a | Uses scraped pages |
| 2b | Discover Products | Group 1a | Uses scraped pages |
| 3a | Product Prompts | Group 2b | Uses discovered products |
| 3b | Generate Product LLMs | Group 2b | Uses discovered products |
GROUP 3a and 3b run in parallel after products are discovered. This means product prompts and product llms.txt files are generated simultaneously.
Groups 1b-1f run in parallel with 1a but donβt block Group 2. This means
the main onboarding flow (scrape β create AI site β generate prompts) isnβt
slowed down by tasks that donβt need scraped pages.
Internal Services
Each service is documented on its own page:
| Service | Group | Input | Output | Page |
|---|
| Scrape Website | 1a | url | pages[] | View β |
| Discover Competitors | 1b | url, business_name | competitors[] | View β |
| Exa Prompts | 1c | org_slug, business_name, url | 10 pre-tested prompts | View β |
| Fetch Favicon | 1d | url, org_slug | favicon URL | View β |
| Materialize Score | 1e | url, org_slug | visibility score | View β |
| Setup CloudFront | 1f | url, org_slug | CloudFront distribution | View β |
| Create AI Website | 2a | url, org_slug, pages[] | AI site URL | View β |
| Business Prompts | 2a | url, org_slug, pages[] | 40 prompts | View β |
| Discover Products | 2b | url, org_slug, pages[] | products[] | View β |
| Product Prompts | 3a | url, org_slug, products[], pages[] | 10 prompts/product | View β |
| Generate Product LLMs | 3b | url, org_slug, products[], pages[] | llms.txt files | View β |
Data Flow
scrape_website(url)
β
βββ pages[] βββββββββββββββββββββββββββββββββββββββββββ
β β
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β create_ai_websiteβ β business_prompts β β discover_productsβ
β (pages[]) β β (pages[]) β β (pages[]) β
βββββββββββββββββββ βββββββββββββββββββ ββββββββββ¬βββββββββ
β
βββββββββββ΄ββββββββββ
βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ
β product_prompts β βgenerate_product β
β (products[]) β β _llms_txt β
β GROUP 3a β β GROUP 3b β
βββββββββββββββββββ βββββββββββββββββββ
β β
βββββββββββ¬ββββββββββ
β
(parallel)
Tasks that DON'T need pages[] (run in parallel with scrape):
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
β favicon β β scoring β β cloudfront β
ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ
ββββββββββββββββ ββββββββββββββββ
β competitors β β exa_prompts β
ββββββββββββββββ ββββββββββββββββ
Code Location
src/app/apis/onboarding/
βββ generate_all/
β βββ routes.py # Main orchestrator (GROUP 1a-1f)
β βββ models.py # Pydantic models
β βββ scrape_website.py # GROUP 1a: Scrape service wrapper
β βββ exa_prompts.py # GROUP 1c: Exa prompts service
β βββ task_orchestrator.py # GROUP 2 and 3 coordinator
β βββ tasks/ # Individual task wrappers
β βββ ai_website.py # GROUP 2a
β βββ cloudfront.py # GROUP 1f
β βββ discover_products.py # GROUP 2b
β βββ favicon.py # GROUP 1d
β βββ prompts.py # GROUP 2a + 3a
β βββ product_llms.py # GROUP 3b
β βββ scoring.py # GROUP 1e
βββ services/
βββ discover_competitors/ # GROUP 1b: Competitor discovery service
src/app/shared/products/ # Shared services used by both onboarding and cron
βββ discover.py # Product discovery service
βββ generate_llms_txt.py # Product llms.txt generation service
Testing Individual Services
Each service can be tested independently via pytest:
# Test the orchestrator
uv run pytest src/pytests/onboarding/test_generate_all.py -v
# Test shared services used by generate-all
uv run pytest src/pytests/cron/test_generate_prompts.py -v