# shakil1819/interactive-estimation-system-using-llm-based-rag-approach architecture

> Architecture diagram of the GitHub repository shakil1819/interactive-estimation-system-using-llm-based-rag-approach, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach
- Repository: https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach

## Overview

##### Project Type and Purpose
- This is a full-stack prototype “Interactive Estimation System” that guides a user through a conversational flow to gather service information (e.g., roofing) and returns a structured cost estimate.
- The backend is a FastAPI service leveraging Langgraph/Langchain and OpenAI for conversation management and information extraction. The frontend is a Streamlit app for real-time user interaction.

##### File Structure
- Top-level:
– Dockerfile, docker-compose.yml, run scripts (run.py, run.sh, run.ps1) for containerized or local startup.
– setup.py, setup.cfg for packaging.
– ARCHITECTURE.md, INSTALL.md, USER_GUIDE.md for documentation.
– config.json and `.env.example` for estimation parameters and API keys.
- backend/app:
– main.py defines FastAPI endpoints.
– graph.py defines the conversational graph via Langgraph.
– estimator.py encapsulates estimation logic.
– models.py defines Pydantic schemas.
– llm_service.py wraps calls to the OpenAI API.
– utils.py contains helpers for question templates and session management.
- frontend:
– app.py is the Streamlit UI.
– image folder holds static assets.
- backend/tests and pytest.ini: test suite with unit tests for each module.

##### README for Additional Insights
- The system uses an in-memory dictionary per session (no persistent DB yet).
- Real-time feedback through Streamlit–FastAPI communication.
- Dynamic questioning via Langgraph, with state transitions.
- Configurable estimation logic driven by config.json.

##### Final Advice
- Be exhaustive: capture every module that plays a role in request handling, conversation management, and estimation.
- Both synchronous flows (HTTP calls) and asynchronous/long-running interactions (LLM calls).
- Keep it modular so new services (e.g., persistent storage, computer vision) can be slotted in easily.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend Layer"
        style FrontendLayer fill:#D0E7FF,stroke:#0366D6,stroke-width:2px
        U["User"]:::external
        UI["Streamlit UI"]:::frontend
        Static["Static Assets"]:::frontend
        Deps["Frontend Dependencies"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Layer"
        style BackendLayer fill:#DFFFE0,stroke:#28A745,stroke-width:2px
        API["FastAPI /chat & /upload"]:::api
        Config["Config Loader"]:::config
        Graph["Conversation Manager"]:::backend
        Estimator["Estimation Engine"]:::backend
        LLM["LLM Service Wrapper"]:::backend
        Models["Pydantic Models"]:::backend
        Utils["Utility Functions & Session Store"]:::backend
    end

    %% External Services
    subgraph "External Services"
        style ExternalLayer fill:#FFF4E5,stroke:#FF8C00,stroke-width:2px
        OA["OpenAI API"]:::external
    end

    %% Deployment & CI
    subgraph "Infrastructure"
        style InfraLayer fill:#F0F0F0,stroke:#6A737D,stroke-width:2px
        Docker["Docker Setup"]:::infra
        CI["CI Pipeline"]:::infra
    end

    %% Relationships
    U -->|"interacts via UI"| UI
    UI -->|"requests estimation"| API
    API -->|"loads config"| Config
    API -->|"validates data"| Models
    API -->|"calls graph"| Graph
    Graph -->|"invokes LLM"| LLM
    LLM -->|"calls external API"| OA
    API -->|"invokes estimation"| Estimator
    API -->|"manages session"| Utils
    Estimator -->|"reads config"| Config
    Utils -->|"stores session"| Utils
    API --> UI

    %% Infrastructure connections
    Docker --> UI
    Docker --> API
    CI --> API

    %% Click Events
    click UI "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/frontend/app.py"
    click Static "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/tree/main/frontend/image/"
    click Deps "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/frontend/requirements.txt"
    click API "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/main.py"
    click Config "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/config.py"
    click Config "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/config.json"
    click Graph "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/graph.py"
    click Estimator "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/estimator.py"
    click LLM "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/llm_service.py"
    click Models "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/models.py"
    click Utils "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/backend/app/utils.py"
    click Docker "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/tree/main/Dockerfile"
    click Docker "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/docker-compose.yml"
    click CI "https://github.com/shakil1819/interactive-estimation-system-using-llm-based-rag-approach/blob/main/.github/workflows/ci.yml"

    %% Styles
    classDef frontend fill:#D0E7FF,stroke:#0366D6,color:#0366D6
    classDef api fill:#DFFFE0,stroke:#28A745,color:#237A00
    classDef backend fill:#DFFFE0,stroke:#28A745,color:#237A00
    classDef config fill:#E8F5E9,stroke:#388E3C,color:#2E7D32
    classDef external fill:#FFF4E5,stroke:#FF8C00,color:#E65100
    classDef infra fill:#F0F0F0,stroke:#6A737D,color:#24292E
```
