# sagnikdebnath07/origamis-pro architecture

> Architecture diagram of the GitHub repository sagnikdebnath07/origamis-pro, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sagnikdebnath07/origamis-pro
- Repository: https://github.com/sagnikdebnath07/origamis-pro

## Overview

##### Project type and purpose
- This is a lightweight full-stack Python application built with Streamlit that implements a Retrieval-Augmented Generation (RAG) chatbot.
- The frontend (app.py) provides an interactive chat UI; the backend (chain.py) handles content loading, vector indexing (FAISS), and orchestration of an OpenAI language model via LangChain.

##### File structure
- Top level:
- .devcontainer/ – defines the development container settings.
- README.md – project overview and instructions.
- requirements.txt – Python dependencies.
- app.py – Streamlit frontend.
- chain.py – core retrieval and generation logic.
- No separate “frontend” or “backend” folders, but functionality is cleanly separated into two modules.
- Configuration files (.devcontainer.json, requirements.txt) sit alongside code.

##### README for additional insights
- Confirms a two-layer architecture: “Frontend(app.py)” vs. “Backend(chain.py).”
- Backend uses: WebBaseLoader → RecursiveCharacterTextSplitter → FAISS vector store → LangChain RetrievalChain → ChatOpenAI model.
- OpenAI API key is provided via Streamlit secrets.
- Conversation state is maintained via Streamlit’s session state.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Actor
    User["User Browser"]:::external

    %% Frontend Layer
    subgraph "Frontend Layer"
        StreamlitApp["app.py<br>(Streamlit UI)"]:::frontend
        SessionState["Session State"]:::datastore
        Secrets["Streamlit Secrets"]:::config
    end

    %% Backend Layer
    subgraph "Backend Layer"
        Chain["chain.py<br>(Retrieval & Generation)"]:::backend
        Loader["WebBaseLoader"]:::module
        Splitter["RecursiveCharacterTextSplitter"]:::module
        FAISSStore["FAISS Vector Store"]:::datastore
        RetrievalChain["LangChain RetrievalChain"]:::module
        Model["OpenAI Chat Model"]:::external
        WebSource["Web Content Source"]:::external
    end

    %% Configuration Files
    subgraph "Configuration"
        DevContainer[".devcontainer/devcontainer.json"]:::config
        Requirements["requirements.txt"]:::config
        READMEFile["README.md"]:::config
    end

    %% Data Flows
    User -->|interacts with| StreamlitApp
    StreamlitApp -->|maintains| SessionState
    StreamlitApp -->|uses secrets| Secrets

    StreamlitApp -->|submit URL/question| Chain

    Chain -->|fetch URL| Loader
    Loader --> Splitter
    Splitter -->|chunk & index| FAISSStore

    StreamlitApp -->|ask question| Chain
    Chain --> RetrievalChain
    RetrievalChain -->|retrieve top-k| FAISSStore
    RetrievalChain -->|call OpenAI API| Model
    Model -->|response| RetrievalChain
    RetrievalChain --> Chain
    Chain -->|return answer| StreamlitApp
    StreamlitApp -->|display response| User

    %% Configuration links
    DevContainer -.-> StreamlitApp
    Requirements -.-> Chain
    READMEFile -.-> User

    %% Click Events
    click StreamlitApp "https://github.com/sagnikdebnath07/origamis-pro/blob/main/app.py"
    click Chain "https://github.com/sagnikdebnath07/origamis-pro/blob/main/chain.py"
    click DevContainer "https://github.com/sagnikdebnath07/origamis-pro/blob/main/.devcontainer/devcontainer.json"
    click Requirements "https://github.com/sagnikdebnath07/origamis-pro/blob/main/requirements.txt"
    click READMEFile "https://github.com/sagnikdebnath07/origamis-pro/blob/main/README.md"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:2px;
    classDef frontend fill:#bbf,stroke:#333,stroke-width:2px;
    classDef backend fill:#bfb,stroke:#333,stroke-width:2px;
    classDef module fill:#fee,stroke:#333,stroke-width:2px;
    classDef datastore fill:#fdb,stroke:#333,stroke-width:2px;
    classDef config fill:#ddd,stroke:#333,stroke-width:2px;
```
