# vishal0205/knowflow-ai architecture

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

- Interactive diagram: https://gitdiagram.com/vishal0205/knowflow-ai
- Repository: https://github.com/vishal0205/knowflow-ai

## Overview

KnowFlow AI is an enterprise knowledge assistant: users submit policy questions, the API routes them through a permission-aware RAG workflow, and the response includes citations or an abstention. The sampled code confirms the API-to-pipeline flow, retrieval entry point, database access, reranking, answer generation, and query logging. The README is empty and several RAG modules were not sampled, so connections for ingestion, indexing, and hybrid retrieval internals are left unspecified.

Main entry points: [`app/rag/pipeline.py`](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/pipeline.py) (Answer pipeline), [`app/rag/retriever.py`](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/retriever.py) (Vector retrieval), [`app/main.py`](https://github.com/vishal0205/knowflow-ai/blob/main/app/main.py) (FastAPI service), [`frontend/src/App.jsx`](https://github.com/vishal0205/knowflow-ai/blob/main/frontend/src/App.jsx) (Question interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_webapp["Question interface<br/>[App.jsx]"]
end

subgraph group_api["API and orchestration"]
  node_api_service["FastAPI service<br/>[main.py]"]
  node_request_models["Query models<br/>[models.py]"]
  node_pipeline["Answer pipeline<br/>[pipeline.py]"]
  node_query_router["Query routing<br/>[query_router.py]"]
end

subgraph group_rag["Knowledge retrieval"]
  node_hybrid_search["Hybrid search<br/>[hybrid_search.py]"]
  node_reranker["Result reranking<br/>[reranker.py]"]
  node_answer_model["Answer generation<br/>[llm.py]"]
  node_ingestion["PDF ingestion<br/>[ingestion.py]"]
  node_retriever["Vector retrieval<br/>[retriever.py]"]
  node_embeddings["Embedding model<br/>[embeddings.py]"]
  node_vector_store["Vector storage<br/>[vector_store.py]"]
end

subgraph group_data["Persistence and observability"]
  node_database_engine["Database engine<br/>[database.py]"]
  node_db_models["Document records<br/>[models.py]"]
  node_logger["Query logging<br/>[logger.py]"]
end

node_employee(("Employee"))
node_postgres[("PostgreSQL")]
node_gemini["Gemini API"]

node_employee -->|"asks question"| node_webapp
node_webapp -->|"posts query"| node_api_service
node_api_service -->|"validates request"| node_request_models
node_api_service -->|"calls"| node_pipeline
node_pipeline -->|"routes query"| node_query_router
node_pipeline -->|"retrieves candidates"| node_hybrid_search
node_pipeline -->|"reranks results"| node_reranker
node_pipeline -->|"generates answer"| node_answer_model
node_pipeline -->|"logs query"| node_logger
node_retriever -->|"embeds query"| node_embeddings
node_retriever -->|"queries"| node_database_engine
node_retriever -->|"selects chunks"| node_db_models
node_database_engine -->|"connects"| node_postgres
node_answer_model -->|"generates content"| node_gemini

click node_webapp "https://github.com/vishal0205/knowflow-ai/blob/main/frontend/src/App.jsx"
click node_api_service "https://github.com/vishal0205/knowflow-ai/blob/main/app/main.py"
click node_request_models "https://github.com/vishal0205/knowflow-ai/blob/main/app/models.py"
click node_pipeline "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/pipeline.py"
click node_query_router "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/query_router.py"
click node_hybrid_search "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/hybrid_search.py"
click node_reranker "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/reranker.py"
click node_answer_model "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/llm.py"
click node_ingestion "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/ingestion.py"
click node_retriever "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/retriever.py"
click node_embeddings "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/embeddings.py"
click node_vector_store "https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/vector_store.py"
click node_database_engine "https://github.com/vishal0205/knowflow-ai/blob/main/app/db/database.py"
click node_db_models "https://github.com/vishal0205/knowflow-ai/blob/main/app/db/models.py"
click node_logger "https://github.com/vishal0205/knowflow-ai/blob/main/app/observability/logger.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_webapp toneBlue
class node_api_service,node_request_models,node_pipeline,node_query_router,node_postgres toneAmber
class node_hybrid_search,node_reranker,node_answer_model,node_ingestion,node_retriever,node_embeddings,node_vector_store,node_gemini toneMint
class node_database_engine,node_db_models,node_logger toneRose
class node_employee toneIndigo
```

## Components

### User interface

- [Question interface](https://github.com/vishal0205/knowflow-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### API and orchestration

- [FastAPI service](https://github.com/vishal0205/knowflow-ai/blob/main/app/main.py): `app/main.py`
- [Query models](https://github.com/vishal0205/knowflow-ai/blob/main/app/models.py): `app/models.py`
- [Answer pipeline](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/pipeline.py): `app/rag/pipeline.py`
- [Query routing](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/query_router.py): `app/rag/query_router.py`

### Knowledge retrieval

- [Hybrid search](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/hybrid_search.py): `app/rag/hybrid_search.py`
- [Result reranking](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/reranker.py): `app/rag/reranker.py`
- [Answer generation](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/llm.py): `app/rag/llm.py`
- [PDF ingestion](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/ingestion.py): `app/rag/ingestion.py`
- [Vector retrieval](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/retriever.py): `app/rag/retriever.py`
- [Embedding model](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/embeddings.py): `app/rag/embeddings.py`
- [Vector storage](https://github.com/vishal0205/knowflow-ai/blob/main/app/rag/vector_store.py): `app/rag/vector_store.py`

### Persistence and observability

- [Database engine](https://github.com/vishal0205/knowflow-ai/blob/main/app/db/database.py): `app/db/database.py`
- [Document records](https://github.com/vishal0205/knowflow-ai/blob/main/app/db/models.py): `app/db/models.py`
- [Query logging](https://github.com/vishal0205/knowflow-ai/blob/main/app/observability/logger.py): `app/observability/logger.py`

### Other components

- **Employee**
- **PostgreSQL**
- **Gemini API**

## Connections

- Employee → Question interface: asks question
- Question interface → FastAPI service: posts query
- FastAPI service → Query models: validates request
- FastAPI service → Answer pipeline: calls
- Answer pipeline → Query routing: routes query
- Answer pipeline → Hybrid search: retrieves candidates
- Answer pipeline → Result reranking: reranks results
- Answer pipeline → Answer generation: generates answer
- Answer pipeline → Query logging: logs query
- Vector retrieval → Embedding model: embeds query
- Vector retrieval → Database engine: queries
- Vector retrieval → Document records: selects chunks
- Database engine → PostgreSQL: connects
- Answer generation → Gemini API: generates content
