How jangjiwon0108/income-tax-chatbot works
Project Type and Purpose
• This is a full-stack retrieval-augmented ChatBot (“소득세법 안내 ChatBot (LangGraph)”) that serves tax-law Q&A over a Korean Income Tax Law PDF.
• The frontend is a Streamlit application (frontend/chatbot_streamlit.py).
• The backend is a Python service (likely FastAPI) under backend/, orchestrating a LangGraph pipeline for RAG (Retrieval-Augmented Generation) and LLM calls.
Top-Level Components
a. Frontend (Streamlit chat UI)
b. Backend API (e.g., FastAPI entrypoint backend/main.py, router in backend/app/router/api_router.py)
c. LangGraph Assistant Pipeline
• Graph definition (backend/app/assistant/graph.py)
• Nodes: retriever, run_gpt, run_upstage_llm, answer_evaluate, result_comparison (backend/app/assistant/nodes/…)
• State & Templates (backend/app/assistant/state.py, templates.py)
d. RAG Module
• Document ingestion & retrieval job (backend/app/rag/rag_job.py)
• Source documents: PDFs in backend/app/rag/
e. History Module
• Conversation persistence (backend/app/history/save_history.py)
f. Config & Schema
• Shared settings (backend/config.py), request/response models (backend/schema.py)
Component Relationships & Data Flow
1. User enters a query in the Streamlit UI.
2. The UI calls the Backend API (e.g., POST /chat).
3. API Router forwards request to the LangGraph pipeline:
• Retriever node locates relevant PDF passages (RAG).
• run_gpt or run_upstage_llm nodes invoke the LLM.
• answer_evaluate and result_comparison nodes refine the output.
4. Pipeline state and templates orchestrate prompts and responses.
5. save_history persists user-bot interactions.
6. Final answer is returned via the API to the Streamlit frontend.
Architectural Patterns & Technologies
• Layered/Onion architecture: UI → API layer → Application logic (LangGraph pipeline) → Data access (PDF retrieval, history store).
• RAG pattern: combining vector search over PDFs with LLM generation.
• Pipeline/Graph pattern via LangGraph nodes.
• Tech stack: Python, FastAPI (inferred), Streamlit, LangGraph, PyPDF or similar for PDF processing.