# jinendra12kumar/parcelpilot-ai-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/jinendra12kumar/parcelpilot-ai-chatbot
- Repository: https://github.com/jinendra12kumar/parcelpilot-ai-chatbot

## Overview

ParcelPilot AI is a support-operations copilot: agents ask questions in the React chat, the FastAPI API supplies identity and thread context, and a LangGraph agent returns answers or pauses for human confirmation before escalation. Its domain paths include policy/document retrieval, account/order/ticket lookup, SLA-credit calculation, and authorized escalation; document indexing and structured-data access support those paths. The README documents streaming and role/account isolation capabilities, though the sampled excerpts do not establish all their internal links. Edges are limited to excerpted calls, indexed references, or documented interactions.

Main entry points: [`app/agent/graph.py`](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/agent/graph.py) (LangGraph agent), [`frontend/src/App.tsx`](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/App.tsx) (Chat application), [`app/api/chat.py`](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/chat.py) (Chat endpoints), [`app/tools/document_search.py`](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/document_search.py) (Document search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_chat_ui["Chat application<br/>[App.tsx]"]
  node_chat_controls["Chat controls"]
  node_confirmation_ui["Confirmation card"]
  node_session_sidebar["Session sidebar<br/>[Sidebar.tsx]"]
  node_api_client["API client<br/>[api.ts]"]
end

subgraph group_api["API and identity"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_chat_routes["Chat endpoints<br/>[chat.py]"]
  node_stream_routes["Streaming endpoint<br/>[chat_stream.py]"]
  node_api_schemas["Chat schemas<br/>[schemas.py]"]
  node_user_context["User context<br/>[auth_context.py]"]
end

subgraph group_agent["Agent orchestration"]
  node_agent_graph["LangGraph agent<br/>[graph.py]"]
  node_checkpoint_db[("Thread checkpoints<br/>[graph.py]")]
end

subgraph group_knowledge["Knowledge and operations"]
  node_document_search["Document search<br/>[document_search.py]"]
  node_retriever["Document retrieval<br/>[retrieval.py]"]
  node_ranking["Authority ranking<br/>[source_ranking.py]"]
  node_indexer["Document indexing<br/>[indexer.py]"]
  node_pdf_loader["PDF loading<br/>[documents.py]"]
  node_vector_store[("Chroma index<br/>[indexer.py]")]
  node_data_lookup["Operational lookup<br/>[data_lookup.py]"]
  node_structured_store[("Operational data<br/>[structured.py]")]
  node_credit_calc["Service credit calculation<br/>[calculations.py]"]
end

subgraph group_guardrails["Authorization and actions"]
  node_permissions["Role permissions<br/>[permissions.py]"]
  node_account_access["Account authorization<br/>[data_access.py]"]
  node_escalation_actions["Escalation actions<br/>[actions.py]"]
end

node_user(("Support user"))
node_gemini["Gemini model"]

node_user -->|"asks"| node_chat_ui
node_chat_ui -->|"sends requests"| node_api_client
node_chat_ui -->|"renders"| node_chat_controls
node_chat_ui -->|"renders"| node_confirmation_ui
node_chat_ui -->|"renders"| node_session_sidebar
node_api_client -->|"HTTP requests"| node_chat_routes
node_fastapi -->|"registers"| node_chat_routes
node_chat_routes -->|"invokes and resumes"| node_agent_graph
node_chat_routes -->|"gets user context"| node_user_context
node_chat_routes -->|"validates payloads"| node_api_schemas
node_stream_routes -->|"invokes"| node_agent_graph
node_agent_graph -->|"calls model"| node_gemini
node_agent_graph -->|"saves thread state"| node_checkpoint_db
node_agent_graph -->|"dispatches tool"| node_document_search
node_agent_graph -->|"dispatches tool"| node_data_lookup
node_agent_graph -->|"dispatches tool"| node_credit_calc
node_agent_graph -->|"prepares and executes"| node_escalation_actions
node_agent_graph -->|"checks role"| node_permissions
node_document_search -->|"searches"| node_retriever
node_document_search -->|"ranks results"| node_ranking
node_retriever -->|"queries"| node_vector_store
node_indexer -->|"loads documents"| node_pdf_loader
node_indexer -->|"writes chunks"| node_vector_store
node_data_lookup -->|"reads records"| node_structured_store
node_escalation_actions -->|"reads tickets"| node_structured_store
node_escalation_actions -->|"checks account scope"| node_account_access
node_chat_ui -.->|"streams replies"| node_stream_routes

click node_chat_ui "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/App.tsx"
click node_chat_controls "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/tree/main/frontend/src/components"
click node_confirmation_ui "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/components/ConfirmationCard.tsx"
click node_session_sidebar "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/components/Sidebar.tsx"
click node_api_client "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/services/api.ts"
click node_fastapi "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/main.py"
click node_chat_routes "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/chat.py"
click node_stream_routes "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/chat_stream.py"
click node_api_schemas "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/schemas.py"
click node_user_context "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/auth_context.py"
click node_agent_graph "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/agent/graph.py"
click node_checkpoint_db "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/agent/graph.py"
click node_document_search "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/document_search.py"
click node_retriever "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/retrieval.py"
click node_ranking "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/source_ranking.py"
click node_indexer "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/indexer.py"
click node_pdf_loader "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/documents.py"
click node_vector_store "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/indexer.py"
click node_data_lookup "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/data_lookup.py"
click node_structured_store "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/structured.py"
click node_credit_calc "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/calculations.py"
click node_permissions "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/permissions.py"
click node_account_access "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/data_access.py"
click node_escalation_actions "https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/actions.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_chat_controls,node_confirmation_ui,node_session_sidebar,node_api_client,node_user toneBlue
class node_fastapi,node_chat_routes,node_stream_routes,node_api_schemas,node_user_context toneAmber
class node_agent_graph,node_checkpoint_db toneMint
class node_document_search,node_retriever,node_ranking,node_indexer,node_pdf_loader,node_vector_store,node_data_lookup,node_structured_store,node_credit_calc toneRose
class node_permissions,node_account_access,node_escalation_actions,node_gemini toneIndigo
```

## Components

### Chat interface

- [Chat application](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Chat controls](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/tree/main/frontend/src/components): `frontend/src/components`
- [Confirmation card](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/components/ConfirmationCard.tsx): `frontend/src/components/ConfirmationCard.tsx`
- [Session sidebar](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/components/Sidebar.tsx): `frontend/src/components/Sidebar.tsx`
- [API client](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`

### API and identity

- [FastAPI application](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/main.py): `app/main.py`
- [Chat endpoints](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/chat.py): `app/api/chat.py`
- [Streaming endpoint](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/chat_stream.py): `app/api/chat_stream.py`
- [Chat schemas](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/api/schemas.py): `app/api/schemas.py`
- [User context](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/auth_context.py): `app/services/auth_context.py`

### Agent orchestration

- [LangGraph agent](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/agent/graph.py): `app/agent/graph.py`
- [Thread checkpoints](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/agent/graph.py): `app/agent/graph.py`

### Knowledge and operations

- [Document search](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/document_search.py): `app/tools/document_search.py`
- [Document retrieval](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/retrieval.py): `app/services/retrieval.py`
- [Authority ranking](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/source_ranking.py): `app/services/source_ranking.py`
- [Document indexing](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/indexer.py): `app/ingestion/indexer.py`
- [PDF loading](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/documents.py): `app/ingestion/documents.py`
- [Chroma index](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/indexer.py): `app/ingestion/indexer.py`
- [Operational lookup](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/data_lookup.py): `app/tools/data_lookup.py`
- [Operational data](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/ingestion/structured.py): `app/ingestion/structured.py`
- [Service credit calculation](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/calculations.py): `app/tools/calculations.py`

### Authorization and actions

- [Role permissions](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/permissions.py): `app/services/permissions.py`
- [Account authorization](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/services/data_access.py): `app/services/data_access.py`
- [Escalation actions](https://github.com/jinendra12kumar/parcelpilot-ai-chatbot/blob/main/app/tools/actions.py): `app/tools/actions.py`

### Other components

- **Support user**
- **Gemini model**

## Connections

- Support user → Chat application: asks (evidence: `README.md`)
- Chat application → API client: sends requests (evidence: `frontend/src/App.tsx`)
- Chat application → Chat controls: renders (evidence: `frontend/src/App.tsx`)
- Chat application → Confirmation card: renders (evidence: `frontend/src/App.tsx`)
- Chat application → Session sidebar: renders (evidence: `frontend/src/App.tsx`)
- API client → Chat endpoints: HTTP requests (evidence: `README.md`)
- FastAPI application → Chat endpoints: registers (evidence: `app/main.py`)
- Chat endpoints → LangGraph agent: invokes and resumes (evidence: `app/api/chat.py`)
- Chat endpoints → User context: gets user context
- Chat endpoints → Chat schemas: validates payloads (evidence: `app/api/chat.py`)
- Streaming endpoint → LangGraph agent: invokes (evidence: `app/api/chat_stream.py`)
- LangGraph agent → Gemini model: calls model (evidence: `app/agent/graph.py`)
- LangGraph agent → Thread checkpoints: saves thread state (evidence: `app/agent/graph.py`)
- LangGraph agent → Document search: dispatches tool (evidence: `app/agent/graph.py`)
- LangGraph agent → Operational lookup: dispatches tool (evidence: `app/agent/graph.py`)
- LangGraph agent → Service credit calculation: dispatches tool (evidence: `app/agent/graph.py`)
- LangGraph agent → Escalation actions: prepares and executes (evidence: `app/agent/graph.py`)
- LangGraph agent → Role permissions: checks role (evidence: `app/agent/graph.py`)
- Document search → Document retrieval: searches (evidence: `app/tools/document_search.py`)
- Document search → Authority ranking: ranks results (evidence: `app/tools/document_search.py`)
- Document retrieval → Chroma index: queries (evidence: `app/services/retrieval.py`)
- Document indexing → PDF loading: loads documents (evidence: `app/ingestion/indexer.py`)
- Document indexing → Chroma index: writes chunks (evidence: `app/ingestion/indexer.py`)
- Operational lookup → Operational data: reads records (evidence: `app/tools/data_lookup.py`)
- Escalation actions → Operational data: reads tickets (evidence: `app/tools/actions.py`)
- Escalation actions → Account authorization: checks account scope (evidence: `app/tools/actions.py`)
- Chat application → Streaming endpoint: streams replies (evidence: `README.md`)
