# vinukj/microbi-bot architecture

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

- Interactive diagram: https://gitdiagram.com/vinukj/microbi-bot
- Repository: https://github.com/vinukj/microbi-bot

## Overview

Microbi-Agri Bot is a Streamlit assistant that gives farmers conversational, personalized organic-farming advice. Farmers enter questions and farming interests; the app retrieves relevant PDF knowledge, generates an answer, and displays the conversation. Its knowledge base can be extended by uploading or manually placing documents, converting Word files to PDFs, and indexing extracted text in Chroma. The README also describes online-resource search, though the sampled code does not establish its implementation. Edges reflect sampled calls or documented workflows; reindexing is a separate maintenance path.

Main entry points: [`reindex.py`](https://github.com/vinukj/microbi-bot/blob/main/reindex.py) (Full reindex), [`ui2.py`](https://github.com/vinukj/microbi-bot/blob/main/ui2.py) (Incremental ingestion), [`tempfolder`](https://github.com/vinukj/microbi-bot/tree/main/tempfolder) (PDF collection), [`custom_loaders.py`](https://github.com/vinukj/microbi-bot/blob/main/custom_loaders.py) (PDF text extraction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["Farmer interaction"]
  node_app["Streamlit app<br/>[ui2.py]"]
  node_profile["Farm profile and language<br/>[ui2.py]"]
  node_chat["Chat and history<br/>[ui2.py]"]
end

subgraph group_knowledge["Knowledge ingestion"]
  node_uploads["Document uploads<br/>[ui2.py]"]
  node_worddocs["Word documents"]
  node_pdf_conversion["Word-to-PDF conversion"]
  node_pdfs["PDF collection"]
  node_ingestion["Incremental ingestion<br/>[ui2.py]"]
  node_pdf_loader["PDF text extraction<br/>[custom_loaders.py]"]
  node_chunking["Text chunking<br/>[ui2.py]"]
  node_embeddings["Cohere embeddings<br/>[ui2.py]"]
  node_vector_store[("Chroma knowledge base<br/>[ui2.py]")]
end

subgraph group_answering["Answer generation"]
  node_retrieval["Relevant context retrieval<br/>[ui2.py]"]
  node_qa["Retrieval QA<br/>[ui2.py]"]
  node_cohere_llm["Cohere response generation<br/>[ui2.py]"]
  node_online_resources["Online resources"]
end

subgraph group_maintenance["Index maintenance"]
  node_reindex["Full reindex<br/>[reindex.py]"]
  node_tracker[("Processed-file tracker")]
end

node_farmer(("Farmer"))

node_farmer -->|"asks questions"| node_app
node_app -->|"collects interests"| node_profile
node_app -->|"accepts and displays"| node_chat
node_app -->|"offers upload"| node_uploads
node_uploads -->|"saves Word files"| node_worddocs
node_uploads -->|"saves PDFs"| node_pdfs
node_worddocs -->|"converts"| node_pdf_conversion
node_pdf_conversion -->|"writes PDFs"| node_pdfs
node_uploads -->|"processes new PDF"| node_ingestion
node_pdfs -->|"checks new PDFs"| node_ingestion
node_ingestion -->|"loads PDF text"| node_pdf_loader
node_pdf_loader -->|"returns page text"| node_chunking
node_ingestion -->|"splits documents"| node_chunking
node_chunking -->|"vectorizes chunks"| node_embeddings
node_ingestion -->|"adds documents"| node_vector_store
node_embeddings -->|"indexes vectors"| node_vector_store
node_chat -->|"submits query"| node_qa
node_qa -->|"gets relevant context"| node_retrieval
node_retrieval -->|"searches knowledge"| node_vector_store
node_qa -->|"generates answer"| node_cohere_llm
node_profile -->|"sets response language"| node_cohere_llm
node_cohere_llm -->|"returns response"| node_chat
node_qa -.->|"may search"| node_online_resources
node_reindex -->|"reads PDFs"| node_pdfs
node_reindex -->|"loads PDF text"| node_pdf_loader
node_reindex -->|"splits documents"| node_chunking
node_reindex -->|"creates embeddings"| node_embeddings
node_reindex -->|"recreates index"| node_vector_store
node_ingestion -->|"records processed files"| node_tracker
node_reindex -->|"rewrites tracker"| node_tracker

click node_app "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_profile "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_chat "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_uploads "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_worddocs "https://github.com/vinukj/microbi-bot/tree/main/worddocs"
click node_pdf_conversion "https://github.com/vinukj/microbi-bot/blob/main/convert_docs_to_pdf.py"
click node_pdfs "https://github.com/vinukj/microbi-bot/tree/main/tempfolder"
click node_ingestion "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_pdf_loader "https://github.com/vinukj/microbi-bot/blob/main/custom_loaders.py"
click node_chunking "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_embeddings "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_vector_store "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_retrieval "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_qa "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_cohere_llm "https://github.com/vinukj/microbi-bot/blob/main/ui2.py"
click node_reindex "https://github.com/vinukj/microbi-bot/blob/main/reindex.py"
click node_tracker "https://github.com/vinukj/microbi-bot/blob/main/.processed_pdfs.json"

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_profile,node_chat toneBlue
class node_uploads,node_worddocs,node_pdf_conversion,node_pdfs,node_ingestion,node_pdf_loader,node_chunking,node_embeddings,node_vector_store toneAmber
class node_retrieval,node_qa,node_cohere_llm,node_online_resources toneMint
class node_reindex,node_tracker toneRose
class node_farmer toneIndigo
```

## Components

### Farmer interaction

- [Streamlit app](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Farm profile and language](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Chat and history](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`

### Knowledge ingestion

- [Document uploads](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Word documents](https://github.com/vinukj/microbi-bot/tree/main/worddocs): `worddocs`
- [Word-to-PDF conversion](https://github.com/vinukj/microbi-bot/blob/main/convert_docs_to_pdf.py): `convert_docs_to_pdf.py`
- [PDF collection](https://github.com/vinukj/microbi-bot/tree/main/tempfolder): `tempfolder`
- [Incremental ingestion](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [PDF text extraction](https://github.com/vinukj/microbi-bot/blob/main/custom_loaders.py): `custom_loaders.py`
- [Text chunking](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Cohere embeddings](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Chroma knowledge base](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`

### Answer generation

- [Relevant context retrieval](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Retrieval QA](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- [Cohere response generation](https://github.com/vinukj/microbi-bot/blob/main/ui2.py): `ui2.py`
- **Online resources**

### Index maintenance

- [Full reindex](https://github.com/vinukj/microbi-bot/blob/main/reindex.py): `reindex.py`
- [Processed-file tracker](https://github.com/vinukj/microbi-bot/blob/main/.processed_pdfs.json): `.processed_pdfs.json`

### Other components

- **Farmer**

## Connections

- Farmer → Streamlit app: asks questions (evidence: `README.md`)
- Streamlit app → Farm profile and language: collects interests (evidence: `README.md`)
- Streamlit app → Chat and history: accepts and displays (evidence: `ui2.py`)
- Streamlit app → Document uploads: offers upload (evidence: `README.md`)
- Document uploads → Word documents: saves Word files (evidence: `README.md`)
- Document uploads → PDF collection: saves PDFs (evidence: `README.md`)
- Word documents → Word-to-PDF conversion: converts (evidence: `README.md`)
- Word-to-PDF conversion → PDF collection: writes PDFs (evidence: `convert_docs_to_pdf.py`)
- Document uploads → Incremental ingestion: processes new PDF (evidence: `ui2.py`)
- PDF collection → Incremental ingestion: checks new PDFs (evidence: `README.md`)
- Incremental ingestion → PDF text extraction: loads PDF text (evidence: `ui2.py`)
- PDF text extraction → Text chunking: returns page text (evidence: `custom_loaders.py`)
- Incremental ingestion → Text chunking: splits documents (evidence: `ui2.py`)
- Text chunking → Cohere embeddings: vectorizes chunks (evidence: `README.md`)
- Incremental ingestion → Chroma knowledge base: adds documents (evidence: `ui2.py`)
- Cohere embeddings → Chroma knowledge base: indexes vectors (evidence: `README.md`)
- Chat and history → Retrieval QA: submits query (evidence: `ui2.py`)
- Retrieval QA → Relevant context retrieval: gets relevant context (evidence: `ui2.py`)
- Relevant context retrieval → Chroma knowledge base: searches knowledge (evidence: `README.md`)
- Retrieval QA → Cohere response generation: generates answer (evidence: `README.md`)
- Farm profile and language → Cohere response generation: sets response language (evidence: `ui2.py`)
- Cohere response generation → Chat and history: returns response (evidence: `ui2.py`)
- Retrieval QA → Online resources: may search (evidence: `README.md`)
- Full reindex → PDF collection: reads PDFs (evidence: `reindex.py`)
- Full reindex → PDF text extraction: loads PDF text (evidence: `reindex.py`)
- Full reindex → Text chunking: splits documents (evidence: `reindex.py`)
- Full reindex → Cohere embeddings: creates embeddings (evidence: `reindex.py`)
- Full reindex → Chroma knowledge base: recreates index (evidence: `reindex.py`)
- Incremental ingestion → Processed-file tracker: records processed files (evidence: `README.md`)
- Full reindex → Processed-file tracker: rewrites tracker (evidence: `reindex.py`)
