# nayakanwesha885-spec/flask-app architecture

> Architecture diagram of the GitHub repository nayakanwesha885-spec/flask-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nayakanwesha885-spec/flask-app
- Repository: https://github.com/nayakanwesha885-spec/flask-app

## Overview

TATVA is a web-based Ayurveda intellectual-property and regulatory knowledge desk. A visitor can explore formulation-classification and access-and-benefit-sharing (ABS) guidance in the site, or submit a question with a topic and language. The `/ask` route validates and screens the question, retrieves relevant PDF-derived material, and returns an answer with source information; the app also has translation-provider code. The sampled excerpts do not show the complete answer-generation or translation call sites, so those connections are omitted. The classification and ABS capabilities appear as informational site content, not demonstrated backend workflows.

Main entry points: [`app.py`](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py) (Flask app), [`templates/index.html`](https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html) (TATVA site), [`static/script.js`](https://github.com/nayakanwesha885-spec/flask-app/blob/main/static/script.js) (Browser interactions), [`knowledge_base`](https://github.com/nayakanwesha885-spec/flask-app/tree/main/knowledge_base) (Knowledge PDFs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_site["TATVA site<br/>[index.html]"]
  node_browser["Browser interactions<br/>[script.js]"]
  node_site_styles["Site styling<br/>[style.css]"]
  node_classification["Formulation guide<br/>[index.html]"]
  node_abs_guide["ABS guidance<br/>[index.html]"]
end

subgraph group_request["Question handling"]
  node_flask["Flask app<br/>[app.py]"]
  node_validation["Input validation<br/>[app.py]"]
  node_safety["Safety screening<br/>[app.py]"]
  node_relevance["Relevance screening<br/>[app.py]"]
  node_rate_limit["Irrelevant request limit<br/>[app.py]"]
  node_response["Answer and sources<br/>[app.py]"]
end

subgraph group_knowledge["Knowledge retrieval"]
  node_retrieval["Page retrieval<br/>[app.py]"]
  node_pdf_loader["PDF text loading<br/>[app.py]"]
  node_local_cache[("Loaded page cache<br/>[app.py]")]
  node_pdf_corpus["Knowledge PDFs"]
  node_vector_search["Vector search<br/>[app.py]"]
  node_vector_store[("OpenAI vector store")]
end

subgraph group_providers["Language providers"]
  node_translation["Translation logic<br/>[app.py]"]
end

node_visitor(("Visitor"))
node_openai{{"OpenAI service"}}
node_gemini{{"Gemini service"}}

node_visitor -->|"opens"| node_site
node_site -->|"loads"| node_browser
node_site -->|"presents"| node_classification
node_site -->|"presents"| node_abs_guide
node_browser -->|"submits question"| node_flask
node_flask -->|"renders"| node_site
node_flask -->|"validates"| node_validation
node_flask -->|"screens"| node_safety
node_flask -->|"checks relevance"| node_relevance
node_flask -->|"limits irrelevant requests"| node_rate_limit
node_flask -->|"retrieves pages"| node_retrieval
node_retrieval -.->|"tries vector search"| node_vector_search
node_vector_search -.->|"searches store"| node_openai
node_openai -.->|"searches"| node_vector_store
node_retrieval -->|"scores pages"| node_local_cache
node_pdf_loader -->|"reads PDFs"| node_pdf_corpus
node_pdf_loader -->|"caches page text"| node_local_cache
node_flask -->|"loads at startup"| node_pdf_loader
node_flask -->|"builds response"| node_response
node_retrieval -->|"provides source pages"| node_response
node_translation -->|"requests translation"| node_gemini

click node_site "https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html"
click node_browser "https://github.com/nayakanwesha885-spec/flask-app/blob/main/static/script.js"
click node_site_styles "https://github.com/nayakanwesha885-spec/flask-app/blob/main/static/style.css"
click node_classification "https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html"
click node_abs_guide "https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html"
click node_flask "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_validation "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_safety "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_relevance "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_rate_limit "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_retrieval "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_pdf_loader "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_local_cache "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_pdf_corpus "https://github.com/nayakanwesha885-spec/flask-app/tree/main/knowledge_base"
click node_vector_search "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_response "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py"
click node_translation "https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.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_site,node_browser,node_site_styles,node_classification,node_abs_guide toneBlue
class node_flask,node_validation,node_safety,node_relevance,node_rate_limit,node_response toneAmber
class node_retrieval,node_pdf_loader,node_local_cache,node_pdf_corpus,node_vector_search,node_vector_store toneMint
class node_translation toneRose
class node_visitor,node_openai,node_gemini toneIndigo
```

## Components

### Web experience

- [TATVA site](https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html): `templates/index.html`
- [Browser interactions](https://github.com/nayakanwesha885-spec/flask-app/blob/main/static/script.js): `static/script.js`
- [Site styling](https://github.com/nayakanwesha885-spec/flask-app/blob/main/static/style.css): `static/style.css`
- [Formulation guide](https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html): `templates/index.html`
- [ABS guidance](https://github.com/nayakanwesha885-spec/flask-app/blob/main/templates/index.html): `templates/index.html`

### Question handling

- [Flask app](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Input validation](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Safety screening](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Relevance screening](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Irrelevant request limit](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Answer and sources](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`

### Knowledge retrieval

- [Page retrieval](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [PDF text loading](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Loaded page cache](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- [Knowledge PDFs](https://github.com/nayakanwesha885-spec/flask-app/tree/main/knowledge_base): `knowledge_base`
- [Vector search](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`
- **OpenAI vector store**

### Language providers

- [Translation logic](https://github.com/nayakanwesha885-spec/flask-app/blob/main/app.py): `app.py`

### Other components

- **Visitor**
- **OpenAI service**
- **Gemini service**

## Connections

- Visitor → TATVA site: opens
- TATVA site → Browser interactions: loads
- TATVA site → Formulation guide: presents
- TATVA site → ABS guidance: presents
- Browser interactions → Flask app: submits question
- Flask app → TATVA site: renders
- Flask app → Input validation: validates
- Flask app → Safety screening: screens
- Flask app → Relevance screening: checks relevance
- Flask app → Irrelevant request limit: limits irrelevant requests
- Flask app → Page retrieval: retrieves pages
- Page retrieval → Vector search: tries vector search
- Vector search → OpenAI service: searches store
- OpenAI service → OpenAI vector store: searches
- Page retrieval → Loaded page cache: scores pages
- PDF text loading → Knowledge PDFs: reads PDFs
- PDF text loading → Loaded page cache: caches page text
- Flask app → PDF text loading: loads at startup
- Flask app → Answer and sources: builds response
- Page retrieval → Answer and sources: provides source pages
- Translation logic → Gemini service: requests translation
