# Auto-Tender Gen: Intelligent Bid Document Generation

> Parses tender documents, then builds an outline, writes the chapters, and exports to Word, grounded in a company knowledge base.

- Period: 2025.12
- Status: Frozen
- Type: Original work by the author
- Tags: Long-document generation, RAG, LangGraph, Word export
- Code: https://github.com/baifan11/Auto-Tender-Gen
- Cover: https://me.ai-clover.com/covers/cover-auto-tender.webp
- Original: https://me.ai-clover.com/en/projects/auto-tender/

The time-consuming part of writing a bid isn't the writing — it's the finding: tender documents run to hundreds of pages, and company material is scattered everywhere. This tool's flow: the tender document (RFP) is parsed in, hybrid retrieval and reranking run over it together with the company knowledge base, a Planner first builds an outline from the tender requirements, a Writer generates chapter by chapter, the content is edited in a visual editor, and the result is exported to Word.

## The core flow

- **Parsing**: the tender document comes in, and text, the table-of-contents structure (TOC), and images are extracted automatically.
- **Planning**: the Planner deeply parses the tender requirements and generates a response-oriented bid outline — organized by scoring points and response requirements, not copied from the source document's own table of contents.
- **Writing**: the Writer retrieves the tender requirements and company knowledge in real time and writes chapter by chapter, each chapter written with the retrieved evidence in hand.
- **Editing and export**: the visual editor is a split-screen preview; structured scoring tables can be extracted and edited separately; one click exports to Word with the hierarchy preserved.

Orchestration is LangGraph's Planner–Writer collaboration: one side works out what to write and in what structure, the other puts it into words chapter by chapter, with retrieval anchoring both sides to the material in between.

## Why the retrieval is particular

In a few places it's more particular than a generic "RAG writes documents" setup. Document parsing doesn't just extract text; it processes the structure and the images too: images first get a detailed text description from a vision model (Gemini 2.0 Flash / GPT-4o) and are then indexed, so retrieval can "search images by text" — organization charts and flow diagrams inside tender documents are exactly the kind of content pure text retrieval can't find. Retrieval is a hybrid of vector search (pgvector) and Postgres full-text search, fine-ranked with DashScope's rerank model. Chunks are linked by their before/after relations (each chunk stores a Prev / Next ID), so when a chunk is hit, its context expands automatically — easing the problem of chunking cutting semantics apart. A company's own general material — qualifications, past cases, business licenses — lives separately in a corporate data center and is injected automatically as high-priority reference while writing, instead of being pasted in by hand for every chapter.

Models are scheduled separately: the four kinds — generation, multimodal, embedding, and rerank — are each configurable and can switch vendors dynamically (OpenAI, DeepSeek, Google Gemini, and Alibaba Tongyi have all been wired in), changeable either in the frontend's model-settings page or through environment variables. Combinations used in the configuration at the time included GPT-4o / DeepSeek-V3 / Qwen-Max for generation, text-embedding-3-small / gte-v2 for embeddings, and gte-rerank for reranking.

Stack: backend Python FastAPI + LangChain / LangGraph + SQLAlchemy, with database migrations via Alembic; frontend TypeScript + Next.js (App Router) + TailwindCSS + ShadcnUI; PostgreSQL (pgvector) storing relational data, vectors, and the full-text index in one place; MinIO for the original documents and the resources extracted by multimodal parsing; infrastructure brought up with Docker Compose. The backend also keeps two automated verification scripts: one checks the full system pipeline, the other specifically checks hybrid retrieval and vectorization.

## Boundaries

The blunt part, out in the open: I never ran this project through an end-to-end acceptance with a real tender document, so as to what level the generation quality actually reaches, I can only say the pipeline works and the code and product documentation are complete — the results are yet to be re-verified.

Code: the repository is not public yet.

## Diagrams

### Main flow

```mermaid
graph LR
  A[RFP document] --> B[Parse + extract]
  B --> C[Planner outline]
  C --> D[Writer drafting]
  K[(Corporate data center)] -.->|Priority injection| D
  R[Hybrid retrieval] -.-> D
  D --> E[Visual editor]
  E --> F[Word export]
```

### System architecture

```mermaid
graph TB
  subgraph L1["Frontend"]
    FE[Next.js editor]
  end
  subgraph L2["Backend"]
    API[FastAPI API]
    AG[LangGraph orchestration]
    RG[RAG retrieval service]
  end
  subgraph L3["Model layer"]
    LLM[Generation models]
    VLM[Vision models]
    EM[Embedding + rerank]
  end
  subgraph L4["Storage layer"]
    PG[(PostgreSQL + pgvector)]
    MN[(MinIO files)]
  end
  FE --> API --> AG
  AG --> RG
  RG --> PG
  AG --> LLM
  RG --> VLM
  RG --> EM
  API --> MN
```
