# archiecodespiece/saharachatbot architecture

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

- Interactive diagram: https://gitdiagram.com/archiecodespiece/saharachatbot
- Repository: https://github.com/archiecodespiece/saharachatbot

## Overview

Sahara is a Flask cancer-care chatbot intended to combine empathetic conversation with document-grounded answers, plus medical-image analysis and pharmacy discovery. The README describes the user-facing capabilities, but the Flask routes and chat orchestration were not excerpted, so their internal connections to retrieval, prompts, and optional features cannot be verified. The shown indexing code loads and chunks a PDF, creates embeddings, and writes to Pinecone; the image and pharmacy modules show their own model and service calls.

Main entry points: [`streindex.py`](https://github.com/archiecodespiece/saharachatbot/blob/main/streindex.py) (Indexing workflow), [`templates/chat.html`](https://github.com/archiecodespiece/saharachatbot/blob/main/templates/chat.html) (Chat interface), [`imagedet.py`](https://github.com/archiecodespiece/saharachatbot/blob/main/imagedet.py) (YOLO image analysis), [`map.py`](https://github.com/archiecodespiece/saharachatbot/blob/main/map.py) (Pharmacy recommendation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_chat["Chat experience"]
  node_chat_ui["Chat interface<br/>[chat.html]"]
  node_styles["UI styling<br/>[style.css]"]
  node_flask["Flask application<br/>[app.py]"]
  node_prompt["Care prompt<br/>[prompt.py]"]
end

subgraph group_knowledge["Document knowledge"]
  node_pdf["Cancer PDF<br/>[goku.pdf]"]
  node_loader["PDF loading<br/>[modelenc.py]"]
  node_chunker["Text chunking<br/>[modelenc.py]"]
  node_embeddings["Embedding generation<br/>[modelenc.py]"]
  node_indexer["Indexing workflow<br/>[streindex.py]"]
  node_pinecone[("Pinecone index")]
end

subgraph group_image["Image analysis"]
  node_image_upload["Medical image"]
  node_image_analysis["YOLO image analysis<br/>[imagedet.py]"]
  node_yolo_model["YOLO weights<br/>[best.pt]"]
end

subgraph group_discovery["Pharmacy discovery"]
  node_pharmacy["Pharmacy query"]
  node_recommend["Pharmacy recommendation<br/>[map.py]"]
  node_nominatim{{"Nominatim search"}}
end

node_user(("User"))
node_groq{{"Groq LLM"}}

node_user -->|"uses"| node_chat_ui
node_chat_ui -.->|"chat request"| node_flask
node_chat_ui -.->|"styled by"| node_styles
node_pdf -->|"indexed from"| node_indexer
node_indexer -->|"loads"| node_loader
node_indexer -->|"chunks"| node_chunker
node_indexer -->|"creates"| node_embeddings
node_indexer -->|"writes documents"| node_pinecone
node_image_upload -->|"analyzed by"| node_image_analysis
node_image_analysis -->|"loads"| node_yolo_model
node_image_analysis -->|"prompts"| node_groq
node_pharmacy -.->|"checked by"| node_recommend
node_recommend -->|"classifies and formats"| node_groq
node_recommend -->|"searches"| node_nominatim

click node_chat_ui "https://github.com/archiecodespiece/saharachatbot/blob/main/templates/chat.html"
click node_styles "https://github.com/archiecodespiece/saharachatbot/blob/main/static/style.css"
click node_flask "https://github.com/archiecodespiece/saharachatbot/blob/main/app.py"
click node_prompt "https://github.com/archiecodespiece/saharachatbot/blob/main/prompt.py"
click node_pdf "https://github.com/archiecodespiece/saharachatbot/blob/main/goku.pdf"
click node_loader "https://github.com/archiecodespiece/saharachatbot/blob/main/src/modelenc.py"
click node_chunker "https://github.com/archiecodespiece/saharachatbot/blob/main/src/modelenc.py"
click node_embeddings "https://github.com/archiecodespiece/saharachatbot/blob/main/src/modelenc.py"
click node_indexer "https://github.com/archiecodespiece/saharachatbot/blob/main/streindex.py"
click node_image_analysis "https://github.com/archiecodespiece/saharachatbot/blob/main/imagedet.py"
click node_yolo_model "https://github.com/archiecodespiece/saharachatbot/blob/main/best.pt"
click node_recommend "https://github.com/archiecodespiece/saharachatbot/blob/main/map.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_chat_ui,node_styles,node_flask,node_prompt,node_user toneBlue
class node_pdf,node_loader,node_chunker,node_embeddings,node_indexer,node_pinecone toneAmber
class node_image_upload,node_image_analysis,node_yolo_model toneMint
class node_pharmacy,node_recommend,node_nominatim toneRose
class node_groq toneIndigo
```

## Components

### Chat experience

- [Chat interface](https://github.com/archiecodespiece/saharachatbot/blob/main/templates/chat.html): `templates/chat.html`
- [UI styling](https://github.com/archiecodespiece/saharachatbot/blob/main/static/style.css): `static/style.css`
- [Flask application](https://github.com/archiecodespiece/saharachatbot/blob/main/app.py): `app.py`
- [Care prompt](https://github.com/archiecodespiece/saharachatbot/blob/main/prompt.py): `prompt.py`

### Document knowledge

- [Cancer PDF](https://github.com/archiecodespiece/saharachatbot/blob/main/goku.pdf): `goku.pdf`
- [PDF loading](https://github.com/archiecodespiece/saharachatbot/blob/main/src/modelenc.py): `src/modelenc.py`
- [Text chunking](https://github.com/archiecodespiece/saharachatbot/blob/main/src/modelenc.py): `src/modelenc.py`
- [Embedding generation](https://github.com/archiecodespiece/saharachatbot/blob/main/src/modelenc.py): `src/modelenc.py`
- [Indexing workflow](https://github.com/archiecodespiece/saharachatbot/blob/main/streindex.py): `streindex.py`
- **Pinecone index**

### Image analysis

- **Medical image**
- [YOLO image analysis](https://github.com/archiecodespiece/saharachatbot/blob/main/imagedet.py): `imagedet.py`
- [YOLO weights](https://github.com/archiecodespiece/saharachatbot/blob/main/best.pt): `best.pt`

### Pharmacy discovery

- **Pharmacy query**
- [Pharmacy recommendation](https://github.com/archiecodespiece/saharachatbot/blob/main/map.py): `map.py`
- **Nominatim search**

### Other components

- **User**
- **Groq LLM**

## Connections

- User → Chat interface: uses (evidence: `README.md`)
- Chat interface → Flask application: chat request
- Chat interface → UI styling: styled by
- Cancer PDF → Indexing workflow: indexed from (evidence: `streindex.py`)
- Indexing workflow → PDF loading: loads (evidence: `streindex.py`)
- Indexing workflow → Text chunking: chunks (evidence: `streindex.py`)
- Indexing workflow → Embedding generation: creates (evidence: `streindex.py`)
- Indexing workflow → Pinecone index: writes documents (evidence: `streindex.py`)
- Medical image → YOLO image analysis: analyzed by (evidence: `README.md`)
- YOLO image analysis → YOLO weights: loads (evidence: `imagedet.py`)
- YOLO image analysis → Groq LLM: prompts (evidence: `imagedet.py`)
- Pharmacy query → Pharmacy recommendation: checked by
- Pharmacy recommendation → Groq LLM: classifies and formats (evidence: `map.py`)
- Pharmacy recommendation → Nominatim search: searches (evidence: `map.py`)
