# niti007/freshkart-build-week architecture

> Architecture diagram of the GitHub repository niti007/freshkart-build-week, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/niti007/freshkart-build-week
- Repository: https://github.com/niti007/freshkart-build-week

## Overview

FreshKart is a customer-support bot with a Streamlit interface and a LangChain rules-and-reply pipeline. A customer message enters the app, the router extracts an order ID and gathers signals, Python policy rules select a route, and a route-specific LLM chain streams a reply. The app also displays order data and session-level operations and review queues. CSV files supply the bot’s records; chat history is in memory. The README documents the route capabilities; unsampled notebook details are not mapped.

Main entry points: [`bot.py`](https://github.com/niti007/freshkart-build-week/blob/main/bot.py) (Signal gathering), [`data`](https://github.com/niti007/freshkart-build-week/tree/main/data) (Business CSV records), [`app.py`](https://github.com/niti007/freshkart-build-week/blob/main/app.py) (Streamlit app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Support interface"]
  node_streamlit_app["Streamlit app<br/>[app.py]"]
  node_chat_ui["Chat and samples<br/>[app.py]"]
  node_ops_queue["Ops and review queue<br/>[app.py]"]
  node_data_view["Data and policy view<br/>[app.py]"]
end

subgraph group_pipeline["Support pipeline"]
  node_router["Request router<br/>[bot.py]"]
  node_order_id["Order ID extraction<br/>[bot.py]"]
  node_signal_gathering["Signal gathering<br/>[bot.py]"]
  node_intent_classifier["Intent classifier<br/>[bot.py]"]
  node_policy_router["Policy routing<br/>[bot.py]"]
  node_reply_chain["Route-specific replies<br/>[bot.py]"]
  node_chat_memory[("Chat history<br/>[bot.py]")]
end

subgraph group_records["Business records"]
  node_order_lookup["Order lookup<br/>[bot.py]"]
  node_customer_lookup["Customer lookup<br/>[bot.py]"]
  node_inventory_check["Inventory check<br/>[bot.py]"]
  node_rider_lookup["Rider lookup<br/>[bot.py]"]
  node_csv_records[("Business CSV records")]
end

subgraph group_services["External services"]
  node_llm_service{{"OpenRouter LLM"}}
end

node_customer(("Customer"))

node_customer -->|"sends message"| node_streamlit_app
node_streamlit_app -->|"renders"| node_chat_ui
node_chat_ui -->|"invokes"| node_router
node_chat_ui -->|"streams reply"| node_reply_chain
node_chat_ui -->|"loads and updates"| node_chat_memory
node_router -->|"extracts ID"| node_order_id
node_router -->|"gathers signals"| node_signal_gathering
node_signal_gathering -->|"classifies intent"| node_intent_classifier
node_signal_gathering -->|"looks up order"| node_order_lookup
node_signal_gathering -->|"looks up customer"| node_customer_lookup
node_signal_gathering -->|"checks inventory"| node_inventory_check
node_signal_gathering -->|"looks up rider"| node_rider_lookup
node_order_lookup -->|"reads"| node_csv_records
node_customer_lookup -->|"reads"| node_csv_records
node_inventory_check -->|"reads"| node_csv_records
node_rider_lookup -->|"reads"| node_csv_records
node_router -->|"applies rules"| node_policy_router
node_policy_router -->|"selects route"| node_reply_chain
node_reply_chain -->|"generates reply"| node_llm_service
node_intent_classifier -->|"classifies with"| node_llm_service
node_streamlit_app -->|"renders session log"| node_ops_queue
node_streamlit_app -->|"renders records"| node_data_view
node_data_view -->|"displays"| node_csv_records
node_ops_queue -.->|"shows review status"| node_customer

click node_streamlit_app "https://github.com/niti007/freshkart-build-week/blob/main/app.py"
click node_chat_ui "https://github.com/niti007/freshkart-build-week/blob/main/app.py"
click node_ops_queue "https://github.com/niti007/freshkart-build-week/blob/main/app.py"
click node_data_view "https://github.com/niti007/freshkart-build-week/blob/main/app.py"
click node_router "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_order_id "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_signal_gathering "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_intent_classifier "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_order_lookup "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_customer_lookup "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_inventory_check "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_rider_lookup "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_csv_records "https://github.com/niti007/freshkart-build-week/tree/main/data"
click node_policy_router "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_reply_chain "https://github.com/niti007/freshkart-build-week/blob/main/bot.py"
click node_chat_memory "https://github.com/niti007/freshkart-build-week/blob/main/bot.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_streamlit_app,node_chat_ui,node_ops_queue,node_data_view toneBlue
class node_router,node_order_id,node_signal_gathering,node_intent_classifier,node_policy_router,node_reply_chain,node_chat_memory toneAmber
class node_order_lookup,node_customer_lookup,node_inventory_check,node_rider_lookup,node_csv_records toneMint
class node_llm_service toneRose
class node_customer toneIndigo
```

## Components

### Support interface

- [Streamlit app](https://github.com/niti007/freshkart-build-week/blob/main/app.py): `app.py`
- [Chat and samples](https://github.com/niti007/freshkart-build-week/blob/main/app.py): `app.py`
- [Ops and review queue](https://github.com/niti007/freshkart-build-week/blob/main/app.py): `app.py`
- [Data and policy view](https://github.com/niti007/freshkart-build-week/blob/main/app.py): `app.py`

### Support pipeline

- [Request router](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Order ID extraction](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Signal gathering](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Intent classifier](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Policy routing](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Route-specific replies](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Chat history](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`

### Business records

- [Order lookup](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Customer lookup](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Inventory check](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Rider lookup](https://github.com/niti007/freshkart-build-week/blob/main/bot.py): `bot.py`
- [Business CSV records](https://github.com/niti007/freshkart-build-week/tree/main/data): `data`

### External services

- **OpenRouter LLM**

### Other components

- **Customer**

## Connections

- Customer → Streamlit app: sends message (evidence: `app.py`)
- Streamlit app → Chat and samples: renders (evidence: `app.py`)
- Chat and samples → Request router: invokes (evidence: `app.py`)
- Chat and samples → Route-specific replies: streams reply (evidence: `app.py`)
- Chat and samples → Chat history: loads and updates (evidence: `app.py`)
- Request router → Order ID extraction: extracts ID (evidence: `bot.py`)
- Request router → Signal gathering: gathers signals (evidence: `bot.py`)
- Signal gathering → Intent classifier: classifies intent (evidence: `bot.py`)
- Signal gathering → Order lookup: looks up order (evidence: `bot.py`)
- Signal gathering → Customer lookup: looks up customer (evidence: `bot.py`)
- Signal gathering → Inventory check: checks inventory (evidence: `bot.py`)
- Signal gathering → Rider lookup: looks up rider (evidence: `bot.py`)
- Order lookup → Business CSV records: reads (evidence: `bot.py`)
- Customer lookup → Business CSV records: reads (evidence: `bot.py`)
- Inventory check → Business CSV records: reads (evidence: `bot.py`)
- Rider lookup → Business CSV records: reads (evidence: `bot.py`)
- Request router → Policy routing: applies rules (evidence: `bot.py`)
- Policy routing → Route-specific replies: selects route (evidence: `bot.py`)
- Route-specific replies → OpenRouter LLM: generates reply (evidence: `bot.py`)
- Intent classifier → OpenRouter LLM: classifies with (evidence: `bot.py`)
- Streamlit app → Ops and review queue: renders session log (evidence: `app.py`)
- Streamlit app → Data and policy view: renders records (evidence: `app.py`)
- Data and policy view → Business CSV records: displays (evidence: `app.py`)
- Ops and review queue → Customer: shows review status (evidence: `app.py`)
