# kyryl-opens-ml/no-ocr architecture

> Architecture diagram of the GitHub repository kyryl-opens-ml/no-ocr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kyryl-opens-ml/no-ocr
- Repository: https://github.com/kyryl-opens-ml/no-ocr

## Overview

##### Project type and purpose
- This is a full-stack AI-driven document exploration tool.
- Frontend: React/TypeScript app (“no-ocr-ui”).
- Backend: FastAPI service (“no-ocr-api”) for document ingestion, Hugging Face-style dataset creation, and vector search ingestion.
- LLM microservices: Python scripts under “no-ocr-llms” deployed via Modal.
- Data stores: local PDF storage, LanceDB vector store, Supabase for auth and metadata.

##### File structure
- Top-level directories:
- no-ocr-ui — React UI, component hierarchy, Supabase config, Vite build
- no-ocr-api — FastAPI code, data ingestion modules, tests, Dockerfile
- no-ocr-llms — standalone scripts for loading and serving vision-language models
- Config files: docker-compose.yml orchestrates UI, API, LanceDB, Supabase emulator
- CI pipelines under .github/workflows validate tests and linting
- Tests under no-ocr-api/tests exercise API endpoints and ingestion logic
- pyproject.toml and requirements.txt define backend dependencies

##### README for additional insights
- Key technologies: FastAPI, LanceDB (via SearchClient), HF_Dataset, Qwen2-VL, Supabase, Modal, Docker.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Frontend
    User("User (Browser)"):::external
    subgraph "Frontend Layer"
        direction TB
        FrontendApp("no-ocr-ui React App"):::frontend
        APIConfig("REST API Config"):::frontend
        SupabaseConfig1("Supabase Config"):::frontend
        SupabaseConfig2("Supabase Lib"):::frontend
        UIComponents("UI Components/Screens"):::frontend
        FrontendDocker("Docker Image"):::infra
    end

    %% Backend API
    subgraph "Backend API Layer"
        direction TB
        BackendAPI("no-ocr-api FastAPI Service"):::api
        APIEntrypoint("FastAPI Entrypoint"):::api
        DataModule("HF_Dataset Generator"):::api
        SearchModule("SearchClient Module"):::api
        LocalStorage("Local PDF Storage"):::datastore
        BackendTests("API & Ingestion Tests"):::infra
        BackendDeps("Dependencies"):::infra
        BackendDocker("Docker Image"):::infra
    end

    %% LLM Microservices
    subgraph "LLM Microservices"
        direction TB
        LLMServices("no-ocr-llms Scripts"):::worker
        LLMEntrypoint("Generic Entrypoint"):::worker
        Colpali("Colpali Model Endpoint"):::worker
        ModelHelper("Model Loader"):::worker
    end

    %% Data Stores & External
    subgraph "Data Stores & External"
        direction TB
        LanceDB("LanceDB Vector Store"):::datastore
        Supabase("Supabase Auth & Metadata"):::external
        Modal("Modal (Qwen2-VL, Colpali)"):::external
        DockerCompose("docker-compose Orchestrator"):::infra
    end

    %% Relationships - CreateCase Flow
    User -->|"Browse UI"| FrontendApp
    FrontendApp -->|"POST /create_case"| BackendAPI
    FrontendApp -->|"Auth Requests"| Supabase
    BackendAPI -->|"Save PDFs"| LocalStorage
    BackendAPI -->|"Call HF_Dataset"| DataModule
    DataModule -->|"Dataset to Ingest"| SearchModule
    SearchModule -->|"Ingest Vectors"| LanceDB

    %% Relationships - Search Flow
    FrontendApp -->|"GET /search"| BackendAPI
    BackendAPI -->|"Query Vectors"| SearchModule
    SearchModule -->|"Fetch Results"| LanceDB
    FrontendApp -->|"VQA Calls"| Modal
    Modal -->|"Return JSON Answers"| FrontendApp

    %% Other interactions
    BackendAPI -->|"Metadata Read/Write"| Supabase

    %% Click Events
    click FrontendApp "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-ui/"
    click APIConfig "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-ui/src/config/api.ts"
    click SupabaseConfig1 "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-ui/src/config/supabase.ts"
    click SupabaseConfig2 "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-ui/src/lib/supabase.ts"
    click UIComponents "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-ui/src/components/"
    click FrontendDocker "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-ui/Dockerfile"
    click BackendAPI "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-api/"
    click APIEntrypoint "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-api/np_ocr/api.py"
    click DataModule "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-api/np_ocr/data.py"
    click SearchModule "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-api/np_ocr/search.py"
    click LocalStorage "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-api/data/"
    click BackendTests "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-api/tests/"
    click BackendDeps "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-api/requirements.txt"
    click BackendDeps "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-api/pyproject.toml"
    click BackendDocker "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-api/Dockerfile"
    click LLMServices "https://github.com/kyryl-opens-ml/no-ocr/tree/main/no-ocr-llms/"
    click LLMEntrypoint "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-llms/llm_serving.py"
    click Colpali "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-llms/llm_serving_colpali.py"
    click ModelHelper "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-llms/llm_serving_load_models.py"
    click DockerCompose "https://github.com/kyryl-opens-ml/no-ocr/blob/main/docker-compose.yml"
    click CIPipeline1 "https://github.com/kyryl-opens-ml/no-ocr/blob/main/.github/workflows/ci.yml"
    click CIPipeline2 "https://github.com/kyryl-opens-ml/no-ocr/blob/main/.github/workflows/test.yml"
    click EnvExample1 "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-api/.env.example"
    click EnvExample2 "https://github.com/kyryl-opens-ml/no-ocr/blob/main/no-ocr-ui/.env.example"

    %% Styles
    classDef frontend fill:#e0f7ff,stroke:#00aaff,stroke-width:1px
    classDef api fill:#e0ffe0,stroke:#00aa00,stroke-width:1px
    classDef datastore fill:#fff4e6,stroke:#ffa500,stroke-width:1px
    classDef external fill:#f0e0ff,stroke:#a000ff,stroke-width:1px
    classDef infra fill:#f0f0f0,stroke:#888888,stroke-width:1px,stroke-dasharray: 5 5
    classDef worker fill:#fde0e0,stroke:#ff0000,stroke-width:1px,stroke-dasharray: 2 2
```
