# cfradar/sheetfill architecture

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

- Interactive diagram: https://gitdiagram.com/cfradar/sheetfill
- Repository: https://github.com/cfradar/sheetfill

## Overview

Flipkart T-Shirt Listing Automation turns a draft listing workbook and product JSON into a completed `.xlsm`, while preserving macros and other package members. In the main workflow, a user uploads a sheet, the app detects designs, accepts or matches product JSON, previews generated rows, and downloads a rebuilt workbook. A separate keyword-agent capability plans marketplace/social research and synthesizes results with an LLM. The map also includes the reusable workbook-filling core and application state. Some subsystem links rely on README or source-index references; unsampled details are not assumed.

Main entry points: [`app/api/sheets.py`](https://github.com/cfradar/sheetfill/blob/main/app/api/sheets.py) (Sheets API), [`app/keyword_agent/service.py`](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/service.py) (Research orchestrator), [`src/flipkart_filler/rows.py`](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/rows.py) (Row generation), [`app/services/writer.py`](https://github.com/cfradar/sheetfill/blob/main/app/services/writer.py) (Workbook writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web workspace"]
  node_frontend["Workspace UI<br/>[App.tsx]"]
  node_upload["Sheet upload<br/>[UploadStep.tsx]"]
  node_workspace["Design editor<br/>[Workspace.tsx]"]
  node_keywordui["Keyword-agent UI"]
end

subgraph group_sheets["Sheet workflow"]
  node_api["Sheets API<br/>[sheets.py]"]
  node_reader["Sheet reader<br/>[sheet_reader.py]"]
  node_detector["Design detection<br/>[design_detector.py]"]
  node_matcher["Bulk matcher<br/>[bulk_matcher.py]"]
  node_store[("Workspace store<br/>[design_store.py]")]
  node_builder["Design builder<br/>[builder.py]"]
  node_writer["Workbook writer<br/>[writer.py]"]
end

subgraph group_filler["Workbook core"]
  node_models["Product and row models<br/>[models.py]"]
  node_json["JSON loader<br/>[json_loader.py]"]
  node_mapper["Value mapper<br/>[mapper.py]"]
  node_rows["Row generation<br/>[rows.py]"]
  node_text["Text builders<br/>[text_builders.py]"]
  node_patch["XLSX patcher<br/>[xlsx_patch.py]"]
end

subgraph group_keyword["Keyword research"]
  node_keywordrouter["Keyword API<br/>[router.py]"]
  node_service["Research orchestrator<br/>[service.py]"]
  node_planner["Query planner<br/>[planner.py]"]
  node_market["Marketplace scraper"]
  node_social["Social scraper<br/>[social_scraper.py]"]
  node_analyst["Results analyst<br/>[analyst.py]"]
end

subgraph group_platform["Platform services"]
  node_mongo[("MongoDB")]
end

node_user(("User"))
node_llm{{"OpenRouter"}}
node_external{{"Market and social sites"}}

node_user -->|"uploads sheet"| node_upload
node_upload -->|"opens workspace"| node_frontend
node_frontend -->|"shows session"| node_workspace
node_frontend -->|"HTTP requests"| node_api
node_api -->|"reads workbook"| node_reader
node_api -->|"detects designs"| node_detector
node_detector -->|"reads rows"| node_reader
node_api -->|"loads session"| node_store
node_api -->|"matches JSON"| node_matcher
node_api -->|"builds preview rows"| node_builder
node_api -->|"rebuilds workbook"| node_writer
node_builder -->|"maps values"| node_mapper
node_builder -->|"generates rows"| node_rows
node_rows -->|"builds descriptions"| node_text
node_rows -->|"uses mappings"| node_mapper
node_writer -->|"patches workbook"| node_patch
node_writer -->|"writes generated rows"| node_rows
node_json -->|"parses product"| node_models
node_mapper -->|"maps product values"| node_models
node_rows -->|"creates row records"| node_models
node_patch -->|"uses row records"| node_models
node_writer -->|"provides download"| node_user
node_user -.->|"starts research"| node_keywordui
node_keywordui -.->|"API requests"| node_keywordrouter
node_keywordrouter -->|"starts run"| node_service
node_service -->|"plans searches"| node_planner
node_service -->|"scrapes products"| node_market
node_service -->|"scrapes social"| node_social
node_service -->|"synthesizes results"| node_analyst
node_planner -.->|"requests planning"| node_llm
node_analyst -->|"requests analysis"| node_llm
node_service -.->|"persists results"| node_mongo
node_market -.->|"collects listings"| node_external
node_social -.->|"collects posts"| node_external

click node_frontend "https://github.com/cfradar/sheetfill/blob/main/frontend/src/App.tsx"
click node_upload "https://github.com/cfradar/sheetfill/blob/main/frontend/src/components/UploadStep.tsx"
click node_workspace "https://github.com/cfradar/sheetfill/blob/main/frontend/src/workspace/Workspace.tsx"
click node_api "https://github.com/cfradar/sheetfill/blob/main/app/api/sheets.py"
click node_reader "https://github.com/cfradar/sheetfill/blob/main/app/services/sheet_reader.py"
click node_detector "https://github.com/cfradar/sheetfill/blob/main/app/services/design_detector.py"
click node_matcher "https://github.com/cfradar/sheetfill/blob/main/app/services/bulk_matcher.py"
click node_store "https://github.com/cfradar/sheetfill/blob/main/app/services/design_store.py"
click node_builder "https://github.com/cfradar/sheetfill/blob/main/app/services/builder.py"
click node_writer "https://github.com/cfradar/sheetfill/blob/main/app/services/writer.py"
click node_models "https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/models.py"
click node_json "https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/json_loader.py"
click node_mapper "https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/mapper.py"
click node_rows "https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/rows.py"
click node_text "https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/text_builders.py"
click node_patch "https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/xlsx_patch.py"
click node_keywordui "https://github.com/cfradar/sheetfill/blob/main/frontend/src/features/keyword-agent/components/KeywordAgentPage.tsx"
click node_keywordrouter "https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/router.py"
click node_service "https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/service.py"
click node_planner "https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/planner.py"
click node_market "https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/marketplace_scraper.py"
click node_social "https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/social_scraper.py"
click node_analyst "https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/analyst.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_frontend,node_upload,node_workspace,node_keywordui,node_user toneBlue
class node_api,node_reader,node_detector,node_matcher,node_store,node_builder,node_writer toneAmber
class node_models,node_json,node_mapper,node_rows,node_text,node_patch,node_llm toneMint
class node_keywordrouter,node_service,node_planner,node_market,node_social,node_analyst toneRose
class node_mongo,node_external toneIndigo
```

## Components

### Web workspace

- [Workspace UI](https://github.com/cfradar/sheetfill/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sheet upload](https://github.com/cfradar/sheetfill/blob/main/frontend/src/components/UploadStep.tsx): `frontend/src/components/UploadStep.tsx`
- [Design editor](https://github.com/cfradar/sheetfill/blob/main/frontend/src/workspace/Workspace.tsx): `frontend/src/workspace/Workspace.tsx`
- [Keyword-agent UI](https://github.com/cfradar/sheetfill/blob/main/frontend/src/features/keyword-agent/components/KeywordAgentPage.tsx): `frontend/src/features/keyword-agent/components/KeywordAgentPage.tsx`

### Sheet workflow

- [Sheets API](https://github.com/cfradar/sheetfill/blob/main/app/api/sheets.py): `app/api/sheets.py`
- [Sheet reader](https://github.com/cfradar/sheetfill/blob/main/app/services/sheet_reader.py): `app/services/sheet_reader.py`
- [Design detection](https://github.com/cfradar/sheetfill/blob/main/app/services/design_detector.py): `app/services/design_detector.py`
- [Bulk matcher](https://github.com/cfradar/sheetfill/blob/main/app/services/bulk_matcher.py): `app/services/bulk_matcher.py`
- [Workspace store](https://github.com/cfradar/sheetfill/blob/main/app/services/design_store.py): `app/services/design_store.py`
- [Design builder](https://github.com/cfradar/sheetfill/blob/main/app/services/builder.py): `app/services/builder.py`
- [Workbook writer](https://github.com/cfradar/sheetfill/blob/main/app/services/writer.py): `app/services/writer.py`

### Workbook core

- [Product and row models](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/models.py): `src/flipkart_filler/models.py`
- [JSON loader](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/json_loader.py): `src/flipkart_filler/json_loader.py`
- [Value mapper](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/mapper.py): `src/flipkart_filler/mapper.py`
- [Row generation](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/rows.py): `src/flipkart_filler/rows.py`
- [Text builders](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/text_builders.py): `src/flipkart_filler/text_builders.py`
- [XLSX patcher](https://github.com/cfradar/sheetfill/blob/main/src/flipkart_filler/xlsx_patch.py): `src/flipkart_filler/xlsx_patch.py`

### Keyword research

- [Keyword API](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/router.py): `app/keyword_agent/router.py`
- [Research orchestrator](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/service.py): `app/keyword_agent/service.py`
- [Query planner](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/planner.py): `app/keyword_agent/agents/planner.py`
- [Marketplace scraper](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/marketplace_scraper.py): `app/keyword_agent/agents/marketplace_scraper.py`
- [Social scraper](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/social_scraper.py): `app/keyword_agent/agents/social_scraper.py`
- [Results analyst](https://github.com/cfradar/sheetfill/blob/main/app/keyword_agent/agents/analyst.py): `app/keyword_agent/agents/analyst.py`

### Platform services

- **MongoDB**

### Other components

- **User**
- **OpenRouter**
- **Market and social sites**

## Connections

- User → Sheet upload: uploads sheet
- Sheet upload → Workspace UI: opens workspace (evidence: `frontend/src/App.tsx`)
- Workspace UI → Design editor: shows session (evidence: `frontend/src/App.tsx`)
- Workspace UI → Sheets API: HTTP requests
- Sheets API → Sheet reader: reads workbook (evidence: `app/api/sheets.py`)
- Sheets API → Design detection: detects designs (evidence: `app/api/sheets.py`)
- Design detection → Sheet reader: reads rows (evidence: `app/services/design_detector.py`)
- Sheets API → Workspace store: loads session (evidence: `app/api/sheets.py`)
- Sheets API → Bulk matcher: matches JSON (evidence: `app/api/sheets.py`)
- Sheets API → Design builder: builds preview rows (evidence: `app/api/sheets.py`)
- Sheets API → Workbook writer: rebuilds workbook (evidence: `app/api/sheets.py`)
- Design builder → Value mapper: maps values (evidence: `app/services/builder.py`)
- Design builder → Row generation: generates rows (evidence: `app/services/builder.py`)
- Row generation → Text builders: builds descriptions (evidence: `src/flipkart_filler/rows.py`)
- Row generation → Value mapper: uses mappings (evidence: `src/flipkart_filler/rows.py`)
- Workbook writer → XLSX patcher: patches workbook (evidence: `app/services/writer.py`)
- Workbook writer → Row generation: writes generated rows (evidence: `app/services/writer.py`)
- JSON loader → Product and row models: parses product (evidence: `src/flipkart_filler/json_loader.py`)
- Value mapper → Product and row models: maps product values (evidence: `src/flipkart_filler/mapper.py`)
- Row generation → Product and row models: creates row records (evidence: `src/flipkart_filler/rows.py`)
- XLSX patcher → Product and row models: uses row records (evidence: `src/flipkart_filler/xlsx_patch.py`)
- Workbook writer → User: provides download
- User → Keyword-agent UI: starts research
- Keyword-agent UI → Keyword API: API requests
- Keyword API → Research orchestrator: starts run (evidence: `app/keyword_agent/router.py`)
- Research orchestrator → Query planner: plans searches (evidence: `app/keyword_agent/service.py`)
- Research orchestrator → Marketplace scraper: scrapes products (evidence: `app/keyword_agent/service.py`)
- Research orchestrator → Social scraper: scrapes social (evidence: `app/keyword_agent/service.py`)
- Research orchestrator → Results analyst: synthesizes results (evidence: `app/keyword_agent/service.py`)
- Query planner → OpenRouter: requests planning
- Results analyst → OpenRouter: requests analysis (evidence: `app/keyword_agent/agents/analyst.py`)
- Research orchestrator → MongoDB: persists results
- Marketplace scraper → Market and social sites: collects listings
- Social scraper → Market and social sites: collects posts
