# romaindujardin/romain architecture

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

- Interactive diagram: https://gitdiagram.com/romaindujardin/romain
- Repository: https://github.com/romaindujardin/romain

## Overview

##### Project Type and Purpose
- This is a chatbot application built using Streamlit for the web interface.
- Its purpose is to answer professional questions by comparing the input with a vectorized data representation of personal information.

##### Analyzing the File Structure
- Top-Level Files:
- main.py: Likely contains the core logic — orchestrating data processing, embedding, FAISS search, LLM interaction, and UI display.
- requirements.txt and packages.txt: Lists dependencies, hinting at the frameworks and libraries in use.
- Configuration Directories:
- .devcontainer: Contains Docker configuration (devcontainer.json) showing that containerization might be used for development.
- .streamlit: Contains secrets or configuration files for the Streamlit application.
- README.md: Provides an overview of the system’s operation, including step-by-step data and input processing.

##### Architectural Components
a. User Interface:
- Streamlit web app as the front-end for users.
- That the user submits their questions via the web interface.
b. Input Processing:
- Module to process the user's input question.
- Component to convert the question into a vector using an embedding model.
c. Data Management & Vector Storage:
- A module that prepares and stores personal information (data about the user) as vector embeddings.
- FAISS index: Highlight that the system uses FAISS to store these embeddings and retrieve the top relevant documents (e.g., the 3 best matching data pieces).
d. Relevance and Context Retrieval:
- Component that, given the embedded user question, performs a similarity search against stored data vectors.
- Logic to select the 3 most relevant documents, ensuring the context for the question is optimal.
e. LLM Integration:
- Module responsible for constructing the prompt (combining the question, relevant context, and a personalized prompt).
f. Response Processing and Delivery:
- Component to filter and clean up the LLM output (e.g., removing repetitions) before displaying it.
- Flow back to the Streamlit interface for user display.

##### Relationships and Data Flow
- That the user’s input is passed to the Input Processing module (conversion to vector).
- Interaction with the FAISS Index module where the query vector is compared with stored vectors.
- Selected documents being sent along with the user's question to the LLM module.
- Finally, direct the output from the LLM to the Response Processing module and back to the web interface.

##### Architectural Patterns and Technologies
- Use of a pipeline pattern: breaking down the chatbot’s task into discrete stages (input processing, vector search, prompt creation, LLM response, output filtering).
- Mention that containerization (devcontainer) is used to standardize the development environment.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Flow
    UI["User Interface: Streamlit UI"]:::frontend
    IP["Input Processing & Embedding"]:::processing
    FAISS["Vector Storage & FAISS Index"]:::storage
    Prompt["Prompt Assembly"]:::processing
    LLM["LLM Integration (Hugging Face API)"]:::lLM
    Response["Response Filtering & Delivery"]:::processing

    UI -->|"processes"| IP
    IP -->|"embeds & routes"| FAISS
    FAISS -->|"retrieves context"| Prompt
    Prompt -->|"builds prompt"| LLM
    LLM -->|"generates response"| Response
    Response -->|"displays result"| UI

    %% Development Environment Subgraph
    subgraph "Development Environment"
        DevEnv["Containerized Development Environment"]:::dev
        Req["Dependency: requirements.txt"]:::dev
        Pack["Dependency: packages.txt"]:::dev
    end

    %% Supporting connections (dotted lines indicate supporting environment)
    DevEnv --- UI
    Req --- UI
    Pack --- UI

    %% Click Events
    click UI "https://github.com/romaindujardin/romain/blob/main/.streamlit"
    click IP "https://github.com/romaindujardin/romain/blob/main/main.py"
    click FAISS "https://github.com/romaindujardin/romain/blob/main/main.py"
    click LLM "https://github.com/romaindujardin/romain/blob/main/main.py"
    click DevEnv "https://github.com/romaindujardin/romain/blob/main/.devcontainer"
    click Req "https://github.com/romaindujardin/romain/blob/main/requirements.txt"
    click Pack "https://github.com/romaindujardin/romain/blob/main/packages.txt"

    %% Classes and Styles
    classDef frontend fill:#a6cee3,stroke:#1f78b4,stroke-width:2px;
    classDef processing fill:#b2df8a,stroke:#33a02c,stroke-width:2px;
    classDef storage fill:#fb9a99,stroke:#e31a1c,stroke-width:2px;
    classDef lLM fill:#fdbf6f,stroke:#ff7f00,stroke-width:2px;
    classDef dev fill:#cab2d6,stroke:#6a3d9a,stroke-width:2px;
```
