# botirbakhtiyarov/filefinder architecture

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

- Interactive diagram: https://gitdiagram.com/botirbakhtiyarov/filefinder
- Repository: https://github.com/botirbakhtiyarov/filefinder

## Overview

##### Project Overview
- FileFinder is a Python-based desktop application with a modern GUI (via customtkinter) that functions as a smart file search and chat assistant.
- It leverages a separate Flask-based API (api_server.py) to handle AI-driven features such as text/image embedding and OCR processing.
- The application integrates with several external dependencies (Tesseract for OCR, Poppler for PDF processing, SentenceTransformers, and ChineseCLIP for embeddings).

##### Main Components
- Desktop Application Client:
- This is the main GUI layer, implemented in app.py.
- The 'assets/ui' directory contains several UI modules (chat_frame.py, main_app.py, search_frame.py, setup_wizard.py, summary_window.py) which indicate different views and dialogs.
- API Server Backend:
- The Flask API provided by api_server.py exposes endpoints such as /embed_text, /embed_image, /embed_clip_text, /extract_pdf_with_ocr, and /extract_image_ocr.
- This server acts as a middleware for performing AI-based processing tasks.
- Utility & File Management Layer:
- Found in assets/utils/file_utils.py, this module provides file handling utilities which support file search and potentially file indexing operations.
- AI Model Resources:
- The models directory (with instructive text) along with configuration in api_server.py hint at a central repository for storing AI model assets.
- External Dependencies:
- Tesseract OCR for text extraction from images.
- Poppler for PDF-to-image conversions.

##### Diagramming the Architecture

a. Components & Their Labels:
- "Desktop Client UI" (build using customtkinter)
- Represents the main application window and subcomponents (e.g., search, chat, settings).
- "Flask API Server"
- "File Management Utilities"
- Shows supporting modules (assets/utils) that interface with file operations.
- "AI Models & Resources"
- Represents the models directory along with the libraries (SentenceTransformers, ChineseCLIP).
- "External Dependencies"
- Nodes for Tesseract OCR and Poppler, indicating their integration with the API server for document/image processing.

b. Relationships and Data Flow:
- Another layer where the File Management Utilities interact with the Desktop Client to manage file indexing and search functionalities.

c. Architectural Patterns and Design Principles:
- Separation of Concerns: Clearly separate the UI (client) from the processing logic (API server) and the file utility layers.
- Modularity: Each area (UI, API, file management) is designed as a module or component, supporting extensibility.
- External Integration: Emphasize how external libraries and tools (Tesseract and Poppler) are integrated via the API server for specialized processing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Desktop Client UI Subgraph
    subgraph "Desktop Client UI"
        UI_Entry["App Entry"]:::ui
        UI_MainView["Main App View"]:::ui
        UI_Chat["Chat Frame"]:::ui
        UI_Search["Search Frame"]:::ui
        UI_Setup["Setup Wizard"]:::ui
        UI_Summary["Summary Window"]:::ui
    end

    %% Intermediate Components
    FileUtils["File Management Utilities"]:::file
    FlaskAPI["Flask API Server"]:::api

    %% Processing Resources Subgraph
    subgraph "Processing Resources"
        AIModels["AI Models & Resources"]:::ai
        subgraph "External Dependencies"
            Tesseract["Tesseract OCR"]:::ext
            Poppler["Poppler PDF"]:::ext
        end
    end

    %% Connections
    UI_Entry -->|"calls_API"| FlaskAPI
    UI_Search -->|"handles_files"| FileUtils
    FlaskAPI -->|"uses_models"| AIModels
    FlaskAPI -->|"calls_OCR"| Tesseract
    FlaskAPI -->|"pdf_proc"| Poppler

    %% Click Events
    click UI_Entry "https://github.com/botirbakhtiyarov/filefinder/blob/main/app.py"
    click UI_MainView "https://github.com/botirbakhtiyarov/filefinder/blob/main/assets/ui/main_app.py"
    click UI_Chat "https://github.com/botirbakhtiyarov/filefinder/blob/main/assets/ui/chat_frame.py"
    click UI_Search "https://github.com/botirbakhtiyarov/filefinder/blob/main/assets/ui/search_frame.py"
    click UI_Setup "https://github.com/botirbakhtiyarov/filefinder/blob/main/assets/ui/setup_wizard.py"
    click UI_Summary "https://github.com/botirbakhtiyarov/filefinder/blob/main/assets/ui/summary_window.py"
    click FlaskAPI "https://github.com/botirbakhtiyarov/filefinder/blob/main/api_server.py"
    click FileUtils "https://github.com/botirbakhtiyarov/filefinder/blob/main/assets/utils/file_utils.py"
    click AIModels "https://github.com/botirbakhtiyarov/filefinder/tree/main/models/"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef api fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef file fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef ai fill:#D7BDE2,stroke:#6C3483,stroke-width:2px;
    classDef ext fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
```
