# juihsuanlee0303/flare architecture

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

- Interactive diagram: https://gitdiagram.com/juihsuanlee0303/flare
- Repository: https://github.com/juihsuanlee0303/flare

## Overview

##### Project type and purpose
- This is an open-source Python microservice/pipeline (“FLARE”) that combines fine-tuned large language models (LLMs) with an augmented retrieval (RAG) vector database to generate security-focused responses.
- It exposes both a CLI entrypoint (`src/flare/main.py`) and an API server (`src/flare/api/main.py`).

##### File structure
- Top-level: configuration (`.env`, `pyproject.toml`), README, tests.
- src/flare/config.py: environment parsing and global settings.
- src/flare/main.py & embedding/main.py: CLI runners for either the full pipeline or embedding steps.
- src/flare/api/main.py: API service (likely FastAPI or Flask) accepting user queries.
- src/flare/embedding/: routines and demos for embedding documents with a Hugging Face embedding model.
- src/flare/rag/: handlers for Qdrant vector DB—indexing and retrieval.
- src/flare/utils/: document chunking, I/O helpers.
- tests/: unit tests for core modules.

##### Extracted system‐level architecture from the README
The README’s ASCII art outlines a linear pipeline:
User Query → Vector DB Retrieval (RAG) → Fine-tuned LLM → Response

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input/Output Layer
    subgraph "Input/Output Layer"
        CLI["CLI Entrypoint (Full Pipeline)"]:::io
        EmbCLI["CLI Entrypoint (Embedding Only)"]:::io
        API["API Service (HTTP)"]:::io
    end

    %% Configuration Layer
    subgraph "Configuration"
        CONFIG["Config & Env Parsing"]:::config
    end

    %% Compute & Logic Layer
    subgraph "Compute & Logic"
        DocHandler["Document Handler / Chunker"]:::compute
        Embedding["Embedding Module"]:::compute
        Retrieval["RAG Retrieval Handler"]:::compute
        LLM["Fine-tuned LLM Inference"]:::compute
        ResponseGen["Response Generator / Formatter"]:::compute
    end

    %% Storage Layer
    Qdrant["Qdrant Vector DB"]:::storage

    %% Demos & Utilities
    subgraph "Utils / Demos"
        EmbDemo["Embedding Module Demo"]:::demo
        RagDemo["RAG Retrieval Demo"]:::demo
        DocDemo["Document Handler Demo"]:::demo
        Tests["Unit Tests"]:::tests
    end

    %% Main Pipeline - Indexing
    CLI -->|invoke pipeline| CONFIG
    EmbCLI -->|invoke embedding only| CONFIG
    CONFIG --> DocHandler
    DocHandler --> Embedding
    Embedding --> Qdrant

    %% Main Pipeline - Query
    API -->|POST query| CONFIG
    CONFIG --> Embedding
    Embedding --> Qdrant
    Qdrant --> Retrieval
    Retrieval --> LLM
    LLM --> ResponseGen
    ResponseGen --> API
    ResponseGen --> CLI

    %% Demos & Tests Connections
    EmbDemo --> Embedding
    RagDemo --> Retrieval
    DocDemo --> DocHandler
    Tests -->|tests modules| Compute & Logic

    %% Click Events
    click CLI "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/main.py"
    click EmbCLI "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/embedding/main.py"
    click API "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/api/main.py"
    click CONFIG "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/config.py"
    click DocHandler "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/utils/document_handler.py"
    click EmbDemo "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/embedding/embedding_demo.py"
    click Retrieval "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/rag/qdrant_handler.py"
    click RagDemo "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/rag/qdrant_handler_demo.py"
    click DocDemo "https://github.com/juihsuanlee0303/flare/blob/develop/src/flare/utils/documnet_handler_demo.py"
    click Tests "https://github.com/juihsuanlee0303/flare/blob/develop/tests/__init__.py"

    %% Styles
    classDef io fill:#D6E9F8,stroke:#31708F,stroke-width:1px
    classDef config fill:#FCF8E3,stroke:#8A6D3B,stroke-width:1px
    classDef compute fill:#DFF0D8,stroke:#3C763D,stroke-width:1px
    classDef storage fill:#FAEBD7,stroke:#A94442,stroke-width:1px
    classDef demo fill:#F5F5F5,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef tests fill:#F2DEDE,stroke:#A94442,stroke-width:1px,stroke-dasharray: 2 2
```
